View Javadoc
1   /*
2    * Copyright (C) 2013 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  
23  import java.io.File;
24  
25  import static org.junit.Assert.assertEquals;
26  
27  
28  /**
29   * Unit tests for the RemoveStubsMojo class.
30   *
31   * @author Keegan Witt
32   */
33  public class RemoveStubsMojoTest {
34      private RemoveStubsMojo removeStubsMojo;
35      private static final String PATH = "FAKE_PATH";
36      private MavenProject project;
37  
38      @Before
39      public void setup() {
40          removeStubsMojo = new RemoveStubsMojo();
41          project = new MavenProject();
42          removeStubsMojo.project = project;
43          removeStubsMojo.stubsOutputDirectory = new File(PATH);
44      }
45  
46      @Test
47      public void testRemoveSourcePathContainsPath() {
48          project.addCompileSourceRoot(removeStubsMojo.stubsOutputDirectory.getAbsolutePath());
49          assertEquals(1, project.getCompileSourceRoots().size());
50          removeStubsMojo.execute();
51          assertEquals(0, project.getCompileSourceRoots().size());
52      }
53  
54      @Test
55      public void testRemoveSourcePathNotContainsPath() {
56          assertEquals(0, project.getCompileSourceRoots().size());
57          removeStubsMojo.execute();
58          assertEquals(0, project.getCompileSourceRoots().size());
59      }
60  
61  }