View Javadoc
1   package org.apache.maven.shared.transfer.dependencies.collect.internal;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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 }