1 package it.com.atlassian.plugin.refimpl;
2
3 import com.atlassian.webdriver.refapp.page.RefappPluginIndexPage;
4 import com.google.common.base.Function;
5 import com.google.common.base.Predicate;
6 import com.google.common.collect.ImmutableList;
7 import com.google.common.collect.Iterables;
8 import org.junit.Test;
9
10 import java.util.Collections;
11 import java.util.Set;
12
13 import static org.junit.Assert.assertEquals;
14 import static org.junit.Assert.assertFalse;
15
16 public class TestIndex extends AbstractRefappTestCase {
17 @Test
18 public void testIndex() {
19 RefappPluginIndexPage pluginIndexPage = PRODUCT.visit(RefappPluginIndexPage.class);
20 Set<String> pluginKeys = pluginIndexPage.getPluginKeys();
21 pluginKeys.contains("com.atlassian.plugin.osgi.bridge");
22
23
24 Set<RefappPluginIndexPage.Bundle> bundles = pluginIndexPage.getBundles();
25
26 assertFalse("Plugins should be present", bundles.isEmpty());
27
28 assertEquals("none of the plugins should be just 'Installed'",
29 Collections.emptyList(),
30 ImmutableList.copyOf(
31 Iterables.transform(Iterables.filter(bundles, IS_INSTALLED), GET_BUNDLE_DESCRIPTION)
32 ));
33 }
34
35 private static Predicate<RefappPluginIndexPage.Bundle> IS_INSTALLED = new Predicate<RefappPluginIndexPage.Bundle>() {
36 public boolean apply(RefappPluginIndexPage.Bundle bundle) {
37 return bundle.getState().equals("Installed");
38 }
39 };
40
41 private static Function<RefappPluginIndexPage.Bundle, String> GET_BUNDLE_DESCRIPTION = new Function<RefappPluginIndexPage.Bundle, String>() {
42 public String apply(RefappPluginIndexPage.Bundle bundle) {
43 return bundle.getSymbolicName() + " " + bundle.getVersion();
44 }
45 };
46 }