Add method for asserting that a pom does not have a dependency

Closes gh-842
This commit is contained in:
Andy Wilkinson
2019-02-19 11:32:09 +00:00
parent 07bf731f47
commit b91ecb61fb

View File

@@ -266,6 +266,23 @@ public class PomAssert {
return this;
}
/**
* Assert that {@code pom.xml} does not define a dependency with the specified
* {@code groupId} and {@code artifactId}.
* @param groupId the dependency's groupId
* @param artifactId the dependency's artifactId
* @return this
*/
public PomAssert doesNotHaveDependency(String groupId, String artifactId) {
assertThat(this.pom).nodesAtPath("/project/dependencies/dependency")
.noneMatch((candidate) -> {
Dependency actual = toDependency(candidate);
return groupId.equals(actual.getGroupId())
&& artifactId.equals(actual.getArtifactId());
});
return this;
}
/**
* Assert {@code pom.xml} defines the specified number of boms.
* @param count the number of boms