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

File TestGroupFactory.java

 

Coverage histogram

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

Code metrics

0
7
4
1
76
39
4
0.57
1.75
4
1

Classes

Class Line # Actions
TestGroupFactory 40 7 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.security.authorization.testwikis.TestDocument;
30    import org.xwiki.security.authorization.testwikis.TestEntity;
31    import org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestDocument;
32    import org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestGroupDocument;
33   
34    /**
35    * Factory for document representing groups.
36    *
37    * @version $Id: 60651583da89c44a2cef7ee6b850bbdc85955d9a $
38    * @since 5.0M2
39    */
 
40    public class TestGroupFactory extends TestUserFactory
41    {
42    /**
43    * Create a new factory for document representing groups.
44    * @param parent parent entity to used by this factory.
45    */
 
46  55 toggle TestGroupFactory(TestEntity parent)
47    {
48  55 super(parent);
49    }
50   
 
51  55 toggle @Override
52    public List<String> getTagNames()
53    {
54  55 return Arrays.asList("group");
55    }
56   
 
57  26 toggle @Override
58    protected void registerFactories(ElementParser parser, TestDocument entity)
59    {
60  26 super.registerFactories(parser, entity);
61  26 parser.register(new TestGroupUserFactory(entity));
62    }
63   
 
64  26 toggle @Override
65    TestDocument getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes)
66    {
67  26 EntityReference reference = parser.getResolver().resolve(attributes.getValue("name"),
68    DefaultTestDocument.TYPE,
69    parent.getReference());
70  26 EntityReference creator = parser.getResolver().resolve(attributes.getValue("creator"),
71    DefaultTestDocument.TYPE,
72    new EntityReference(XWikiConstants.XWIKI_SPACE, EntityType.SPACE, reference.getRoot()));
73   
74  26 return new DefaultTestGroupDocument(reference, creator, attributes.getValue("alt"), parent);
75    }
76    }