1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.extension.test.po

File ExtensionDescriptionPane.java

 

Coverage histogram

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

Code metrics

2
25
12
1
163
75
13
0.52
2.08
12
1.08

Classes

Class Line # Actions
ExtensionDescriptionPane 35 25 0% 13 6
0.8461538684.6%
 

Contributing tests

This file is covered by 1 test. .

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.extension.test.po;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import org.openqa.selenium.By;
26    import org.openqa.selenium.WebElement;
27    import org.xwiki.test.ui.po.BaseElement;
28   
29    /**
30    * The section that displays various information about an extension, like its license and web page.
31    *
32    * @version $Id: 8c3dee29227da8fd535b67a30935ac87d837dd4d $
33    * @since 4.2M1
34    */
 
35    public class ExtensionDescriptionPane extends BaseElement
36    {
37    /**
38    * The XPath used to access a definition list item if we know the definition term.
39    */
40    private static final String DEFINITION_FOR_TERM_XPATH = ".//dd[preceding-sibling::dt[1][. = '%s']]";
41   
42    /**
43    * The section container.
44    */
45    private final WebElement container;
46   
47    /**
48    * Creates a new instance.
49    *
50    * @param container the section container
51    */
 
52  2 toggle public ExtensionDescriptionPane(WebElement container)
53    {
54  2 this.container = container;
55    }
56   
57    /**
58    * @return the extension license
59    */
 
60  1 toggle public String getLicense()
61    {
62  1 return getMetaData("License");
63    }
64   
65    /**
66    * @return the extension web site link
67    */
 
68  1 toggle public WebElement getWebSite()
69    {
70  1 return getMetaDataLink("Website");
71    }
72   
73    /**
74    * @return the extension id
75    */
 
76  1 toggle public String getId()
77    {
78  1 return getMetaData("Id");
79    }
80   
81    /**
82    * @return the extensions features
83    */
 
84  1 toggle public List<String> getFeatures()
85    {
86  1 By xpath = By.xpath(String.format(DEFINITION_FOR_TERM_XPATH, "Feature"));
87  1 List<WebElement> featureElements = getDriver().findElementsWithoutWaiting(container, xpath);
88  1 if (featureElements.isEmpty()) {
89  0 featureElements = getMetaDataList("Features");
90    }
91  1 List<String> features = new ArrayList<>();
92  1 for (WebElement element : featureElements) {
93  1 features.add(element.getText());
94    }
95  1 return features;
96    }
97   
98    /**
99    * @return the extension type
100    */
 
101  1 toggle public String getType()
102    {
103  1 return getMetaData("Type");
104    }
105   
106    /**
107    * @return the link to the extension sources
108    */
 
109  0 toggle public WebElement getSources()
110    {
111  0 return getMetaDataLink("Sources");
112    }
113   
114    /**
115    * @return the link to the extension issue tracker
116    */
 
117  0 toggle public WebElement getIssues()
118    {
119  0 return getMetaDataLink("Issues");
120    }
121   
122    /**
123    * @return the list of namespaces where the extension is installed
124    */
 
125  1 toggle public List<String> getNamespaces()
126    {
127  1 List<String> namespaces = new ArrayList<>();
128  1 for (WebElement element : getMetaDataList("Installed on the following namespaces")) {
129  1 namespaces.add(element.getText());
130    }
131  1 return namespaces;
132    }
133   
134    /**
135    * @param label the meta data label
136    * @return the extension meta data for the specified label
137    */
 
138  3 toggle private String getMetaData(String label)
139    {
140  3 By xpath = By.xpath(String.format(DEFINITION_FOR_TERM_XPATH, label));
141  3 return getDriver().findElementWithoutWaiting(container, xpath).getText();
142    }
143   
144    /**
145    * @param label the meta data label
146    * @return the link element associated with the specified meta data
147    */
 
148  1 toggle private WebElement getMetaDataLink(String label)
149    {
150  1 By xpath = By.xpath(String.format(DEFINITION_FOR_TERM_XPATH + "/a", label));
151  1 return getDriver().findElementWithoutWaiting(container, xpath);
152    }
153   
154    /**
155    * @param label the meta data label
156    * @return the list items associated with the specified meta data
157    */
 
158  1 toggle private List<WebElement> getMetaDataList(String label)
159    {
160  1 By xpath = By.xpath(String.format(DEFINITION_FOR_TERM_XPATH + "//li", label));
161  1 return getDriver().findElementsWithoutWaiting(container, xpath);
162    }
163    }