1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.shared.artifact.filter.collection;
20
21 import java.util.Set;
22
23 import org.apache.maven.artifact.Artifact;
24 import org.apache.maven.plugin.testing.ArtifactStubFactory;
25 import org.junit.Before;
26 import org.junit.Test;
27
28 import static org.junit.Assert.assertEquals;
29 import static org.junit.Assert.assertTrue;
30
31
32
33
34 public class TestGroupIdFilter extends AbstractArtifactFeatureFilterTest {
35
36 @Before
37 public void setUp() throws Exception {
38 filterClass = GroupIdFilter.class;
39 ArtifactStubFactory factory = new ArtifactStubFactory(null, false);
40 artifacts = factory.getGroupIdArtifacts();
41 }
42
43 @Test
44 public void testParsing() throws Exception {
45 parsing();
46 }
47
48 @Test
49 public void testFiltering() throws Exception {
50 Set<Artifact> result = filtering();
51 for (Artifact artifact : result) {
52 assertTrue(
53 artifact.getGroupId().equals("one") || artifact.getGroupId().equals("two"));
54 }
55 }
56
57 @Test
58 public void testFiltering2() throws Exception {
59 Set<Artifact> result = filtering2();
60 for (Artifact artifact : result) {
61 assertTrue(
62 artifact.getGroupId().equals("two") || artifact.getGroupId().equals("four"));
63 }
64 }
65
66 @Test
67 public void testFiltering3() throws Exception {
68 filtering3();
69 }
70
71 @Test
72 public void testFiltering4() throws Exception {
73
74 Set<Artifact> result = filtering();
75 assertEquals(1, result.size());
76 GroupIdFilter filter = new GroupIdFilter("o", null);
77 result = filter.filter(result);
78 for (Artifact artifact : result) {
79 assertEquals("one", artifact.getGroupId());
80 }
81
82
83 result = filtering();
84 assertEquals(1, result.size());
85 filter = new GroupIdFilter(null, "on");
86 result = filter.filter(result);
87 for (Artifact artifact : result) {
88 assertEquals("two", artifact.getGroupId());
89 }
90 }
91
92 @Test
93 public void testMultipleInclude() throws SecurityException, IllegalArgumentException, ArtifactFilterException {
94 ArtifactsFilter filter = new GroupIdFilter("one,two", null);
95
96 assertEquals(4, artifacts.size());
97
98 Set<Artifact> result = filter.filter(artifacts);
99
100 assertEquals(2, result.size());
101 }
102
103 @Test
104 public void testMultipleExclude() throws SecurityException, IllegalArgumentException, ArtifactFilterException {
105 ArtifactsFilter filter = new GroupIdFilter(null, "one,two");
106
107 assertEquals(4, artifacts.size());
108
109 Set<Artifact> result = filter.filter(artifacts);
110
111 assertEquals(2, result.size());
112 }
113 }