1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugins.shade.mojo;
20
21 import java.util.Collection;
22 import java.util.Collections;
23
24 import org.junit.Test;
25
26 import static org.junit.Assert.assertFalse;
27 import static org.junit.Assert.assertTrue;
28
29
30
31
32 public class ArtifactSelectorTest {
33
34 private ArtifactSelector newSelector(Collection<String> includes, Collection<String> excludes, String groupPrefix) {
35 return new ArtifactSelector(includes, excludes, groupPrefix);
36 }
37
38 @Test
39 public void testIsSelected() {
40 ArtifactSelector selector;
41
42 selector = newSelector(null, null, null);
43 assertTrue(selector.isSelected(new ArtifactId("gid", "aid", "type", "cls")));
44
45 selector = newSelector(null, null, "");
46 assertTrue(selector.isSelected(new ArtifactId("gid", "aid", "type", "cls")));
47
48 selector = newSelector(null, null, "gid");
49 assertTrue(selector.isSelected(new ArtifactId("gid", "aid", "type", "cls")));
50 assertTrue(selector.isSelected(new ArtifactId("gid.test", "aid", "type", "cls")));
51 assertFalse(selector.isSelected(new ArtifactId("id", "aid", "type", "cls")));
52
53 selector = newSelector(Collections.<String>emptySet(), Collections.<String>emptySet(), null);
54 assertTrue(selector.isSelected(new ArtifactId("gid", "aid", "type", "cls")));
55
56 selector = newSelector(Collections.singleton("gid:aid"), Collections.<String>emptySet(), null);
57 assertTrue(selector.isSelected(new ArtifactId("gid", "aid", "type", "cls")));
58 assertFalse(selector.isSelected(new ArtifactId("gid", "id", "type", "cls")));
59
60 selector = newSelector(Collections.<String>emptySet(), Collections.singleton("gid:aid"), null);
61 assertFalse(selector.isSelected(new ArtifactId("gid", "aid", "type", "cls")));
62 assertTrue(selector.isSelected(new ArtifactId("gid", "id", "type", "cls")));
63
64 selector = newSelector(Collections.singleton("gid:*"), Collections.singleton("*:aid"), null);
65 assertTrue(selector.isSelected(new ArtifactId("gid", "id", "type", "cls")));
66 assertFalse(selector.isSelected(new ArtifactId("gid", "aid", "type", "cls")));
67 assertFalse(selector.isSelected(new ArtifactId("gid.test", "id", "type", "cls")));
68 }
69 }