1 package org.apache.maven.shared.transfer.artifact.resolve.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.artifact.Artifact;
25 import org.apache.maven.project.ProjectBuildingRequest;
26 import org.apache.maven.shared.transfer.artifact.ArtifactCoordinate;
27 import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver;
28 import org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolverException;
29 import org.junit.Before;
30 import org.junit.Rule;
31 import org.junit.Test;
32 import org.junit.rules.ExpectedException;
33
34
35
36
37
38
39 public class DefaultArtifactResolverTest
40 {
41
42 @Rule
43 public ExpectedException thrown = ExpectedException.none();
44
45 private ArtifactResolver dap;
46
47 @Before
48 public void setUp()
49 {
50 dap = new DefaultArtifactResolver();
51 }
52
53 @Test
54 public void resolveArtifactWithArtifactShouldFaileWithIAEWhenParameterBuildingRequestIsNull()
55 throws ArtifactResolverException
56 {
57 thrown.expect( IllegalArgumentException.class );
58 thrown.expectMessage( "The parameter buildingRequest is not allowed to be null." );
59
60 dap.resolveArtifact( null, (Artifact) null );
61 }
62
63 @Test
64 public void resolveArtifactWithArtifactShouldFaileWithIAEWhenArtifactIsNull()
65 throws ArtifactResolverException
66 {
67 thrown.expect( IllegalArgumentException.class );
68 thrown.expectMessage( "The parameter mavenArtifact is not allowed to be null." );
69
70 ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
71
72 dap.resolveArtifact( pbr, (Artifact) null );
73 }
74
75 @Test
76 public void resolveArtifactWithCoordinateShouldFaileWithIAEWhenParameterBuildingRequestIsNull()
77 throws ArtifactResolverException
78 {
79 thrown.expect( IllegalArgumentException.class );
80 thrown.expectMessage( "The parameter buildingRequest is not allowed to be null." );
81
82 dap.resolveArtifact( null, (ArtifactCoordinate) null );
83 }
84
85 @Test
86 public void resolveArtifactWithCoordinateShouldFaileWithIAEWhenArtifactIsNull()
87 throws ArtifactResolverException
88 {
89 thrown.expect( IllegalArgumentException.class );
90 thrown.expectMessage( "The parameter coordinate is not allowed to be null." );
91
92 ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
93
94 dap.resolveArtifact( pbr, (ArtifactCoordinate) null );
95 }
96
97 }