1 package org.apache.maven.shared.transfer.collection.internal;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import static org.mockito.Mockito.mock;
23
24 import org.apache.maven.project.ProjectBuildingRequest;
25 import org.apache.maven.shared.transfer.collection.DependencyCollectionException;
26 import org.apache.maven.shared.transfer.collection.DependencyCollector;
27 import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
28 import org.junit.Before;
29 import org.junit.Rule;
30 import org.junit.Test;
31 import org.junit.rules.ExpectedException;
32
33 public class DefaultDependencyCollectorTest {
34
35 @Rule
36 public ExpectedException thrown = ExpectedException.none();
37
38 private DependencyCollector dc;
39
40 @Before
41 public void setUp() {
42 dc = new org.apache.maven.shared.transfer.collection.internal.DefaultDependencyCollector();
43 }
44
45 @Test
46 public void collectDependenciesWithDependencyShouldFailWithNPEWhenParameterBuildingRequestIsNull()
47 throws DependencyCollectionException {
48 thrown.expect( NullPointerException.class );
49 thrown.expectMessage( "The parameter buildingRequest is not allowed to be null." );
50
51 dc.collectDependencies(null, (org.apache.maven.model.Dependency) null);
52 }
53
54 @Test
55 public void collectDependenciesWithDependencyShouldFailWithNPEWhenParameterRootIsNull()
56 throws DependencyCollectionException {
57 thrown.expect( NullPointerException.class );
58 thrown.expectMessage("The parameter root is not allowed to be null.");
59
60 ProjectBuildingRequest request = mock( ProjectBuildingRequest.class );
61 dc.collectDependencies(request, (org.apache.maven.model.Dependency) null);
62 }
63
64 @Test
65 public void collectDependenciesWithDependableCoordinateShouldFailWithNPEWhenParameterBuildingRequestIsNull()
66 throws DependencyCollectionException {
67 thrown.expect(NullPointerException.class);
68 thrown.expectMessage("The parameter buildingRequest is not allowed to be null.");
69
70 dc.collectDependencies(null, (DependableCoordinate) null);
71 }
72
73 @Test
74 public void collectDependenciesWithDependableCoordinateShouldFailWithNPEWhenParameterRootIsNull()
75 throws DependencyCollectionException {
76 thrown.expect( NullPointerException.class );
77 thrown.expectMessage( "The parameter root is not allowed to be null." );
78
79 ProjectBuildingRequest request = mock( ProjectBuildingRequest.class );
80 dc.collectDependencies(request, (DependableCoordinate) null);
81 }
82
83 @Test
84 public void collectDependenciesWithModelShouldFailWithNPEWhenParameterBuildingRequestIsNull()
85 throws DependencyCollectionException {
86 thrown.expect( NullPointerException.class );
87 thrown.expectMessage( "The parameter buildingRequest is not allowed to be null." );
88
89 dc.collectDependencies(null, (org.apache.maven.model.Model) null);
90 }
91
92 @Test
93 public void collectDependenciesWithModelShouldFailWithNPEWhenParameterRootIsNull()
94 throws DependencyCollectionException {
95 thrown.expect( NullPointerException.class );
96 thrown.expectMessage( "The parameter root is not allowed to be null." );
97
98 ProjectBuildingRequest request = mock( ProjectBuildingRequest.class );
99 dc.collectDependencies(request, (org.apache.maven.model.Model) null);
100 }
101 }