1 package org.apache.maven.shared.transfer.dependencies.collect.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.model.Dependency;
25 import org.apache.maven.model.Model;
26 import org.apache.maven.project.ProjectBuildingRequest;
27 import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException;
28 import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
29 import org.apache.maven.shared.transfer.dependencies.DependableCoordinate;
30 import org.apache.maven.shared.transfer.dependencies.collect.DependencyCollector;
31 import org.apache.maven.shared.transfer.dependencies.collect.DependencyCollectorException;
32 import org.apache.maven.shared.transfer.dependencies.collect.internal.DefaultDependencyCollector;
33 import org.junit.Before;
34 import org.junit.Rule;
35 import org.junit.Test;
36 import org.junit.rules.ExpectedException;
37
38 public class DefaultDependencyCollectorTest
39 {
40
41 @Rule
42 public ExpectedException thrown = ExpectedException.none();
43
44 private DependencyCollector dc;
45
46 @Before
47 public void setUp()
48 {
49 dc = new DefaultDependencyCollector();
50 }
51
52 @Test
53 public void collectDependenciesWithDependableCoordinatShouldFailWithIAEWhenParameterBuildingRequestIsNull()
54 throws ArtifactDeployerException, ArtifactResolverException, DependencyCollectorException
55 {
56 thrown.expect( IllegalArgumentException.class );
57 thrown.expectMessage( "The parameter buildingRequest is not allowed to be null." );
58
59 dc.collectDependencies( null, (DependableCoordinate) null );
60 }
61
62 @Test
63 public void collectDependenciesWithDependableCoordinatShouldFailWithIAEWhenParameterRootIsNull()
64 throws ArtifactDeployerException, ArtifactResolverException, DependencyCollectorException
65 {
66 thrown.expect( IllegalArgumentException.class );
67 thrown.expectMessage( "The parameter root is not allowed to be null." );
68
69 ProjectBuildingRequest request = mock( ProjectBuildingRequest.class );
70 dc.collectDependencies( request, (DependableCoordinate) null );
71 }
72
73 @Test
74 public void collectDependenciesWithDependencyShouldFailWithIAEWhenParameterBuildingRequestIsNull()
75 throws ArtifactDeployerException, ArtifactResolverException, DependencyCollectorException
76 {
77 thrown.expect( IllegalArgumentException.class );
78 thrown.expectMessage( "The parameter buildingRequest is not allowed to be null." );
79
80 dc.collectDependencies( null, (Dependency) null );
81 }
82
83 @Test
84 public void collectDependenciesWithDependencyShouldFailWithIAEWhenParameterRootIsNull()
85 throws ArtifactDeployerException, ArtifactResolverException, DependencyCollectorException
86 {
87 thrown.expect( IllegalArgumentException.class );
88 thrown.expectMessage( "The parameter root is not allowed to be null." );
89
90 ProjectBuildingRequest request = mock( ProjectBuildingRequest.class );
91 dc.collectDependencies( request, (Dependency) null );
92 }
93
94 @Test
95 public void collectDependenciesWithModelShouldFailWithIAEWhenParameterBuildingRequestIsNull()
96 throws ArtifactDeployerException, ArtifactResolverException, DependencyCollectorException
97 {
98 thrown.expect( IllegalArgumentException.class );
99 thrown.expectMessage( "The parameter buildingRequest is not allowed to be null." );
100
101 dc.collectDependencies( null, (Model) null );
102 }
103
104 @Test
105 public void collectDependenciesWithModelShouldFailWithIAEWhenParameterRootIsNull()
106 throws ArtifactDeployerException, ArtifactResolverException, DependencyCollectorException
107 {
108 thrown.expect( IllegalArgumentException.class );
109 thrown.expectMessage( "The parameter root is not allowed to be null." );
110
111 ProjectBuildingRequest request = mock( ProjectBuildingRequest.class );
112 dc.collectDependencies( request, (Model) null );
113 }
114
115 }