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

File TestDocumentFactory.java

 

Coverage histogram

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

Code metrics

2
6
3
1
71
34
4
0.67
2
3
1.33

Classes

Class Line # Actions
TestDocumentFactory 39 6 0% 4 0
1.0100%
 

Contributing tests

This file is covered by 12 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   
33    /**
34    * Test document factory.
35    *
36    * @version $Id: 7e3d6133ab8300bc3b6211ffd38f7004b7abd3c9 $
37    * @since 5.0M2
38    */
 
39    public class TestDocumentFactory extends AbstractSecureEntityFactory<TestDocument>
40    {
41    /**
42    * Create a new factory for document of the given parent (a space usually).
43    * @param parent parent entity to used by this factory.
44    */
 
45  58 toggle TestDocumentFactory(TestEntity parent)
46    {
47  58 setParent(parent);
48    }
49   
 
50  58 toggle @Override
51    public List<String> getTagNames()
52    {
53  58 return Arrays.asList("document");
54    }
55   
 
56  88 toggle @Override
57    TestDocument getNewInstance(ElementParser parser, String name, TestEntity parent, Attributes attributes)
58    {
59  88 EntityReference reference = parser.getResolver().resolve(attributes.getValue("name"),
60    DefaultTestDocument.TYPE,
61    parent.getReference());
62  88 String creatorString = attributes.getValue("creator");
63  88 EntityReference creator = (creatorString) != null ? parser.getResolver().resolve(creatorString,
64    DefaultTestDocument.TYPE, new EntityReference(XWikiConstants.XWIKI_SPACE, EntityType.SPACE,
65    reference.getRoot()))
66    : null;
67   
68   
69  88 return new DefaultTestDocument(reference, creator, attributes.getValue("alt"), parent);
70    }
71    }