Skip to content

Commit

Permalink
[SHRINKRES-79] Do not consider ordering in value equality of exclusions
Browse files Browse the repository at this point in the history
  • Loading branch information
tsabirgaliev authored and ALRubinger committed Oct 31, 2012
1 parent 6d3ccc0 commit 6198f6f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import org.jboss.shrinkwrap.resolver.api.maven.PackagingType;
Expand Down Expand Up @@ -213,16 +212,9 @@ public boolean equals(Object obj) {
return false;
}
final Set<MavenDependencyExclusion> theirExclusions = other.exclusions;
final Iterator<MavenDependencyExclusion> theirIt = other.exclusions.iterator();
final Set<MavenDependencyExclusion> ourExclusions = exclusions;
if (ourExclusions.size() != theirExclusions.size()) {
if(!exclusions.equals(theirExclusions)) {
return false;
}
for (final MavenDependencyExclusion exclusion : ourExclusions) {
if (!exclusion.equals(theirIt.next())) {
return false;
}
}
}
if (optional != other.optional) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ public void equalsByValueExclusions() {
Assert.assertEquals(dependency1, dependency2);
}

@Test
public void equalsByValueExclusionsUnordered() {
final MavenCoordinate coordinate = this.createCoordinate();
final ScopeType scope = ScopeType.RUNTIME;
final boolean optional = true;
final MavenDependencyExclusion exclusion11 = new MavenDependencyExclusionImpl("groupId1", "artifactId1");
final MavenDependencyExclusion exclusion12 = new MavenDependencyExclusionImpl("groupId2", "artifactId2");
final MavenDependencyExclusion exclusion21 = new MavenDependencyExclusionImpl("groupId1", "artifactId1");
final MavenDependencyExclusion exclusion22 = new MavenDependencyExclusionImpl("groupId2", "artifactId2");
final MavenDependency dependency1 = new MavenDependencyImpl(coordinate, scope, optional, exclusion11, exclusion12);
final MavenDependency dependency2 = new MavenDependencyImpl(coordinate, scope, optional, exclusion22, exclusion21);
Assert.assertEquals(dependency1, dependency2);
}

@Test
public void notEqualsByValueExclusions() {
final MavenCoordinate coordinate = this.createCoordinate();
Expand Down

0 comments on commit 6198f6f

Please sign in to comment.