1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.graph;
20
21 import java.util.Arrays;
22 import java.util.Collections;
23
24 import org.eclipse.aether.artifact.DefaultArtifact;
25 import org.junit.Test;
26
27 import static org.junit.Assert.*;
28
29
30
31 public class DependencyTest {
32
33 @Test
34 public void testSetScope() {
35 Dependency d1 = new Dependency(new DefaultArtifact("gid:aid:ver"), "compile");
36
37 Dependency d2 = d1.setScope(null);
38 assertNotSame(d2, d1);
39 assertEquals("", d2.getScope());
40
41 Dependency d3 = d1.setScope("test");
42 assertNotSame(d3, d1);
43 assertEquals("test", d3.getScope());
44 }
45
46 @Test
47 public void testSetExclusions() {
48 Dependency d1 = new Dependency(
49 new DefaultArtifact("gid:aid:ver"),
50 "compile",
51 false,
52 Collections.singleton(new Exclusion("g", "a", "c", "e")));
53
54 Dependency d2 = d1.setExclusions(null);
55 assertNotSame(d2, d1);
56 assertEquals(0, d2.getExclusions().size());
57
58 assertSame(d2, d2.setExclusions(null));
59 assertSame(d2, d2.setExclusions(Collections.<Exclusion>emptyList()));
60 assertSame(d2, d2.setExclusions(Collections.<Exclusion>emptySet()));
61 assertSame(d1, d1.setExclusions(Arrays.asList(new Exclusion("g", "a", "c", "e"))));
62
63 Dependency d3 =
64 d1.setExclusions(Arrays.asList(new Exclusion("g", "a", "c", "e"), new Exclusion("g", "a", "c", "f")));
65 assertNotSame(d3, d1);
66 assertEquals(2, d3.getExclusions().size());
67 }
68 }