1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.security.authorization.testwikis.internal.parser

File TestSpaceFactory.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

2
9
4
1
76
38
5
0.56
2.25
4
1.25

Classes

Class Line # Actions
TestSpaceFactory 37 9 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 15 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.security.authorization.testwikis.internal.parser;
21   
22    import java.util.Arrays;
23    import java.util.List;
24   
25    import org.xml.sax.Attributes;
26    import org.xwiki.model.reference.EntityReference;
27    import org.xwiki.security.authorization.testwikis.TestEntity;
28    import org.xwiki.security.authorization.testwikis.TestSpace;
29    import org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestSpace;
30   
31    /**
32    * Test Space factory.
33    *
34    * @version $Id: 8427aed0ccba748aeedbc37162fb6cbcb203c25c $
35    * @since 5.0M2
36    */
 
37    public class TestSpaceFactory extends AbstractSecureEntityFactory<TestSpace>
38    {
39    /**
40    * Create a new factory for spaces of the given parent (wiki usually).
41    * @param parent parent entity to used by this factory.
42    */
 
43  55 toggle TestSpaceFactory(TestEntity parent)
44    {
45  55 setParent(parent);
46    }
47   
 
48  55 toggle @Override
49    public List<String> getTagNames()
50    {
51  55 return Arrays.asList("space");
52    }
53   
 
54  58 toggle @Override
55    TestSpace getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes)
56    {
57  58 EntityReference reference = parser.getResolver().resolve(attributes.getValue("name"),
58    DefaultTestSpace.TYPE,
59    parent.getReference());
60   
61  58 TestSpace space = (TestSpace) parent.getEntity(reference);
62  58 if (space == null) {
63  43 space = new DefaultTestSpace(reference, attributes.getValue("alt"), parent);
64    }
65   
66  58 return space;
67    }
68   
 
69  58 toggle @Override
70    protected void registerFactories(ElementParser parser, TestSpace entity)
71    {
72  58 super.registerFactories(parser, entity);
73  58 parser.register(new TestDocumentFactory(entity));
74    }
75   
76    }