[maven-dependency-plugin] branch master updated: Code cleanup (#37)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[maven-dependency-plugin] branch master updated: Code cleanup (#37)

elharo
This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-dependency-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 23bc9f4  Code cleanup (#37)
23bc9f4 is described below

commit 23bc9f4eed7fe7e73d1167fd773ea4e8afd11554
Author: Elliotte Rusty Harold <[hidden email]>
AuthorDate: Sat May 23 10:19:58 2020 -0400

    Code cleanup (#37)
   
    * static import
---
 .../dependency/analyze/TestAnalyzeDepMgt.java      | 54 ++++++----------------
 ...ExcludeReactorProjectsDependencyFilterTest.java |  1 +
 .../testUtils/stubs/DependencyProjectStub.java     |  7 ++-
 .../translators/TestClassifierTypeTranslator.java  |  2 -
 4 files changed, 17 insertions(+), 47 deletions(-)

diff --git a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java
index 268ac1d..d3392a2 100644
--- a/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java
+++ b/src/test/java/org/apache/maven/plugins/dependency/analyze/TestAnalyzeDepMgt.java
@@ -34,6 +34,8 @@ import org.apache.maven.artifact.Artifact;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.DependencyManagement;
 import org.apache.maven.model.Exclusion;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugins.dependency.testUtils.DependencyArtifactStubFactory;
 import org.apache.maven.plugins.dependency.testUtils.stubs.DependencyProjectStub;
 import org.apache.maven.project.MavenProject;
@@ -192,60 +194,30 @@ public class TestAnalyzeDepMgt
     }
 
     public void testMojo()
-        throws IOException
+        throws IOException, MojoExecutionException, MojoFailureException
     {
         mojo.setIgnoreDirect( false );
-        try
-        {
-            // test with nothing in depMgt
-            mojo.execute();
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace();
-            fail( "Caught Unexpected Exception:" + e.getLocalizedMessage() );
-        }
+        // test with nothing in depMgt
+        mojo.execute();
 
-        try
-        {
-            DependencyProjectStub project = (DependencyProjectStub) mojo.getProject();
-            project.setDependencyManagement( depMgt );
-            // test with exclusion
-            mojo.execute();
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace();
-            fail( "Caught Unexpected Exception:" + e.getLocalizedMessage() );
-        }
+        DependencyProjectStub project = (DependencyProjectStub) mojo.getProject();
+        project.setDependencyManagement( depMgt );
+        // test with exclusion
+        mojo.execute();
 
         try
         {
-            DependencyProjectStub project = (DependencyProjectStub) mojo.getProject();
-            project.setDependencyManagement( depMgt );
             // test with exclusion
             mojo.setFailBuild( true );
             mojo.execute();
             fail( "Expected exception to fail the build." );
         }
-        catch ( Exception e )
+        catch ( MojoExecutionException e )
         {
-            System.out.println( "Caught Expected Exception:" + e.getLocalizedMessage() );
         }
 
-        try
-        {
-            DependencyProjectStub project = (DependencyProjectStub) mojo.getProject();
-            project.setDependencyManagement( depMgt );
-            // test with exclusion
-            mojo.setFailBuild( true );
-            mojo.setIgnoreDirect( true );
-            mojo.execute();
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace();
-            fail( "Caught Unexpected Exception:" + e.getLocalizedMessage() );
-        }
+        mojo.setFailBuild( true );
+        mojo.setIgnoreDirect( true );
+        mojo.execute();
     }
 }
diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java
index ee66875..9a23afd 100644
--- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java
+++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/ExcludeReactorProjectsDependencyFilterTest.java
@@ -34,6 +34,7 @@ import java.util.HashSet;
 import java.util.Set;
 
 import static java.util.Collections.singletonList;
+
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
diff --git a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java
index a0954ee..f812715 100644
--- a/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java
+++ b/src/test/java/org/apache/maven/plugins/dependency/testUtils/stubs/DependencyProjectStub.java
@@ -96,10 +96,6 @@ public class DependencyProjectStub
 
     private List<ArtifactRepository> pluginArtifactRepositories;
 
-    // private ArtifactRepository releaseArtifactRepository;
-
-    // private ArtifactRepository snapshotArtifactRepository;
-
     private List<Profile> activeProfiles;
 
     private Set<Artifact> dependencyArtifacts;
@@ -615,6 +611,7 @@ public class DependencyProjectStub
         return null;
     }
 
+    @Override
     public void setMailingLists( List<MailingList> list )
     {
 
@@ -630,6 +627,7 @@ public class DependencyProjectStub
 
     }
 
+    @Override
     public void setDevelopers( List<Developer> list )
     {
 
@@ -951,6 +949,7 @@ public class DependencyProjectStub
         return Collections.emptyList();
     }
 
+    @Override
     public Set<Artifact> createArtifacts( ArtifactFactory artifactFactory, String string, ArtifactFilter artifactFilter )
         throws InvalidDependencyVersionException
     {
diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java
index 5c202a6..5e77698 100644
--- a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java
+++ b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java
@@ -55,7 +55,6 @@ public class TestClassifierTypeTranslator
 
     Log log = new SilentLog();
 
-
     private ArtifactHandlerManager artifactHandlerManager;
 
     @Override
@@ -75,7 +74,6 @@ public class TestClassifierTypeTranslator
         DependencyArtifactStubFactory factory = new DependencyArtifactStubFactory( null, false );
         artifacts = factory.getMixedArtifacts();
 
-
         MavenSession session = newMavenSession( new MavenProjectStub() );
 
         DefaultRepositorySystemSession repoSession = (DefaultRepositorySystemSession) session.getRepositorySession();