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

File TestWikisFactory.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

2
7
4
1
72
35
5
0.71
1.75
4
1.25

Classes

Class Line # Actions
TestWikisFactory 38 7 0% 5 2
0.8461538684.6%
 

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.xml.sax.SAXException;
28    import org.xwiki.security.authorization.testwikis.TestDefinition;
29    import org.xwiki.security.authorization.testwikis.TestEntity;
30    import org.xwiki.security.authorization.testwikis.internal.entities.DefaultTestDefinition;
31   
32    /**
33    * Root entity factory.
34    *
35    * @version $Id: 1a15f85524c872f88cfaf35068b10406412843f0 $
36    * @since 5.0M2
37    */
 
38    public class TestWikisFactory extends AbstractEntityFactory<TestDefinition>
39    {
40    /** The entity created for the root. */
41    private TestDefinition wikis;
42   
 
43  15 toggle @Override
44    public List<String> getTagNames()
45    {
46  15 return Arrays.asList("wikis");
47    }
48   
 
49  15 toggle @Override
50    TestDefinition getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes)
51    throws SAXException
52    {
53  15 if (wikis != null) {
54  0 throw new SAXException(parser.getLocatedMessage("Only one root element is allowed per file."));
55    }
56  15 wikis = new DefaultTestDefinition();
57  15 return wikis;
58    }
59   
 
60  15 toggle @Override
61    protected void registerFactories(ElementParser parser, TestDefinition entity)
62    {
63  15 parser.register(new TestWikiFactory(wikis));
64    }
65   
66    /**
67    * @return the entity created for the root.
68    */
 
69  47 toggle TestDefinition getWikis() {
70  47 return wikis;
71    }
72    }