@Test public void testGetArtifactFileWithDiffType() throws Exception { MyMojo mojo = new MyMojo(); File kitten = new File("kitten"); File puppies = new File("puppies"); mojo.project = mock(MavenProject.class); Artifact artifact1 = mock(Artifact.class); when(artifact1.getArtifactId()).thenReturn("artifact1"); when(artifact1.getType()).thenReturn("kitten"); when(artifact1.getFile()).thenReturn(kitten); Artifact artifact2 = mock(Artifact.class); when(artifact2.getArtifactId()).thenReturn("artifact1"); when(artifact2.getType()).thenReturn("puppies"); when(artifact2.getFile()).thenReturn(puppies); when(mojo.project.getArtifacts()).thenReturn(ImmutableSet.of( artifact1 )); mojo.pluginDependencies = ImmutableList.of( artifact2); assertThat(DependencyFinder.getArtifactFile(mojo, "artifact1", "kitten")).isNotNull().isEqualTo(kitten); assertThat(DependencyFinder.getArtifactFile(mojo, "artifact1", "puppies")).isNotNull().isEqualTo(puppies); assertThat(DependencyFinder.getArtifactFile(mojo, "artifact1", "jar")).isNull(); }
public static File getArtifactFile(AbstractWisdomMojo mojo, String artifactId, String type) { File file = getArtifactFileFromProjectDependencies(mojo, artifactId, type); if (file == null) { file = getArtifactFileFromPluginDependencies(mojo, artifactId, type); } return file; }
DependencyFinder { public static File getArtifactFile(AbstractWisdomMojo mojo, String artifactId, String type) { File file = getArtifactFileFromProjectDependencies(mojo, artifactId, type); if (file == null) { file = getArtifactFileFromPluginDependencies(mojo, artifactId, type); } return file; } }
DependencyFinder { public static File getArtifactFile(AbstractWisdomMojo mojo, String artifactId, String type) { File file = getArtifactFileFromProjectDependencies(mojo, artifactId, type); if (file == null) { file = getArtifactFileFromPluginDependencies(mojo, artifactId, type); } return file; } private  DependencyFinder(); }
DependencyFinder { public static File getArtifactFile(AbstractWisdomMojo mojo, String artifactId, String type) { File file = getArtifactFileFromProjectDependencies(mojo, artifactId, type); if (file == null) { file = getArtifactFileFromPluginDependencies(mojo, artifactId, type); } return file; } private  DependencyFinder(); static File getArtifactFileFromPluginDependencies(AbstractWisdomMojo mojo, String artifactId, String type); static File getArtifactFileFromProjectDependencies(AbstractWisdomMojo mojo, String artifactId,
                                                              String type); static File getArtifactFile(AbstractWisdomMojo mojo, String artifactId, String type); static File resolve(AbstractWisdomMojo mojo, String groupId, String artifactId, String version,
                               String type, String classifier); static File resolve(AbstractWisdomMojo mojo, String coords); }
DependencyFinder { public static File getArtifactFile(AbstractWisdomMojo mojo, String artifactId, String type) { File file = getArtifactFileFromProjectDependencies(mojo, artifactId, type); if (file == null) { file = getArtifactFileFromPluginDependencies(mojo, artifactId, type); } return file; } private  DependencyFinder(); static File getArtifactFileFromPluginDependencies(AbstractWisdomMojo mojo, String artifactId, String type); static File getArtifactFileFromProjectDependencies(AbstractWisdomMojo mojo, String artifactId,
                                                              String type); static File getArtifactFile(AbstractWisdomMojo mojo, String artifactId, String type); static File resolve(AbstractWisdomMojo mojo, String groupId, String artifactId, String version,
                               String type, String classifier); static File resolve(AbstractWisdomMojo mojo, String coords);  }