Quick fixes to issues reported by IDE
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java
index 0c18d91..24b2304 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java
@@ -43,7 +43,6 @@
* </p>
*
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id$
*/
public abstract class AbstractStrictPatternArtifactFilter implements ArtifactFilter
{
@@ -157,9 +156,7 @@
// support leading wildcard
else if ( pattern.startsWith( "*" ) )
{
- String suffix = pattern.substring( 1, pattern.length() );
-
- matches = token.endsWith( suffix );
+ matches = token.endsWith( pattern.substring( 1 ) );
}
// support trailing wildcard
else if ( pattern.endsWith( "*" ) )
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java
index a88e324..c9aad45 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilter.java
@@ -48,9 +48,9 @@
private final boolean actTransitively;
- private final Set<String> patternsTriggered = new HashSet<String>();
+ private final Set<String> patternsTriggered = new HashSet<>();
- private final List<String> filteredArtifactIds = new ArrayList<String>();
+ private final List<String> filteredArtifactIds = new ArrayList<>();
/**
* @param patterns The pattern to be used.
@@ -67,8 +67,8 @@
public PatternIncludesArtifactFilter( final Collection<String> patterns, final boolean actTransitively )
{
this.actTransitively = actTransitively;
- final List<String> pos = new ArrayList<String>();
- final List<String> neg = new ArrayList<String>();
+ final List<String> pos = new ArrayList<>();
+ final List<String> neg = new ArrayList<>();
if ( patterns != null && !patterns.isEmpty() )
{
for ( String pattern : patterns )
@@ -272,7 +272,7 @@
// support leading wildcard
else if ( pattern.startsWith( "*" ) )
{
- final String suffix = pattern.substring( 1, pattern.length() );
+ final String suffix = pattern.substring( 1 );
matches = token.endsWith( suffix );
}
@@ -336,7 +336,7 @@
// if there are no patterns, there is nothing to report.
if ( !positivePatterns.isEmpty() || !negativePatterns.isEmpty() )
{
- final List<String> missed = new ArrayList<String>();
+ final List<String> missed = new ArrayList<>();
missed.addAll( positivePatterns );
missed.addAll( negativePatterns );
@@ -352,7 +352,7 @@
for ( String pattern : missed )
{
- buffer.append( "\no \'" ).append( pattern ).append( "\'" );
+ buffer.append( "\no '" ).append( pattern ).append( "'" );
}
buffer.append( "\n" );
@@ -376,7 +376,7 @@
final StringBuilder buffer = new StringBuilder();
for ( String pattern : positivePatterns )
{
- buffer.append( "\no \'" ).append( pattern ).append( "\'" );
+ buffer.append( "\no '" ).append( pattern ).append( "'" );
}
return buffer.toString();
@@ -413,7 +413,7 @@
// if there are no patterns, there is nothing to report.
if ( !positivePatterns.isEmpty() || !negativePatterns.isEmpty() )
{
- final List<String> missed = new ArrayList<String>();
+ final List<String> missed = new ArrayList<>();
missed.addAll( positivePatterns );
missed.addAll( negativePatterns );
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java
index 8ea1b61..77c264c 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java
@@ -63,7 +63,7 @@
private boolean systemScopeHit = false;
- private List<String> filteredArtifactIds = new ArrayList<String>();
+ private final List<String> filteredArtifactIds = new ArrayList<>();
/**
* Constructor that is meant to be used with fine-grained manipulation to
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java
index 50d91f8..24fd5b1 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilter.java
@@ -26,7 +26,6 @@
* artifact pattern syntax.
*
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id$
* @see AbstractStrictPatternArtifactFilter
* @see PatternExcludesArtifactFilter
*/
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java
index f907d3a..0c8231e 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilter.java
@@ -26,7 +26,6 @@
* artifact pattern syntax.
*
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id$
* @see AbstractStrictPatternArtifactFilter
* @see PatternIncludesArtifactFilter
*/
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilter.java
index dbf677a..8bfa122 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilter.java
@@ -22,6 +22,7 @@
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
@@ -31,7 +32,6 @@
* This is the common base class of ClassifierFilter and TypeFilter
*
* @author <a href="richardv@mxtelecom.com">Richard van der Hoff</a>
- * @version $Id$
*/
public abstract class AbstractArtifactFeatureFilter
extends AbstractArtifactsFilter
@@ -86,7 +86,7 @@
*/
private Set<Artifact> filterIncludes( Set<Artifact> artifacts, List<String> theIncludes )
{
- Set<Artifact> result = new LinkedHashSet<Artifact>();
+ Set<Artifact> result = new LinkedHashSet<>();
for ( String include : theIncludes )
{
@@ -108,13 +108,13 @@
/**
* Processes the dependencies list and excludes the dependencies that match a filter in the list.
*
- * @param depends List of dependencies.
- * @param excludes List of types or classifiers to exclude.
+ * @param artifacts List of dependencies.
+ * @param theExcludes List of types or classifiers to exclude.
* @return a set of filtered artifacts.
*/
private Set<Artifact> filterExcludes( Set<Artifact> artifacts, List<String> theExcludes )
{
- Set<Artifact> result = new LinkedHashSet<Artifact>();
+ Set<Artifact> result = new LinkedHashSet<>();
for ( Artifact artifact : artifacts )
{
@@ -190,14 +190,13 @@
/**
* Allows Feature comparison to be customized
- *
+ *
* @param lhs String artifact's feature
* @param rhs String feature from exclude or include list
* @return boolean true if features match
*/
protected boolean compareFeatures( String lhs, String rhs )
{
- // If lhs is null, check that rhs is null. Otherwise check if strings are equal.
- return ( lhs == null ? rhs == null : lhs.equals( rhs ) );
+ return ( Objects.equals( lhs, rhs ) );
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactsFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactsFilter.java
index f7918a4..04fb0a7 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactsFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactsFilter.java
@@ -26,7 +26,6 @@
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
*/
public abstract class AbstractArtifactsFilter
implements ArtifactsFilter
@@ -39,7 +38,7 @@
public boolean isArtifactIncluded( Artifact artifact )
throws ArtifactFilterException
{
- Set<Artifact> set = new LinkedHashSet<Artifact>();
+ Set<Artifact> set = new LinkedHashSet<>();
set.add( artifact );
set = filter( set );
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactIdFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactIdFilter.java
index c8f365a..cb4c85f 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactIdFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactIdFilter.java
@@ -26,7 +26,6 @@
*
* @author clove
* @since 2.0-alpha-2
- * @version $Id$
*/
public class ArtifactIdFilter
extends AbstractArtifactFeatureFilter
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java
index d80ea25..e238f57 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactTransitivityFilter.java
@@ -37,7 +37,6 @@
* This filter will exclude everything that is not a dependency of the selected artifact.
*
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
*/
public class ArtifactTransitivityFilter
extends AbstractArtifactsFilter
@@ -98,17 +97,7 @@
transitiveArtifacts.add( mavenArtifact.getDependencyConflictId() );
}
}
- catch ( IllegalAccessException e )
- {
- // don't want to pollute method signature with ReflectionExceptions
- throw new RuntimeException( e.getMessage(), e );
- }
- catch ( InvocationTargetException e )
- {
- // don't want to pollute method signature with ReflectionExceptions
- throw new RuntimeException( e.getMessage(), e );
- }
- catch ( NoSuchMethodException e )
+ catch ( IllegalAccessException | InvocationTargetException | NoSuchMethodException e )
{
// don't want to pollute method signature with ReflectionExceptions
throw new RuntimeException( e.getMessage(), e );
@@ -132,17 +121,7 @@
transitiveArtifacts.add( mavenArtifact.getDependencyConflictId() );
}
}
- catch ( IllegalAccessException e )
- {
- // don't want to pollute method signature with ReflectionExceptions
- throw new RuntimeException( e.getMessage(), e );
- }
- catch ( InvocationTargetException e )
- {
- // don't want to pollute method signature with ReflectionExceptions
- throw new RuntimeException( e.getMessage(), e );
- }
- catch ( NoSuchMethodException e )
+ catch ( IllegalAccessException | InvocationTargetException | NoSuchMethodException e )
{
// don't want to pollute method signature with ReflectionExceptions
throw new RuntimeException( e.getMessage(), e );
@@ -179,7 +158,7 @@
public Set<Artifact> filter( Set<Artifact> artifacts )
{
- Set<Artifact> result = new LinkedHashSet<Artifact>();
+ Set<Artifact> result = new LinkedHashSet<>();
for ( Artifact artifact : artifacts )
{
if ( artifactIsATransitiveDependency( artifact ) )
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactsFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactsFilter.java
index 6fdc3c9..458f3a6 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactsFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ArtifactsFilter.java
@@ -19,17 +19,12 @@
* under the License.
*/
-/**
- *
- */
-
import java.util.Set;
import org.apache.maven.artifact.Artifact;
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
*/
public interface ArtifactsFilter
{
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ClassifierFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ClassifierFilter.java
index f9fe056..b0d5140 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ClassifierFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ClassifierFilter.java
@@ -23,8 +23,6 @@
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
- *
*/
public class ClassifierFilter
extends AbstractArtifactFeatureFilter
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/FilterArtifacts.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/FilterArtifacts.java
index a8f211f..7054d03 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/FilterArtifacts.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/FilterArtifacts.java
@@ -19,10 +19,6 @@
* under the License.
*/
-/**
- *
- */
-
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -31,7 +27,6 @@
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
*/
public class FilterArtifacts
{
@@ -42,7 +37,7 @@
*/
public FilterArtifacts()
{
- filters = new ArrayList<ArtifactsFilter>();
+ filters = new ArrayList<>();
}
/**
@@ -101,7 +96,6 @@
catch ( NullPointerException e )
{
// don't do anything, just skip this.
- continue;
}
}
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/GroupIdFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/GroupIdFilter.java
index a12ddc5..d0d2188 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/GroupIdFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/GroupIdFilter.java
@@ -26,7 +26,6 @@
*
* @author clove
* @since 2.0
- * @version $Id$
*/
public class GroupIdFilter
extends AbstractArtifactFeatureFilter
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ProjectTransitivityFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ProjectTransitivityFilter.java
index ca3a70d..7b5f6da 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ProjectTransitivityFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ProjectTransitivityFilter.java
@@ -26,7 +26,6 @@
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
*/
public class ProjectTransitivityFilter
extends AbstractArtifactsFilter
@@ -34,7 +33,7 @@
private boolean excludeTransitive;
- private Set<Artifact> directDependencies;
+ private final Set<Artifact> directDependencies;
/**
* @param directDependencies set of direct dependencies.
@@ -57,7 +56,7 @@
if ( excludeTransitive )
{
- result = new LinkedHashSet<Artifact>();
+ result = new LinkedHashSet<>();
for ( Artifact artifact : artifacts )
{
if ( artifactIsADirectDependency( artifact ) )
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ScopeFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ScopeFilter.java
index 320f069..cb43dd5 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/ScopeFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/ScopeFilter.java
@@ -29,7 +29,6 @@
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
*/
public class ScopeFilter
extends AbstractArtifactsFilter
@@ -73,7 +72,7 @@
throw new ArtifactFilterException( "Invalid Scope in includeScope: " + includeScope );
}
- results = new LinkedHashSet<Artifact>();
+ results = new LinkedHashSet<>();
if ( Artifact.SCOPE_PROVIDED.equals( includeScope ) || Artifact.SCOPE_SYSTEM.equals( includeScope ) )
{
@@ -100,7 +99,7 @@
{
throw new ArtifactFilterException( "Invalid Scope in excludeScope: " + excludeScope );
}
- results = new LinkedHashSet<Artifact>();
+ results = new LinkedHashSet<>();
// plexus ScopeArtifactFilter doesn't handle the provided scope so
// we
// need special handling for it.
@@ -131,7 +130,7 @@
private Set<Artifact> includeSingleScope( Set<Artifact> artifacts, String scope )
{
- Set<Artifact> results = new LinkedHashSet<Artifact>();
+ Set<Artifact> results = new LinkedHashSet<>();
for ( Artifact artifact : artifacts )
{
if ( scope.equals( artifact.getScope() ) )
@@ -144,7 +143,7 @@
private Set<Artifact> excludeSingleScope( Set<Artifact> artifacts, String scope )
{
- Set<Artifact> results = new LinkedHashSet<Artifact>();
+ Set<Artifact> results = new LinkedHashSet<>();
for ( Artifact artifact : artifacts )
{
if ( !scope.equals( artifact.getScope() ) )
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/collection/TypeFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/collection/TypeFilter.java
index 96d4c93..14a38bd 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/collection/TypeFilter.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/collection/TypeFilter.java
@@ -23,8 +23,7 @@
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
- * @version $Id$
- */
+s */
public class TypeFilter
extends AbstractArtifactFeatureFilter
{
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformer.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformer.java
index dc04a24..c6c2cdb 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformer.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformer.java
@@ -138,13 +138,13 @@
@Override
public ArtifactFilter transform( final ExclusionsFilter exclusionsFilter )
{
- return new ExcludesArtifactFilter( new ArrayList<String>( exclusionsFilter.getExcludes() ) );
+ return new ExcludesArtifactFilter( new ArrayList<>( exclusionsFilter.getExcludes() ) );
}
@Override
public ArtifactFilter transform( OrFilter orFilter )
{
- final Collection<ArtifactFilter> filters = new ArrayList<ArtifactFilter>( orFilter.getFilters().size() );
+ final Collection<ArtifactFilter> filters = new ArrayList<>( orFilter.getFilters().size() );
for ( TransformableFilter subFilter : orFilter.getFilters() )
{
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java
index 043a3da..7272802 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformer.java
@@ -61,7 +61,7 @@
@Override
public AndDependencyFilter transform( AndFilter andFilter )
{
- Collection<DependencyFilter> filters = new ArrayList<DependencyFilter>();
+ Collection<DependencyFilter> filters = new ArrayList<>();
for ( TransformableFilter filter : andFilter.getFilters() )
{
filters.add( filter.transform( this ) );
@@ -78,7 +78,7 @@
@Override
public OrDependencyFilter transform( OrFilter orFilter )
{
- Collection<DependencyFilter> filters = new ArrayList<DependencyFilter>();
+ Collection<DependencyFilter> filters = new ArrayList<>();
for ( TransformableFilter filter : orFilter.getFilters() )
{
filters.add( filter.transform( this ) );
@@ -131,7 +131,7 @@
private DependencyFilter newAdvancedPatternInclusionFilter( Collection<String> includes )
{
- List<DependencyFilter> filters = new ArrayList<DependencyFilter>( includes.size() );
+ List<DependencyFilter> filters = new ArrayList<>( includes.size() );
Pattern pattern = Pattern.compile( GAE_C_V );
for ( String include : includes )
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java
index a1181ba..935c27f 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java
@@ -69,7 +69,7 @@
if ( nodeDependency.getExclusions() != null )
{
List<org.apache.maven.model.Exclusion> mavenExclusions =
- new ArrayList<org.apache.maven.model.Exclusion>( nodeDependency.getExclusions().size() );
+ new ArrayList<>( nodeDependency.getExclusions().size() );
for ( Exclusion aetherExclusion : nodeDependency.getExclusions() )
{
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformer.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformer.java
index 852e472..edce5d2 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformer.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformer.java
@@ -63,7 +63,7 @@
@Override
public AndDependencyFilter transform( AndFilter filter )
{
- Collection<DependencyFilter> filters = new ArrayList<DependencyFilter>( filter.getFilters().size() );
+ Collection<DependencyFilter> filters = new ArrayList<>( filter.getFilters().size() );
for ( TransformableFilter dependencyFilter : filter.getFilters() )
{
filters.add( dependencyFilter.transform( this ) );
@@ -80,7 +80,7 @@
@Override
public OrDependencyFilter transform( OrFilter filter )
{
- Collection<DependencyFilter> filters = new ArrayList<DependencyFilter>( filter.getFilters().size() );
+ Collection<DependencyFilter> filters = new ArrayList<>( filter.getFilters().size() );
for ( TransformableFilter dependencyFilter : filter.getFilters() )
{
filters.add( dependencyFilter.transform( this ) );
@@ -133,7 +133,7 @@
private DependencyFilter newAdvancedPatternInclusionFilter( Collection<String> includes )
{
- List<DependencyFilter> filters = new ArrayList<DependencyFilter>( includes.size() );
+ List<DependencyFilter> filters = new ArrayList<>( includes.size() );
Pattern pattern = Pattern.compile( GAE_C_V );
for ( String include : includes )
diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNode.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNode.java
index fa612ef..419f6fb 100644
--- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNode.java
+++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNode.java
@@ -66,7 +66,7 @@
if ( nodeDependency.getExclusions() != null )
{
List<org.apache.maven.model.Exclusion> mavenExclusions =
- new ArrayList<org.apache.maven.model.Exclusion>( nodeDependency.getExclusions().size() );
+ new ArrayList<>( nodeDependency.getExclusions().size() );
for ( Exclusion aetherExclusion : nodeDependency.getExclusions() )
{
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/AbstractPatternArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/AbstractPatternArtifactFilterTest.java
index 4972a1b..bbd46f0 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/AbstractPatternArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/AbstractPatternArtifactFilterTest.java
@@ -40,7 +40,7 @@
protected abstract ArtifactFilter createFilter( List<String> patterns, boolean actTransitively );
- protected abstract boolean isInclusionExpected();
+ protected abstract boolean isInclusionNotExpected();
@Test
public void testShouldTriggerBothPatternsWithWildcards()
@@ -63,13 +63,13 @@
when( artifact2.getArtifactId() ).thenReturn( artifactId2 );
when( artifact2.getId() ).thenReturn( groupId2 + ":" + artifactId2 + ":jar:version" );
- final List<String> patterns = new ArrayList<String>();
+ final List<String> patterns = new ArrayList<>();
patterns.add( groupId1 + ":" + artifactId1 + ":*" );
patterns.add( groupId2 + ":" + artifactId2 + ":*" );
final ArtifactFilter filter = createFilter( patterns );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact1 ) );
assertFalse( filter.include( artifact2 ) );
@@ -102,13 +102,13 @@
when( artifact2.getArtifactId() ).thenReturn( artifactId2 );
when( artifact2.getId() ).thenReturn( groupId2 + ":" + artifactId2 + ":jar:version" );
- final List<String> patterns = new ArrayList<String>();
+ final List<String> patterns = new ArrayList<>();
patterns.add( groupId1 + "*" );
patterns.add( groupId2 + "*" );
final ArtifactFilter filter = createFilter( patterns );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact1 ) );
assertFalse( filter.include( artifact2 ) );
@@ -134,7 +134,7 @@
final ArtifactFilter filter = createFilter( Collections.singletonList( groupId + ":" + artifactId ) );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact ) );
}
@@ -158,7 +158,7 @@
final ArtifactFilter filter = createFilter( Collections.singletonList( groupId + ":" + artifactId + ":jar" ) );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact ) );
}
@@ -180,13 +180,13 @@
when( artifact.getArtifactId() ).thenReturn( artifactId );
when( artifact.getId() ).thenReturn( groupId + ":" + artifactId + ":jar:version" );
- final List<String> patterns = new ArrayList<String>();
+ final List<String> patterns = new ArrayList<>();
patterns.add( "otherGroup:" + artifactId + ":jar" );
patterns.add( "otherGroup:" + artifactId );
final ArtifactFilter filter = createFilter( patterns );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertTrue( filter.include( artifact ) );
}
@@ -208,13 +208,13 @@
when( artifact.getArtifactId() ).thenReturn( artifactId );
when( artifact.getId() ).thenReturn( groupId + ":" + artifactId + ":jar:version" );
- final List<String> patterns = new ArrayList<String>();
+ final List<String> patterns = new ArrayList<>();
patterns.add( groupId + "otherArtifact:jar" );
patterns.add( groupId + "otherArtifact" );
final ArtifactFilter filter = createFilter( patterns );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertTrue( filter.include( artifact ) );
}
@@ -236,13 +236,13 @@
when( artifact.getArtifactId() ).thenReturn( artifactId );
when( artifact.getId() ).thenReturn( groupId + ":" + artifactId + ":jar:version" );
- final List<String> patterns = new ArrayList<String>();
+ final List<String> patterns = new ArrayList<>();
patterns.add( "otherGroup:otherArtifact:jar" );
patterns.add( "otherGroup:otherArtifact" );
final ArtifactFilter filter = createFilter( patterns );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertTrue( filter.include( artifact ) );
}
@@ -261,7 +261,7 @@
final String rootDepTrailItem = "current:project:jar:1.0";
final String depTrailItem = "otherGroup:otherArtifact";
- final List<String> depTrail = Arrays.asList( new String[] { rootDepTrailItem, depTrailItem + ":jar:1.0" } );
+ final List<String> depTrail = Arrays.asList( rootDepTrailItem, depTrailItem + ":jar:1.0" );
final List<String> patterns = Collections.singletonList( depTrailItem );
Artifact artifact = mock( Artifact.class );
@@ -273,7 +273,7 @@
final ArtifactFilter filter = createFilter( patterns, true );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact ) );
}
@@ -292,7 +292,7 @@
final String rootDepTrailItem = "current:project:jar:1.0";
final String depTrailItem = "otherGroup:otherArtifact";
- final List<String> depTrail = Arrays.asList( new String[] { rootDepTrailItem, depTrailItem + ":jar:1.0" } );
+ final List<String> depTrail = Arrays.asList( rootDepTrailItem, depTrailItem + ":jar:1.0" );
final List<String> patterns = Collections.singletonList( "otherGroup*" );
Artifact artifact = mock( Artifact.class );
@@ -304,7 +304,7 @@
final ArtifactFilter filter = createFilter( patterns, true );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact ) );
}
@@ -326,12 +326,12 @@
when( artifact.getArtifactId() ).thenReturn( artifactId );
when( artifact.getId() ).thenReturn( groupId + ":" + artifactId + ":jar:version" );
- final List<String> patterns = new ArrayList<String>();
+ final List<String> patterns = new ArrayList<>();
patterns.add( "!group:artifact:jar" );
final ArtifactFilter filter = createFilter( patterns );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertTrue( filter.include( artifact ) );
}
@@ -353,12 +353,12 @@
when( artifact.getArtifactId() ).thenReturn( artifactId );
when( artifact.getId() ).thenReturn( groupId + ":" + artifactId + ":jar:version" );
- final List<String> patterns = new ArrayList<String>();
+ final List<String> patterns = new ArrayList<>();
patterns.add( "group:*:jar" );
final ArtifactFilter filter = createFilter( patterns );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact ) );
}
@@ -381,12 +381,12 @@
when( artifact.getArtifactId() ).thenReturn( artifactId );
when( artifact.getId() ).thenReturn( groupId + ":" + artifactId + ":jar:version" );
- final List<String> patterns = new ArrayList<String>();
+ final List<String> patterns = new ArrayList<>();
patterns.add( "*:artifact:*" );
final ArtifactFilter filter = createFilter( patterns );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact ) );
}
@@ -409,12 +409,12 @@
when( artifact.getArtifactId() ).thenReturn( artifactId );
when( artifact.getId() ).thenReturn( groupId + ":" + artifactId + ":jar:version" );
- final List<String> patterns = new ArrayList<String>();
+ final List<String> patterns = new ArrayList<>();
patterns.add( "group:some-*-id" );
final ArtifactFilter filter = createFilter( patterns );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact ) );
}
@@ -437,12 +437,12 @@
when( artifact.getArtifactId() ).thenReturn( artifactId );
when( artifact.getId() ).thenReturn( groupId + ":" + artifactId + ":jar:version" );
- final List<String> patterns = new ArrayList<String>();
+ final List<String> patterns = new ArrayList<>();
patterns.add( "some.group*" );
final ArtifactFilter filter = createFilter( patterns );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact ) );
}
@@ -479,7 +479,7 @@
final ArtifactFilter filter = createFilter( patterns, true );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertTrue( filter.include( artifact2 ) );
assertFalse( filter.include( artifact1 ) );
@@ -503,12 +503,12 @@
when( artifact.getArtifactId() ).thenReturn( artifactId );
when( artifact.getId() ).thenReturn( groupId + ":" + artifactId + ":jar:version" );
- final List<String> patterns = new ArrayList<String>();
+ final List<String> patterns = new ArrayList<>();
patterns.add( "com.mycompany.*:*:jar:*:*" );
final ArtifactFilter filter = createFilter( patterns );
- if ( !isInclusionExpected() )
+ if ( isInclusionNotExpected() )
{
assertFalse( filter.include( artifact ) );
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java
index ddfc099..77bf57e 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java
@@ -29,288 +29,334 @@
import org.apache.maven.artifact.versioning.VersionRange;
import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
/**
* Tests subclasses of <code>AbstractStrictPatternArtifactFilter</code>.
*
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id$
* @see AbstractStrictPatternArtifactFilter
*/
-public abstract class AbstractStrictPatternArtifactFilterTest extends TestCase
+public abstract class AbstractStrictPatternArtifactFilterTest
{
- // fields -----------------------------------------------------------------
-
protected Artifact artifact;
- // TestCase methods -------------------------------------------------------
-
- /*
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception
+ @Before
+ public void setUp()
{
artifact = createArtifact( "groupId", "artifactId", "type", "version" );
}
- // tests ------------------------------------------------------------------
-
+ @Test
public void testExactIncluded()
{
assertIncluded( "groupId:artifactId" );
}
+ @Test
public void testExactExcluded()
{
assertExcluded( "differentGroupId:differentArtifactId" );
}
+ @Test
public void testGroupIdIncluded()
{
assertIncluded( "groupId" );
}
+ @Test
public void testGroupIdExcluded()
{
assertExcluded( "differentGroupId" );
}
+ @Test
public void testGroupIdWildcardIncluded()
{
assertIncluded( "*" );
}
+ @Test
public void testGroupIdImplicitWildcardIncluded()
{
assertIncluded( "" );
}
+ @Test
public void testGroupIdStartsWithWildcardIncluded()
{
assertIncluded( "groupId*" );
}
+ @Test
public void testGroupIdStartsWithPartialWildcardIncluded()
{
assertIncluded( "group*" );
}
+ @Test
public void testGroupIdStartsWithWildcardExcluded()
{
assertExcluded( "different*" );
}
+ @Test
public void testGroupIdEndsWithWildcardIncluded()
{
assertIncluded( "*groupId" );
}
+ @Test
public void testGroupIdEndsWithPartialWildcardIncluded()
{
assertIncluded( "*Id" );
}
+ @Test
public void testGroupIdEndsWithWildcardExcluded()
{
assertExcluded( "*different" );
}
+ @Test
public void testGroupIdContainsWildcardIncluded()
{
assertIncluded( "*oup*" );
}
+ @Test
public void testGroupIdContainsWildcardExcluded()
{
assertExcluded( "*different*" );
}
+ @Test
public void testArtifactIdIncluded()
{
assertIncluded( ":artifactId" );
}
+ @Test
public void testArtifactIdExcluded()
{
assertExcluded( ":differentArtifactId" );
}
+ @Test
public void testArtifactIdWildcardIncluded()
{
assertIncluded( ":*" );
}
+ @Test
public void testArtifactIdImplicitWildcardIncluded()
{
assertIncluded( ":" );
}
+ @Test
public void testArtifactIdStartsWithWildcardIncluded()
{
assertIncluded( ":artifactId*" );
}
+ @Test
public void testArtifactIdStartsWithPartialWildcardIncluded()
{
assertIncluded( ":artifact*" );
}
+ @Test
public void testArtifactIdStartsWithWildcardExcluded()
{
assertExcluded( ":different*" );
}
+ @Test
public void testArtifactIdEndsWithWildcardIncluded()
{
assertIncluded( ":*artifactId" );
}
+ @Test
public void testArtifactIdEndsWithPartialWildcardIncluded()
{
assertIncluded( ":*Id" );
}
+ @Test
public void testArtifactIdEndsWithWildcardExcluded()
{
assertExcluded( ":*different" );
}
+ @Test
public void testArtifactIdContainsWildcardIncluded()
{
assertIncluded( ":*fact*" );
}
+ @Test
public void testArtifactIdContainsWildcardExcluded()
{
assertExcluded( ":*different*" );
}
+ @Test
public void testTypeIncluded()
{
assertIncluded( "::type" );
}
+ @Test
public void testTypeExcluded()
{
assertExcluded( "::differentType" );
}
+ @Test
public void testTypeWildcardIncluded()
{
assertIncluded( "::*" );
}
+ @Test
public void testTypeImplicitWildcardIncluded()
{
assertIncluded( "::" );
}
+ @Test
public void testTypeStartsWithWildcardIncluded()
{
assertIncluded( "::type*" );
}
+ @Test
public void testTypeStartsWithPartialWildcardIncluded()
{
assertIncluded( "::t*" );
}
+ @Test
public void testTypeStartsWithWildcardExcluded()
{
assertExcluded( "::different*" );
}
+ @Test
public void testTypeEndsWithWildcardIncluded()
{
assertIncluded( "::*type" );
}
+ @Test
public void testTypeEndsWithPartialWildcardIncluded()
{
assertIncluded( "::*e" );
}
+ @Test
public void testTypeEndsWithWildcardExcluded()
{
assertExcluded( "::*different" );
}
+ @Test
public void testTypeContainsWildcardIncluded()
{
assertIncluded( "::*yp*" );
}
+ @Test
public void testTypeContainsWildcardExcluded()
{
assertExcluded( "::*different*" );
}
+ @Test
public void testVersionIncluded()
{
assertIncluded( ":::version" );
}
+ @Test
public void testVersionExcluded()
{
assertExcluded( ":::differentVersion" );
}
+ @Test
public void testVersionWildcardIncluded()
{
assertIncluded( ":::*" );
}
+ @Test
public void testVersionImplicitWildcardIncluded()
{
assertIncluded( ":::" );
}
+ @Test
public void testVersionStartsWithWildcardIncluded()
{
assertIncluded( ":::version*" );
}
+ @Test
public void testVersionStartsWithPartialWildcardIncluded()
{
assertIncluded( ":::ver*" );
}
+ @Test
public void testVersionStartsWithWildcardExcluded()
{
assertExcluded( ":::different*" );
}
+ @Test
public void testVersionEndsWithWildcardIncluded()
{
assertIncluded( ":::*version" );
}
+ @Test
public void testVersionEndsWithPartialWildcardIncluded()
{
assertIncluded( ":::*ion" );
}
+ @Test
public void testVersionEndsWithWildcardExcluded()
{
assertExcluded( ":::*different" );
}
+ @Test
public void testVersionContainsWildcardIncluded()
{
assertIncluded( ":::*si*" );
}
+ @Test
public void testVersionContainsWildcardExcluded()
{
assertExcluded( ":::*different*" );
}
+ @Test
public void testComplex()
{
assertIncluded( "group*:*Id:*:version" );
}
+ @Test
public void testSnapshotVersion()
{
artifact = createArtifact( "groupId", "artifactId", "type", "version-12345678.123456-1" );
@@ -318,6 +364,7 @@
assertIncluded( ":::*-SNAPSHOT" );
}
+ @Test
public void testRangeVersion()
{
artifact = createArtifact( "groupId", "artifactId", "type", "1.0.1" );
@@ -329,6 +376,7 @@
assertExcluded( "groupId:artifactId:type:(,1.0],[1.2,)");
}
+ @Test
public void testWildcardsWithRangeVersion()
{
artifact = createArtifact( "groupId", "artifactId", "type", "1.0.1" );
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
index 00ad6ca..f800a4c 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/PatternExcludesArtifactFilterTest.java
@@ -40,9 +40,9 @@
}
@Override
- protected boolean isInclusionExpected()
+ protected boolean isInclusionNotExpected()
{
- return false;
+ return true;
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
index 5fcb905..0b576f8 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/PatternIncludesArtifactFilterTest.java
@@ -39,8 +39,8 @@
}
@Override
- protected boolean isInclusionExpected()
+ protected boolean isInclusionNotExpected()
{
- return true;
+ return false;
}
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java
index 3086cff..b00dae2 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java
@@ -39,7 +39,8 @@
{
ArtifactStubFactory factory = new ArtifactStubFactory();
- Artifact excluded = factory.createArtifact( "group", "artifact", VersionRange.createFromVersionSpec( "[1.2.3]" ), Artifact.SCOPE_PROVIDED, "jar", null, false );
+ Artifact excluded = factory.createArtifact( "group", "artifact",
+ VersionRange.createFromVersionSpec( "[1.2.3]" ), Artifact.SCOPE_PROVIDED, "jar", null, false );
ArtifactFilter filter = new ScopeArtifactFilter( Artifact.SCOPE_RUNTIME );
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java
index 76ca837..497ec61 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternExcludesArtifactFilterTest.java
@@ -25,14 +25,11 @@
* Tests <code>StrictPatternExcludesArtifactFilter</code>.
*
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id$
* @see StrictPatternExcludesArtifactFilter
*/
public class StrictPatternExcludesArtifactFilterTest
extends AbstractStrictPatternArtifactFilterTest
{
- // AbstractStrictPatternArtifactFilterTest methods ------------------------
-
/*
* @see org.apache.maven.shared.artifact.filter.AbstractStrictPatternArtifactFilterTest#createFilter(java.util.List)
*/
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java
index 78e57c1..242ff11 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/StrictPatternIncludesArtifactFilterTest.java
@@ -25,14 +25,11 @@
* Tests <code>StrictPatternIncludesArtifactFilter</code>.
*
* @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
- * @version $Id$
* @see StrictPatternIncludesArtifactFilter
*/
public class StrictPatternIncludesArtifactFilterTest
extends AbstractStrictPatternArtifactFilterTest
{
- // AbstractStrictPatternArtifactFilterTest methods ------------------------
-
/*
* @see org.apache.maven.shared.artifact.filter.AbstractStrictPatternArtifactFilterTest#createFilter(java.util.List)
*/
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTestCase.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTest.java
similarity index 88%
rename from src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTestCase.java
rename to src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTest.java
index 690557a..5ccca1b 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTestCase.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTest.java
@@ -18,11 +18,6 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-/**
- *
- */
-
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
@@ -31,25 +26,19 @@
import org.apache.maven.artifact.Artifact;
-import junit.framework.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
/**
* Abstract test case for subclasses of AbstractArtifactFeatureFilter
*/
-public abstract class AbstractArtifactFeatureFilterTestCase
- extends TestCase
+public abstract class AbstractArtifactFeatureFilterTest
{
- protected Set<Artifact> artifacts = new HashSet<Artifact>();
+ protected Set<Artifact> artifacts = new HashSet<>();
protected Class<?> filterClass;
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- }
-
private Object createObjectViaReflection( Class<?> clazz, Object[] conArgs )
throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException,
IllegalAccessException, InvocationTargetException
@@ -61,6 +50,7 @@
return ct.newInstance( conArgs );
}
+ @Test
public abstract void testParsing()
throws Exception;
@@ -77,12 +67,13 @@
assertEquals( 2, includes.size() );
assertEquals( 2, excludes.size() );
- assertEquals( "one", includes.get( 0 ).toString() );
- assertEquals( "two", includes.get( 1 ).toString() );
- assertEquals( "three", excludes.get( 0 ).toString() );
- assertEquals( "four", excludes.get( 1 ).toString() );
+ assertEquals( "one", includes.get( 0 ) );
+ assertEquals( "two", includes.get( 1 ) );
+ assertEquals( "three", excludes.get( 0 ) );
+ assertEquals( "four", excludes.get( 1 ) );
}
+ @Test
public abstract void testFiltering()
throws Exception;
@@ -98,6 +89,7 @@
return result;
}
+ @Test
public abstract void testFiltering2()
throws Exception;
@@ -114,6 +106,7 @@
}
+ @Test
public abstract void testFiltering3()
throws Exception;
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestArtifactFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestArtifactFilter.java
index 3944845..5c5aeaf 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestArtifactFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestArtifactFilter.java
@@ -18,48 +18,52 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-/**
- *
- */
-
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* TestCases for ArtifactFilter
*/
public class TestArtifactFilter
- extends AbstractArtifactFeatureFilterTestCase
+ extends AbstractArtifactFeatureFilterTest
{
- protected void setUp()
+ @Before
+ public void setUp()
throws Exception
{
- super.setUp();
filterClass = ArtifactIdFilter.class;
ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
artifacts = factory.getArtifactArtifacts();
}
+
+ @Test
public void testParsing()
throws Exception
{
parsing();
}
+ @Test
public void testFiltering()
throws Exception
{
Set<Artifact> result = filtering();
for ( Artifact artifact : result )
{
- assertTrue( artifact.getArtifactId().equals( "two" ) );
+ assertEquals( "two", artifact.getArtifactId() );
}
}
+ @Test
public void testFiltering2()
throws Exception
{
@@ -70,6 +74,7 @@
}
}
+ @Test
public void testFiltering3()
throws Exception
{
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestClassifierFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestClassifierFilter.java
index ffd08b9..8d176b9 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestClassifierFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestClassifierFilter.java
@@ -18,33 +18,33 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-/**
- *
- */
-
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
/**
* Test case for ClassifierFilter
*/
public class TestClassifierFilter
- extends AbstractArtifactFeatureFilterTestCase
+ extends AbstractArtifactFeatureFilterTest
{
- protected void setUp()
+ @Before
+ public void setUp()
throws Exception
{
- super.setUp();
filterClass = ClassifierFilter.class;
ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
artifacts = factory.getClassifiedArtifacts();
}
+ @Test
public void testParsing()
throws Exception
{
@@ -52,6 +52,7 @@
}
+ @Test
public void testFiltering()
throws Exception
{
@@ -62,6 +63,7 @@
}
}
+ @Test
public void testFiltering2()
throws Exception
{
@@ -72,6 +74,7 @@
}
}
+ @Test
public void testFiltering3()
throws Exception
{
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestFilterArtifacts.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestFilterArtifacts.java
index 8a66b35..ede9860 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestFilterArtifacts.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestFilterArtifacts.java
@@ -18,35 +18,26 @@
* specific language governing permissions and limitations
* under the License.
*/
-/**
- *
- */
-
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
-import junit.framework.TestCase;
-
+import org.apache.commons.io.FileUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
-import org.apache.maven.shared.utils.io.FileUtils;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
public class TestFilterArtifacts
- extends TestCase
{
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
- }
-
+ @Test
public void testNullFilters()
throws IOException, ArtifactFilterException
@@ -70,7 +61,7 @@
fa.filter( artifacts );
assertEquals( 0, fa.getFilters().size() );
- ArrayList<ArtifactsFilter> filters = new ArrayList<ArtifactsFilter>();
+ ArrayList<ArtifactsFilter> filters = new ArrayList<>();
filters.add( null );
filters.add( null );
fa.setFilters( filters );
@@ -80,9 +71,10 @@
fa.filter( artifacts );
}
+ @Test
public void testArtifactFilter()
{
- Set<Artifact> a = new HashSet<Artifact>();
+ Set<Artifact> a = new HashSet<>();
FilterArtifacts fa = new FilterArtifacts();
ArtifactsFilter scope = new ScopeFilter( "compile", "system" );
ArtifactsFilter type = new TypeFilter( "jar", "war" );
@@ -101,8 +93,7 @@
assertTrue( fa.getFilters().get( 1 ) instanceof ProjectTransitivityFilter );
assertTrue( fa.getFilters().get( 2 ) instanceof TypeFilter );
- ArrayList<ArtifactsFilter> list = new ArrayList<ArtifactsFilter>();
- list.addAll( fa.getFilters() );
+ ArrayList<ArtifactsFilter> list = new ArrayList<>( fa.getFilters() );
fa.clearFilters();
assertEquals( 0, fa.getFilters().size() );
@@ -115,6 +106,7 @@
}
+ @Test
public void testArtifactFilterWithClassifier() throws IOException, ArtifactFilterException
{
File outputFolder = new File( "target/filters/" );
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestGroupIdFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestGroupIdFilter.java
index df1035c..167c12c 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestGroupIdFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestGroupIdFilter.java
@@ -18,39 +18,40 @@
* specific language governing permissions and limitations
* under the License.
*/
-
-/**
- *
- */
-
-import java.lang.reflect.InvocationTargetException;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* TestCases for GroupIdFilter
*/
public class TestGroupIdFilter
- extends AbstractArtifactFeatureFilterTestCase
+ extends AbstractArtifactFeatureFilterTest
{
- protected void setUp()
+ @Before
+ public void setUp()
throws Exception
{
- super.setUp();
filterClass = GroupIdFilter.class;
ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
artifacts = factory.getGroupIdArtifacts();
}
+ @Test
public void testParsing()
throws Exception
{
parsing();
}
+ @Test
public void testFiltering()
throws Exception
{
@@ -61,6 +62,7 @@
}
}
+ @Test
public void testFiltering2()
throws Exception
{
@@ -71,12 +73,14 @@
}
}
+ @Test
public void testFiltering3()
throws Exception
{
filtering3();
}
+ @Test
public void testFiltering4()
throws Exception
{
@@ -87,7 +91,7 @@
result = filter.filter( result );
for ( Artifact artifact : result )
{
- assertTrue( artifact.getGroupId().equals( "one" ) );
+ assertEquals( "one", artifact.getGroupId() );
}
@@ -98,14 +102,14 @@
result = filter.filter( result );
for ( Artifact artifact : result )
{
- assertTrue( artifact.getGroupId().equals( "two" ) );
+ assertEquals( "two", artifact.getGroupId() );
}
}
+ @Test
public void testMultipleInclude()
- throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException,
- IllegalAccessException, InvocationTargetException, ArtifactFilterException
+ throws SecurityException, IllegalArgumentException, ArtifactFilterException
{
ArtifactsFilter filter = new GroupIdFilter( "one,two", null );
@@ -116,9 +120,9 @@
assertEquals( 2, result.size() );
}
+ @Test
public void testMultipleExclude()
- throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException,
- IllegalAccessException, InvocationTargetException, ArtifactFilterException
+ throws SecurityException, IllegalArgumentException, ArtifactFilterException
{
ArtifactsFilter filter = new GroupIdFilter( null, "one,two" );
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestProjectTransitivityFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestProjectTransitivityFilter.java
index e8868a3..ea796c0 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestProjectTransitivityFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestProjectTransitivityFilter.java
@@ -18,22 +18,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-/**
- *
- */
-
import java.util.Set;
-import junit.framework.TestCase;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
public class TestProjectTransitivityFilter
- extends TestCase
{
Set<Artifact> artifacts;
@@ -41,11 +38,9 @@
Set<Artifact> classifiedArtifacts;
- protected void setUp()
- throws Exception
+ @Before
+ public void setUp() throws Exception
{
- super.setUp();
-
ArtifactStubFactory fact = new ArtifactStubFactory( null, false );
artifacts = fact.getScopedArtifacts();
directArtifacts = fact.getReleaseAndSnapshotArtifacts();
@@ -54,15 +49,15 @@
artifacts.addAll( classifiedArtifacts );
}
+ @Test
public void testAll()
{
ProjectTransitivityFilter filter = new ProjectTransitivityFilter( directArtifacts, false );
-
Set<Artifact> result = filter.filter( artifacts );
-
assertEquals( 11, result.size() );
}
+ @Test
public void testExclude()
{
ProjectTransitivityFilter filter = new ProjectTransitivityFilter( directArtifacts, false );
@@ -75,16 +70,16 @@
for ( Artifact artifact : result )
{
- assertTrue( artifact.getArtifactId().equals( "release" ) || artifact.getArtifactId().equals( "snapshot" ) );
+ assertTrue(
+ artifact.getArtifactId().equals( "release" ) || artifact.getArtifactId().equals( "snapshot" ) );
}
}
+ @Test
public void testClassified()
{
ProjectTransitivityFilter filter = new ProjectTransitivityFilter( classifiedArtifacts, true );
-
Set<Artifact> result = filter.filter( artifacts );
-
assertEquals( 4, result.size() );
}
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestScopeFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestScopeFilter.java
index fe44381..2a8a243 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestScopeFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestScopeFilter.java
@@ -18,38 +18,36 @@
* specific language governing permissions and limitations
* under the License.
*/
-/**
- *
- */
-
import java.util.Set;
-import junit.framework.TestCase;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
import org.apache.maven.plugin.testing.SilentLog;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
public class TestScopeFilter
- extends TestCase
{
Set<Artifact> artifacts;
Log log = new SilentLog();
- protected void setUp()
+ @Before
+ public void setUp()
throws Exception
{
- super.setUp();
-
ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
artifacts = factory.getScopedArtifacts();
}
+ @Test
public void testScopeCompile()
throws ArtifactFilterException
{
@@ -59,15 +57,16 @@
}
+ @Test
public void testScopeRuntime()
throws ArtifactFilterException
{
ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_RUNTIME, null );
Set<Artifact> result = filter.filter( artifacts );
assertEquals( 2, result.size() );
-
}
+ @Test
public void testScopeTest()
throws ArtifactFilterException
{
@@ -76,10 +75,10 @@
assertEquals( 5, result.size() );
}
+ @Test
public void testScopeProvided()
throws ArtifactFilterException
{
-
ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_PROVIDED, null );
Set<Artifact> result = filter.filter( artifacts );
assertTrue( result.size() > 0 );
@@ -89,10 +88,10 @@
}
}
+ @Test
public void testScopeSystem()
throws ArtifactFilterException
{
-
ScopeFilter filter = new ScopeFilter( Artifact.SCOPE_SYSTEM, null );
Set<Artifact> result = filter.filter( artifacts );
assertTrue( result.size() > 0 );
@@ -102,6 +101,7 @@
}
}
+ @Test
public void testScopeFilterNull()
throws ArtifactFilterException
{
@@ -110,6 +110,7 @@
assertEquals( 5, result.size() );
}
+ @Test
public void testScopeFilterEmpty()
throws ArtifactFilterException
{
@@ -118,6 +119,7 @@
assertEquals( 5, result.size() );
}
+ @Test
public void testExcludeProvided()
throws ArtifactFilterException
{
@@ -125,14 +127,13 @@
Set<Artifact> result = filter.filter( artifacts );
assertNotNull( result );
assertTrue( result.size() > 0 );
- assertNotNull( result );
- assertTrue( result.size() > 0 );
for ( Artifact artifact : result )
{
assertFalse( Artifact.SCOPE_PROVIDED.equalsIgnoreCase( artifact.getScope() ) );
}
}
+ @Test
public void testExcludeSystem()
throws ArtifactFilterException
{
@@ -146,6 +147,7 @@
}
}
+ @Test
public void testExcludeCompile()
throws ArtifactFilterException
{
@@ -154,29 +156,30 @@
assertEquals( 2, result.size() );
}
+ @Test
public void testExcludeTest()
{
try
{
ScopeFilter filter = new ScopeFilter( "", Artifact.SCOPE_TEST );
filter.filter( artifacts );
- fail( "Expected an Exception" );
+ Assert.fail( "Expected an Exception" );
}
- catch ( ArtifactFilterException e )
+ catch ( ArtifactFilterException ignored )
{
-
}
}
+ @Test
public void testBadScope()
{
ScopeFilter filter = new ScopeFilter( "cOmpile", "" );
try
{
filter.filter( artifacts );
- fail( "Expected an Exception" );
+ Assert.fail( "Expected an Exception" );
}
- catch ( ArtifactFilterException e )
+ catch ( ArtifactFilterException ignored )
{
}
@@ -184,14 +187,15 @@
{
filter = new ScopeFilter( "", "coMpile" );
filter.filter( artifacts );
- fail( "Expected an Exception" );
+ Assert.fail( "Expected an Exception" );
}
- catch ( ArtifactFilterException e )
+ catch ( ArtifactFilterException ignored )
{
}
}
+ @Test
public void testSettersGetters()
{
ScopeFilter filter = new ScopeFilter( "include", "exclude" );
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestTypeFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestTypeFilter.java
index db9a775..f245a4b 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestTypeFilter.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestTypeFilter.java
@@ -18,35 +18,33 @@
* specific language governing permissions and limitations
* under the License.
*/
-/**
- *
- */
-
import java.util.List;
import java.util.Set;
-import junit.framework.TestCase;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.testing.ArtifactStubFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
public class TestTypeFilter
- extends TestCase
{
Set<Artifact> artifacts;
- protected void setUp()
+ @Before
+ public void setUp()
throws Exception
{
- super.setUp();
-
ArtifactStubFactory factory = new ArtifactStubFactory( null, false );
artifacts = factory.getTypedArtifacts();
}
+ @Test
public void testTypeParsing()
{
TypeFilter filter = new TypeFilter( "war,jar", "sources,zip," );
@@ -55,12 +53,13 @@
assertEquals( 2, includes.size() );
assertEquals( 2, excludes.size() );
- assertEquals( "war", includes.get( 0 ).toString() );
- assertEquals( "jar", includes.get( 1 ).toString() );
- assertEquals( "sources", excludes.get( 0 ).toString() );
- assertEquals( "zip", excludes.get( 1 ).toString() );
+ assertEquals( "war", includes.get( 0 ) );
+ assertEquals( "jar", includes.get( 1 ) );
+ assertEquals( "sources", excludes.get( 0 ) );
+ assertEquals( "zip", excludes.get( 1 ) );
}
+ @Test
public void testFiltering()
{
TypeFilter filter = new TypeFilter( "war,jar", "war,zip," );
@@ -69,10 +68,11 @@
for ( Artifact artifact : result )
{
- assertTrue( artifact.getType().equals( "jar" ) );
+ assertEquals( "jar", artifact.getType() );
}
}
+ @Test
public void testFiltering2()
{
TypeFilter filter = new TypeFilter( null, "war,jar," );
@@ -85,6 +85,7 @@
}
}
+ @Test
public void testFiltering3()
{
TypeFilter filter = new TypeFilter( null, null );
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformerTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformerTest.java
index 99074de..4225088 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformerTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformerTest.java
@@ -50,7 +50,7 @@
private ArtifactIncludeFilterTransformer transformer;
- private ArtifactStubFactory artifactFactory = new ArtifactStubFactory();
+ private final ArtifactStubFactory artifactFactory = new ArtifactStubFactory();
@Before
public void setUp()
@@ -64,7 +64,7 @@
{
AndFilter filter =
new AndFilter(
- Arrays.<TransformableFilter>asList( ScopeFilter.including( "compile" ),
+ Arrays.asList( ScopeFilter.including( "compile" ),
new ExclusionsFilter( Collections.singletonList( "x:a" ) ) ) );
AndArtifactFilter dependencyFilter = (AndArtifactFilter) filter.transform( transformer );
@@ -84,7 +84,7 @@
{
ExclusionsFilter filter = new ExclusionsFilter( Collections.singletonList( "x:a" ) );
- ArtifactFilter dependencyFilter = (ArtifactFilter) filter.transform( transformer );
+ ArtifactFilter dependencyFilter = filter.transform( transformer );
assertTrue( dependencyFilter.include( newArtifact( "g:a:v", "compile" ) ) );
@@ -99,7 +99,7 @@
new OrFilter( Arrays.<TransformableFilter>asList( ScopeFilter.including( "compile" ),
ScopeFilter.including( "test" ) ) );
- ArtifactFilter dependencyFilter = (ArtifactFilter) filter.transform( transformer );
+ ArtifactFilter dependencyFilter = filter.transform( transformer );
assertTrue( dependencyFilter.include( newArtifact( "g:a:v", "compile" ) ) );
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeNodeTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeNodeTest.java
index 72f0031..0bfcdac 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeNodeTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeNodeTest.java
@@ -19,8 +19,6 @@
* under the License.
*/
-import static org.junit.Assert.assertEquals;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.model.Dependency;
@@ -28,9 +26,11 @@
import org.apache.maven.shared.artifact.filter.resolve.Node;
import org.junit.Test;
+import static org.junit.Assert.*;
+
public class ArtifactIncludeNodeTest
{
- private ArtifactStubFactory artifactFactory = new ArtifactStubFactory();
+ private final ArtifactStubFactory artifactFactory = new ArtifactStubFactory();
@Test
public void testGAV() throws Exception
@@ -72,7 +72,7 @@
assertEquals( "g", dependency.getGroupId() );
assertEquals( "a", dependency.getArtifactId() );
assertEquals( "v", dependency.getVersion() );
- assertEquals( null, dependency.getClassifier() );
+ assertNull( dependency.getClassifier() );
assertEquals( "pom", dependency.getType() );
}
@@ -97,15 +97,15 @@
Node node = new ArtifactIncludeNode( newArtifact( "g:a:pom:v", null, null ) );
assertEquals( "false", node.getDependency().getOptional() );
- assertEquals( false, node.getDependency().isOptional() );
+ assertFalse( node.getDependency().isOptional() );
node = new ArtifactIncludeNode( newArtifact( "g:a:pom:v", null, true ) );
assertEquals( "true", node.getDependency().getOptional() );
- assertEquals( true, node.getDependency().isOptional() );
+ assertTrue( node.getDependency().isOptional() );
node = new ArtifactIncludeNode( newArtifact( "g:a:pom:v", null, false ) );
assertEquals( "false", node.getDependency().getOptional() );
- assertEquals( false, node.getDependency().isOptional() );
+ assertFalse( node.getDependency().isOptional() );
}
private Artifact newArtifact( String coor, String scope )
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformerTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformerTest.java
index b125b80..0955c71 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformerTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformerTest.java
@@ -51,13 +51,13 @@
public class EclipseAetherFilterTransformerTest
{
- private EclipseAetherFilterTransformer transformer = new EclipseAetherFilterTransformer();
+ private final EclipseAetherFilterTransformer transformer = new EclipseAetherFilterTransformer();
@Test
public void testTransformAndFilter()
{
AndFilter filter = new AndFilter(
- Arrays.<TransformableFilter>asList( ScopeFilter.including( "compile" ),
+ Arrays.asList( ScopeFilter.including( "compile" ),
new ExclusionsFilter( Collections.singletonList( "x:a" ) ) ) );
AndDependencyFilter dependencyFilter = (AndDependencyFilter) filter.transform( transformer );
@@ -156,7 +156,7 @@
}
@Test
- public void testTransformAbstractFilter() throws Exception
+ public void testTransformAbstractFilter()
{
AbstractFilter snapshotFilter = new AbstractFilter()
{
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNodeTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNodeTest.java
index a2e9c3a..bcd7db2 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNodeTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNodeTest.java
@@ -19,8 +19,6 @@
* under the License.
*/
-import static org.junit.Assert.assertEquals;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -33,6 +31,8 @@
import org.eclipse.aether.graph.Exclusion;
import org.junit.Test;
+import static org.junit.Assert.*;
+
public class EclipseAetherNodeTest
{
@Test
@@ -46,7 +46,7 @@
assertEquals( "a", mavenDependency.getArtifactId() );
assertEquals( "v", mavenDependency.getVersion() );
assertEquals( "", mavenDependency.getClassifier() );
- assertEquals( null, mavenDependency.getType() );
+ assertNull( mavenDependency.getType() );
assertEquals( "", mavenDependency.getScope() );
}
@@ -61,7 +61,7 @@
assertEquals( "a", mavenDependency.getArtifactId() );
assertEquals( "v", mavenDependency.getVersion() );
assertEquals( "c", mavenDependency.getClassifier() );
- assertEquals( null, mavenDependency.getType() );
+ assertNull( mavenDependency.getType() );
assertEquals( "", mavenDependency.getScope() );
}
@@ -76,7 +76,7 @@
assertEquals( "a", mavenDependency.getArtifactId() );
assertEquals( "v", mavenDependency.getVersion() );
assertEquals( "", mavenDependency.getClassifier() );
- assertEquals( null, mavenDependency.getType() );
+ assertNull( mavenDependency.getType() );
assertEquals( "s", mavenDependency.getScope() );
}
@@ -84,17 +84,17 @@
public void testOptional()
{
Node node = new EclipseAetherNode( newDependencyNode( "g:a:v", null, (Boolean) null ) );
-
- assertEquals( null, node.getDependency().getOptional() );
- assertEquals( false, node.getDependency().isOptional() );
+
+ assertNull( node.getDependency().getOptional() );
+ assertFalse( node.getDependency().isOptional() );
node = new EclipseAetherNode( newDependencyNode( "g:a:v", null, true ) );
assertEquals( "true", node.getDependency().getOptional() );
- assertEquals( true, node.getDependency().isOptional() );
+ assertTrue( node.getDependency().isOptional() );
node = new EclipseAetherNode( newDependencyNode( "g:a:v", null, false ) );
assertEquals( "false", node.getDependency().getOptional() );
- assertEquals( false, node.getDependency().isOptional() );
+ assertFalse( node.getDependency().isOptional() );
}
@Test
@@ -122,7 +122,7 @@
{
Dependency dependency = new Dependency( new DefaultArtifact( coor ), scope );
- Collection<Exclusion> aetherExclusions = new ArrayList<Exclusion>( exclusions.size() );
+ Collection<Exclusion> aetherExclusions = new ArrayList<>( exclusions.size() );
for ( String exclusion : exclusions )
{
String[] ga = exclusion.split( ":" );
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformerTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformerTest.java
index d759bc0..fe4cd19 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformerTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherFilterTransformerTest.java
@@ -52,13 +52,13 @@
public class SonatypeAetherFilterTransformerTest
{
- private SonatypeAetherFilterTransformer transformer = new SonatypeAetherFilterTransformer();
+ private final SonatypeAetherFilterTransformer transformer = new SonatypeAetherFilterTransformer();
@Test
public void testTransformAndFilter()
{
AndFilter filter = new AndFilter(
- Arrays.<TransformableFilter>asList( ScopeFilter.including( "compile" ),
+ Arrays.asList( ScopeFilter.including( "compile" ),
new ExclusionsFilter( Collections.singletonList( "x:a" ) ) ) );
AndDependencyFilter dependencyFilter = (AndDependencyFilter) filter.transform( transformer );
@@ -158,7 +158,7 @@
}
@Test
- public void testTransformAbstractFilter() throws Exception
+ public void testTransformAbstractFilter()
{
AbstractFilter snapshotFilter = new AbstractFilter()
{
diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNodeTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNodeTest.java
index 0097dda..826e394 100644
--- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNodeTest.java
+++ b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/SonatypeAetherNodeTest.java
@@ -19,8 +19,6 @@
* under the License.
*/
-import static org.junit.Assert.assertEquals;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -33,6 +31,8 @@
import org.sonatype.aether.util.artifact.DefaultArtifact;
import org.sonatype.aether.util.graph.DefaultDependencyNode;
+import static org.junit.Assert.*;
+
public class SonatypeAetherNodeTest
{
@Test
@@ -46,7 +46,7 @@
assertEquals( "a", mavenDependency.getArtifactId() );
assertEquals( "v", mavenDependency.getVersion() );
assertEquals( "", mavenDependency.getClassifier() );
- assertEquals( null, mavenDependency.getType() );
+ assertNull( mavenDependency.getType() );
assertEquals( "", mavenDependency.getScope() );
}
@@ -61,7 +61,7 @@
assertEquals( "a", mavenDependency.getArtifactId() );
assertEquals( "v", mavenDependency.getVersion() );
assertEquals( "c", mavenDependency.getClassifier() );
- assertEquals( null, mavenDependency.getType() );
+ assertNull( mavenDependency.getType() );
assertEquals( "", mavenDependency.getScope() );
}
@@ -76,7 +76,7 @@
assertEquals( "a", mavenDependency.getArtifactId() );
assertEquals( "v", mavenDependency.getVersion() );
assertEquals( "", mavenDependency.getClassifier() );
- assertEquals( null, mavenDependency.getType() );
+ assertNull( mavenDependency.getType() );
assertEquals( "s", mavenDependency.getScope() );
}
@@ -86,15 +86,15 @@
Node node = new SonatypeAetherNode( newDependencyNode( "g:a:v", null ) );
assertEquals( "false", node.getDependency().getOptional() );
- assertEquals( false, node.getDependency().isOptional() );
+ assertFalse( node.getDependency().isOptional() );
node = new SonatypeAetherNode( newDependencyNode( "g:a:v", null, true ) );
assertEquals( "true", node.getDependency().getOptional() );
- assertEquals( true, node.getDependency().isOptional() );
+ assertTrue( node.getDependency().isOptional() );
node = new SonatypeAetherNode( newDependencyNode( "g:a:v", null, false ) );
assertEquals( "false", node.getDependency().getOptional() );
- assertEquals( false, node.getDependency().isOptional() );
+ assertFalse( node.getDependency().isOptional() );
}
@Test
@@ -122,7 +122,7 @@
{
Dependency dependency = new Dependency( new DefaultArtifact( coor ), scope );
- Collection<Exclusion> aetherExclusions = new ArrayList<Exclusion>( exclusions.size() );
+ Collection<Exclusion> aetherExclusions = new ArrayList<>( exclusions.size() );
for ( String exclusion : exclusions )
{
String[] ga = exclusion.split( ":" );