View Javadoc
1   package org.apache.maven.shared.transfer.collection.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.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 }