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

File DependencyPane.java

 

Coverage histogram

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

Code metrics

8
17
7
1
113
50
11
0.65
2.43
7
1.57

Classes

Class Line # Actions
DependencyPane 35 17 0% 11 2
0.937593.8%
 

Contributing tests

This file is covered by 5 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.extension.test.po;
21   
22    import java.util.List;
23   
24    import org.openqa.selenium.By;
25    import org.openqa.selenium.WebElement;
26    import org.xwiki.extension.ExtensionId;
27    import org.xwiki.test.ui.po.BaseElement;
28   
29    /**
30    * Displays information about a dependency of an extension.
31    *
32    * @version $Id: d65805e2fc49bd32c0403730e109d77c36fe0eb6 $
33    * @since 4.2M1
34    */
 
35    public class DependencyPane extends BaseElement
36    {
37    /**
38    * The dependency container.
39    */
40    private final WebElement container;
41   
42    /**
43    * Creates a new instance.
44    *
45    * @param container the dependency container
46    */
 
47  15 toggle public DependencyPane(WebElement container)
48    {
49  15 this.container = container;
50    }
51   
52    /**
53    * @return the extension status (loading, core, installed, remote, remote-installed, remote-core,
54    * remote-installed-incompatible, remote-core-incompatible)
55    */
 
56  11 toggle public String getStatus()
57    {
58  11 String[] classNames = container.getAttribute("class").split("\\s+");
59  11 if (classNames.length < 2) {
60  0 return null;
61    }
62  11 return classNames[1].substring("extension-item-".length());
63    }
64   
65    /**
66    * @return the extension status message
67    */
 
68  11 toggle public String getStatusMessage()
69    {
70  11 List<WebElement> found = getDriver().findElementsWithoutWaiting(container, By.className("extension-status"));
71  11 return found.size() > 0 ? found.get(0).getText() : null;
72    }
73   
74    /**
75    * @return the extension link that can be clicked to view more details
76    */
 
77  19 toggle public WebElement getLink()
78    {
79  19 By linkLocator = By.cssSelector("a.extension-link");
80  19 List<WebElement> found = getDriver().findElementsWithoutWaiting(container, linkLocator);
81  19 return found.isEmpty() ? null : found.get(0);
82    }
83   
84    /**
85    * @return the extension name
86    */
 
87  14 toggle public String getName()
88    {
89  14 WebElement link = getLink();
90  14 if (link != null) {
91  13 return link.getText();
92    }
93    // Unknown dependency, with no link.
94  1 String innerText = container.getText();
95  1 return innerText.substring(0, innerText.indexOf(getVersion()));
96    }
97   
98    /**
99    * @return the extension version
100    */
 
101  15 toggle public String getVersion()
102    {
103  15 return getDriver().findElementWithoutWaiting(container, By.className("extension-version")).getText();
104    }
105   
106    /**
107    * @return the extension id
108    */
 
109  7 toggle public ExtensionId getId()
110    {
111  7 return new ExtensionId(getName(), getVersion());
112    }
113    }