Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
13   96   10   2.17
8   48   0.77   6
6     1.67  
1    
 
  MockWikiModel       Line # 37 13 0% 10 1 96.3% 0.962963
 
  (37)
 
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.rendering.test;
21   
22    import java.util.Map;
23   
24    import org.xwiki.component.descriptor.ComponentDescriptor;
25    import org.xwiki.component.descriptor.DefaultComponentDescriptor;
26    import org.xwiki.rendering.listener.reference.AttachmentResourceReference;
27    import org.xwiki.rendering.listener.reference.DocumentResourceReference;
28    import org.xwiki.rendering.listener.reference.ResourceReference;
29    import org.xwiki.rendering.wiki.WikiModel;
30   
31    /**
32    * Mock WikiModel implementation for integration tests.
33    *
34    * @version $Id: 6c19a631a8e4a7a49c838701c1c7efa58251f1e0 $
35    * @since 2.0M1
36    */
 
37    public class MockWikiModel implements WikiModel
38    {
39    /**
40    * Question Mark symbol.
41    */
42    private static final String QM = "?";
43   
44    /**
45    * Create and return a descriptor for this component.
46    *
47    * @return the descriptor of the component.
48    */
 
49  180 toggle public static ComponentDescriptor<WikiModel> getComponentDescriptor()
50    {
51  180 DefaultComponentDescriptor<WikiModel> componentDescriptor = new DefaultComponentDescriptor<WikiModel>();
52   
53  180 componentDescriptor.setRole(WikiModel.class);
54  180 componentDescriptor.setImplementation(MockWikiModel.class);
55   
56  180 return componentDescriptor;
57    }
58   
59    /**
60    * {@inheritDoc}
61    * @since 2.5RC1
62    */
 
63  9 toggle @Override
64    public String getLinkURL(ResourceReference linkReference)
65    {
66  9 String queryString = linkReference.getParameter(AttachmentResourceReference.QUERY_STRING);
67  9 return "attachmenturl" + (queryString != null ? QM + queryString : "");
68    }
69   
 
70  21 toggle @Override
71    public String getImageURL(ResourceReference imageReference, Map<String, String> parameters)
72    {
73  21 String queryString = imageReference.getParameter(AttachmentResourceReference.QUERY_STRING);
74  21 return "imageurl" + (queryString != null ? QM + queryString : "");
75    }
76   
 
77  23 toggle @Override
78    public String getDocumentEditURL(ResourceReference documentReference)
79    {
80  23 return "editurl";
81    }
82   
 
83  8 toggle @Override
84    public String getDocumentViewURL(ResourceReference documentReference)
85    {
86  8 String queryString = documentReference.getParameter(DocumentResourceReference.QUERY_STRING);
87  8 String anchor = documentReference.getParameter(DocumentResourceReference.ANCHOR);
88  8 return "viewurl" + (queryString != null ? QM + queryString : "") + (anchor != null ? "#" + anchor : "");
89    }
90   
 
91  31 toggle @Override
92    public boolean isDocumentAvailable(ResourceReference documentReference)
93    {
94  31 return "Space.ExistingPage".equals(documentReference.getReference());
95    }
96    }