1 package com.atlassian.plugin.manager;
2
3 import com.atlassian.plugin.PluginDependencies;
4 import com.google.common.collect.ImmutableList;
5 import com.google.common.collect.ImmutableSet;
6 import org.junit.Test;
7 import org.junit.runner.RunWith;
8 import org.junit.runners.Parameterized;
9
10 import java.util.Arrays;
11 import java.util.Collection;
12 import java.util.Set;
13
14 import static com.atlassian.plugin.PluginDependencies.Type.DYNAMIC;
15 import static com.atlassian.plugin.PluginDependencies.Type.MANDATORY;
16 import static com.atlassian.plugin.PluginDependencies.Type.OPTIONAL;
17 import static org.hamcrest.Matchers.equalTo;
18 import static org.hamcrest.Matchers.is;
19 import static org.junit.Assert.assertThat;
20
21
22 @RunWith(Parameterized.class)
23 public class TestDependentPluginsGetByType extends TestDependentPlugins {
24 @Parameterized.Parameters(name = "{index}: ({1}, {0})")
25 public static Collection<Object[]> data() {
26 return Arrays.asList(new Object[][]{
27 {ImmutableSet.of(MANDATORY, OPTIONAL, DYNAMIC),
28 new String[]{"A", "B", "D", "F", "E", "H"}
29 },
30 {ImmutableSet.of(MANDATORY),
31 new String[]{"E", "H"}
32 },
33 {ImmutableSet.of(OPTIONAL),
34 new String[]{"A", "D", "F"}
35 },
36 {ImmutableSet.of(DYNAMIC),
37 new String[]{"B"}
38 },
39 });
40 }
41
42 @Parameterized.Parameter
43 public Set<PluginDependencies.Type> dependencyTypes;
44
45 @Parameterized.Parameter(1)
46 public String[] expected;
47
48 @Test
49 public void testGet() throws Exception {
50 final DependentPlugins dp = new DependentPlugins(ImmutableList.of("C"), allPlugins,
51 ImmutableSet.of(MANDATORY, OPTIONAL, DYNAMIC));
52
53 final Set<String> keysExpected = ImmutableSet.copyOf(expected);
54 assertThat(getKeys(dp.getByTypes(dependencyTypes)), is(equalTo(keysExpected)));
55 }
56 }