View Javadoc
1   /*
2    * Copyright 2014 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * You may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.codehaus.gmavenplus.mojo;
18  
19  import org.apache.maven.project.MavenProject;
20  import org.junit.Before;
21  import org.junit.Test;
22  import org.mockito.Mock;
23  import org.mockito.MockitoAnnotations;
24  
25  import java.io.File;
26  
27  import static org.mockito.Mockito.verify;
28  
29  
30  /**
31   * Unit tests for the AddStubSourcesMojo class.
32   *
33   * @author Keegan Witt
34   */
35  public class AddStubSourcesMojoTest {
36      private AddStubSourcesMojo addStubSourcesMojo;
37      @Mock
38      private MavenProject project;
39      @Mock
40      private File stubsOutputDirectory;
41  
42      @Before
43      public void setup() {
44          MockitoAnnotations.openMocks(this);
45          addStubSourcesMojo = new AddStubSourcesMojo();
46          addStubSourcesMojo.project = project;
47          addStubSourcesMojo.stubsOutputDirectory = stubsOutputDirectory;
48      }
49  
50      @Test
51      public void testAddsStubsToSources() {
52          addStubSourcesMojo.execute();
53          verify(project).addCompileSourceRoot(stubsOutputDirectory.getAbsolutePath());
54      }
55  
56  }