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