/** @param d not null */ protected boolean match(Dependency d) { boolean r = true; /* match if not attributes given */ if (hasattribs() == false) return r; if (r && this.alias != null) r = match(this.alias, d.getAlias()); if (r && this.scope != null) { String[] scope; scope = d.getScope(); r = false; for (int i = 0; !r && i < scope.length; ++i) r = match(this.scope, scope[i]); } if (r && this.bname != null) r = match(this.bname, d.basename()); if (r && this.type != null) r = match(this.type, d.getType()); if (r && this.gid != null) r = match(this.gid, d.getGroupId()); if (r && this.path != null) r = match(this.path, d.m1path()); if (r && this.version != null) r = match(this.version, d.getVersion()); return r; }
@Test public void testDependenciesWithSameVersionHaveSameCoordinates() { // Set up final Dependency dependency1 = new Dependency(DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, DEPENDENCY_VERSION); final Dependency dependency2 = new Dependency( dependency1.getGroupId(), dependency1.getArtifactId(), dependency1.getVersion()); // Invoke final boolean same = dependency1.hasSameCoordinates(dependency2); // Check assertTrue(same); }
@Test public void testDependenciesWithSameVersionAreEqual() { // Set up final Dependency dependency1 = new Dependency(DEPENDENCY_GROUP_ID, DEPENDENCY_ARTIFACT_ID, DEPENDENCY_VERSION); final Dependency dependency2 = new Dependency( dependency1.getGroupId(), dependency1.getArtifactId(), dependency1.getVersion()); // Invoke final boolean equal = dependency1.equals(dependency2); // Check assertTrue(equal); }
@Override public String getGroupId(String artifactId) { Dependency dependency = find(artifactId); return (dependency == null ? null : dependency.getGroupId()); }