mirror of
https://gitee.com/dcren/initializr.git
synced 2025-09-21 02:58:08 +08:00
Add doesNotHaveBom test assertion
Closes gh-1074
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -250,6 +250,20 @@ public class MavenBuildAssert extends AbstractTextAssert<MavenBuildAssert> {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assert that {@code pom.xml} does not define the specified bom.
|
||||||
|
* @param groupId the groupId of the bom
|
||||||
|
* @param artifactId the artifactId of the bom
|
||||||
|
* @return {@code this} assertion object
|
||||||
|
*/
|
||||||
|
public MavenBuildAssert doesNotHaveBom(String groupId, String artifactId) {
|
||||||
|
this.pom.nodesAtPath("/project/dependencyManagement/dependencies/dependency").noneMatch((candidate) -> {
|
||||||
|
BillOfMaterials actual = toBom(candidate);
|
||||||
|
return groupId.equals(actual.getGroupId()) && artifactId.equals(actual.getArtifactId());
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assert {@code pom.xml} defines the specified number of repositories.
|
* Assert {@code pom.xml} defines the specified number of repositories.
|
||||||
* @param size the number of repositories
|
* @param size the number of repositories
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2020 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -234,6 +234,22 @@ class MavenBuildAssertTests {
|
|||||||
() -> assertThat(forSampleMavenBuild()).hasBom("com.example.acme", "library-bom", "${wrong.version}"));
|
() -> assertThat(forSampleMavenBuild()).hasBom("com.example.acme", "library-bom", "${wrong.version}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void doesNotHaveBomArtifactId() {
|
||||||
|
assertThat(forSampleMavenBuild()).doesNotHaveBom("com.example.acme", "wrong");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void doesNotHaveBomGroupId() {
|
||||||
|
assertThat(forSampleMavenBuild()).doesNotHaveBom("com.example.wrong", "library-bom");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void doesNotHaveBomWithMatchingBom() {
|
||||||
|
assertThatExceptionOfType(AssertionError.class)
|
||||||
|
.isThrownBy(() -> assertThat(forSampleMavenBuild()).doesNotHaveBom("com.example.acme", "library-bom"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void hasRepositoriesSize() {
|
void hasRepositoriesSize() {
|
||||||
assertThat(forMavenBuild("sample-repositories-pom.xml")).hasRepositoriesSize(2);
|
assertThat(forMavenBuild("sample-repositories-pom.xml")).hasRepositoriesSize(2);
|
||||||
|
Reference in New Issue
Block a user