1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.annotation.maintainer

File TestDocumentFactory.java

 

Coverage histogram

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

Code metrics

4
10
2
1
58
28
5
0.5
5
2
2.5

Classes

Class Line # Actions
TestDocumentFactory 32 10 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 49 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.annotation.maintainer;
21   
22    import java.io.IOException;
23   
24    import org.xwiki.annotation.Annotation;
25   
26    /**
27    * Factory for loading mock documents from test files extended for loading documents with updates.
28    *
29    * @version $Id: 3e8fd5eb65074b90210b492f2dfd7f965e735550 $
30    * @since 2.3M1
31    */
 
32    public class TestDocumentFactory extends org.xwiki.annotation.TestDocumentFactory
33    {
 
34  147 toggle @Override
35    public MockDocument getDocument(String docName) throws IOException
36    {
37  147 MockDocument loadedDoc = (MockDocument) docs.get(docName);
38  147 if (loadedDoc == null) {
39  49 loadedDoc = new MockDocument();
40  49 loadDocument(loadedDoc, docName);
41  49 docs.put(docName, loadedDoc);
42    }
43  147 return loadedDoc;
44    }
45   
 
46  196 toggle @Override
47    protected void saveKeyToDoc(String currentKey, String currentValue, org.xwiki.annotation.MockDocument doc,
48    String docName) throws IOException
49    {
50    // test if it's a modified annotation and parse & save as a modified annotation
51  196 if (currentKey.equals("annotationUpdated") && doc instanceof MockDocument) {
52  49 Annotation ann = parseAnnotation(currentValue, docName);
53  49 ((MockDocument) doc).getUpdatedAnnotations().add(ann);
54    } else {
55  147 super.saveKeyToDoc(currentKey, currentValue, doc, docName);
56    }
57    }
58    }