Dependency { @Override public boolean equals(final Object obj){ if(obj instanceof Dependency){ return hashCode() == obj.hashCode(); } return false; } protected  Dependency(); Artifact getTarget(); Scope getScope(); String getSourceVersion(); void setSourceVersion(final String sourceVersion); String getSourceName(); void setSourceName(final String sourceName); @Override boolean equals(final Object obj); @Override int hashCode();  }
@Test public void checkIfTwoArtifactsAreEquals(){ Artifact artifact = DataModelFactory.createArtifact("com.my.company", "test", "1.0.0-SNAPSHOT", "win32", "jar", "jar"); Artifact artifact2 = DataModelFactory.createArtifact("com.my.company", "test", "1.0.0-SNAPSHOT", "win32", "jar", "jar"); Dependency dep1 = DataModelFactory.createDependency(artifact, Scope.TEST); Dependency dep2 = DataModelFactory.createDependency(artifact2, Scope.TEST); Dependency dep3 = DataModelFactory.createDependency(artifact2, Scope.COMPILE); assertTrue(dep1.equals(dep2)); assertFalse(dep1.equals(dep3)); assertFalse(dep1.equals("test")); }