View Javadoc
1   package com.atlassian.webdriver.refapp.page;
2   
3   import com.google.common.collect.ImmutableSet;
4   import com.google.common.collect.Sets;
5   import org.openqa.selenium.By;
6   import org.openqa.selenium.WebElement;
7   
8   import java.util.HashSet;
9   import java.util.Set;
10  
11  public class RefappPluginIndexPage extends RefappAbstractPage {
12      public String getUrl() {
13          return "/index.jsp";
14      }
15  
16      public Set<String> getPluginKeys() {
17          Set<String> keys = new HashSet<String>();
18          for (WebElement element : driver.findElements(By.className("plugin-key"))) {
19              keys.add(element.getText());
20          }
21  
22          return keys;
23      }
24  
25      public Set<Bundle> getBundles() {
26          Set<Bundle> bundles = new HashSet<Bundle>();
27          for (WebElement element : driver.findElements(By.className("bundle"))) {
28              String symbolicName = element.findElement(By.className("bundle-symbolic-name")).getText();
29              String version = element.findElement(By.className("bundle-version")).getText();
30              String state = element.findElement(By.className("bundle-state")).getText();
31  
32              Set<String> serviceInterfaces = new HashSet<String>();
33  
34              for (WebElement interfaceElement : element.findElements(By.className("bundle-service-interface"))) {
35                  serviceInterfaces.add(interfaceElement.getText());
36              }
37  
38              bundles.add(new Bundle(symbolicName, version, state, serviceInterfaces));
39          }
40  
41          return bundles;
42      }
43  
44      public Set<String> getServiceInterfaces() {
45          Set<String> serviceInterfaces = Sets.newHashSet();
46          for (Bundle bundle : getBundles()) {
47              serviceInterfaces = Sets.union(serviceInterfaces, bundle.getServiceInterfaces());
48          }
49  
50          return serviceInterfaces;
51      }
52  
53      public class Bundle {
54          private final String symbolicName;
55          private final String version;
56          private final String state;
57          private final Set<String> serviceInterfaces;
58  
59          public Bundle(String symbolicName, String version, String state, Set<String> serviceInterfaces) {
60              this.symbolicName = symbolicName;
61              this.version = version;
62              this.state = state;
63              this.serviceInterfaces = ImmutableSet.copyOf(serviceInterfaces);
64          }
65  
66          public String getSymbolicName() {
67              return symbolicName;
68          }
69  
70          public String getVersion() {
71              return version;
72          }
73  
74          public String getState() {
75              return state;
76          }
77  
78          public Set<String> getServiceInterfaces() {
79              return serviceInterfaces;
80          }
81      }
82  }