1 package org.apache.maven.shared.transfer.artifact.deploy.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 java.util.Collections;
25
26 import org.apache.maven.artifact.Artifact;
27 import org.apache.maven.project.ProjectBuildingRequest;
28 import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployer;
29 import org.apache.maven.shared.transfer.artifact.deploy.ArtifactDeployerException;
30 import org.apache.maven.shared.transfer.artifact.deploy.internal.DefaultArtifactDeployer;
31 import org.junit.Before;
32 import org.junit.Rule;
33 import org.junit.Test;
34 import org.junit.rules.ExpectedException;
35
36
37
38
39
40
41 public class DefaultArtifactDeployerTest
42 {
43 @Rule
44 public ExpectedException thrown = ExpectedException.none();
45
46 private ArtifactDeployer dap;
47
48 @Before
49 public void setUp()
50 {
51 dap = new DefaultArtifactDeployer();
52 }
53
54 @Test
55 public void deployShouldReturnIllegalArgumentExceptionForFirstParameterWithNull()
56 throws ArtifactDeployerException
57 {
58 thrown.expect( IllegalArgumentException.class );
59 thrown.expectMessage( "The parameter request is not allowed to be null." );
60 dap.deploy( null, Collections.<Artifact>emptyList() );
61 }
62
63 @Test
64 public void deployShouldReturnIllegalArgumentExceptionForSecondParameterWithNull()
65 throws ArtifactDeployerException
66 {
67 ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
68
69 thrown.expect( IllegalArgumentException.class );
70 thrown.expectMessage( "The parameter mavenArtifacts is not allowed to be null." );
71 dap.deploy( pbr, null );
72 }
73
74 @Test
75 public void deployShouldReturnIllegalArgumentExceptionForSecondParameterWithEmpty()
76 throws ArtifactDeployerException
77 {
78 ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
79
80 thrown.expect( IllegalArgumentException.class );
81 thrown.expectMessage( "The collection mavenArtifacts is not allowed to be empty." );
82 dap.deploy( pbr, Collections.<Artifact>emptyList() );
83 }
84
85
86 @Test
87 public void deploy3ParametersShouldReturnIllegalArgumentExceptionForFirstParameterWithNull()
88 throws ArtifactDeployerException
89 {
90 thrown.expect( IllegalArgumentException.class );
91 thrown.expectMessage( "The parameter request is not allowed to be null." );
92 dap.deploy( null, null, Collections.<Artifact>emptyList() );
93 }
94
95 @Test
96 public void deploy3ParametersShouldReturnIllegalArgumentExceptionForSecondParameterWithNull()
97 throws ArtifactDeployerException
98 {
99 ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
100
101 thrown.expect( IllegalArgumentException.class );
102 thrown.expectMessage( "The parameter mavenArtifacts is not allowed to be null." );
103 dap.deploy( pbr, null, null );
104 }
105
106 @Test
107 public void deploy3ParametersShouldReturnIllegalArgumentExceptionForSecondParameterWithEmpty()
108 throws ArtifactDeployerException
109 {
110 ProjectBuildingRequest pbr = mock( ProjectBuildingRequest.class );
111
112 thrown.expect( IllegalArgumentException.class );
113 thrown.expectMessage( "The collection mavenArtifacts is not allowed to be empty." );
114 dap.deploy( pbr, null, Collections.<Artifact>emptyList() );
115 }
116
117 }