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

File TestUserFactory.java

 

Coverage histogram

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

Code metrics

2
9
3
1
76
40
4
0.44
3
3
1.33

Classes

Class Line # Actions
TestUserFactory 42 9 0% 4 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   
21    package org.xwiki.security.authorization.testwikis.internal.parser;
22   
23    import java.util.Arrays;
24    import java.util.List;
25   
26    import org.xml.sax.Attributes;
27    import org.xwiki.model.EntityType;
28    import org.xwiki.model.reference.EntityReference;
29    import org.xwiki.model.reference.SpaceReference;
30    import org.xwiki.security.authorization.testwikis.TestDocument;
31    import org.xwiki.security.authorization.testwikis.TestEntity;
32    import org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestDocument;
33    import org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestSpace;
34    import org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestUserDocument;
35   
36    /**
37    * Factory for document representing users.
38    *
39    * @version $Id: 16b2b8063412c1ccc00f6e4426b607a061d76aba $
40    * @since 5.0M2
41    */
 
42    public class TestUserFactory extends AbstractSecureEntityFactory<TestDocument>
43    {
44    /**
45    * Create a new factory for document representing users.
46    * @param parent parent entity to used by this factory.
47    */
 
48  110 toggle TestUserFactory(TestEntity parent)
49    {
50  110 SpaceReference xwikiSpaceRef = new SpaceReference(XWikiConstants.XWIKI_SPACE, parent.getReference());
51  110 TestEntity xwikiSpace = parent.getEntity(xwikiSpaceRef);
52  110 if (xwikiSpace == null) {
53  55 xwikiSpace = new DefaultTestSpace(xwikiSpaceRef, null, parent);
54    }
55  110 setParent(xwikiSpace);
56    }
57   
 
58  55 toggle @Override
59    public List<String> getTagNames()
60    {
61  55 return Arrays.asList("user");
62    }
63   
 
64  41 toggle @Override
65    TestDocument getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes)
66    {
67  41 EntityReference reference = parser.getResolver().resolve(attributes.getValue("name"),
68    DefaultTestDocument.TYPE,
69    parent.getReference());
70  41 EntityReference creator = parser.getResolver().resolve(attributes.getValue("creator"),
71    DefaultTestDocument.TYPE,
72    new EntityReference(XWikiConstants.XWIKI_SPACE, EntityType.SPACE, reference.getRoot()));
73   
74  41 return new DefaultTestUserDocument(reference, creator, attributes.getValue("alt"), parent);
75    }
76    }