Dependency tests are now based on ArchUnit.
Replaced ignored tests with exclusion of packages and classes. Upgraded ArchUnit dependency to 1.0.0. Closes #1354
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.jdbc;
|
||||
|
||||
import org.assertj.core.api.SoftAssertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.auditing.config.AuditingHandlerBeanDefinitionParser;
|
||||
|
||||
@@ -43,10 +42,9 @@ public class DependencyTests {
|
||||
JavaClasses importedClasses = new ClassFileImporter() //
|
||||
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS) //
|
||||
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_JARS) // we just analyze the code of this module.
|
||||
.importPackages("org.springframework.data.jdbc")
|
||||
.that( //
|
||||
onlySpringData() //
|
||||
);
|
||||
.importPackages("org.springframework.data.jdbc").that( //
|
||||
onlySpringData() //
|
||||
);
|
||||
|
||||
ArchRule rule = SlicesRuleDefinition.slices() //
|
||||
.matching("org.springframework.data.jdbc.(**)") //
|
||||
@@ -57,17 +55,17 @@ public class DependencyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("Cycle in Spring Data Commons")
|
||||
void acrossModules() {
|
||||
|
||||
JavaClasses importedClasses = new ClassFileImporter()
|
||||
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
|
||||
JavaClasses importedClasses = new ClassFileImporter().withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
|
||||
.importPackages( //
|
||||
"org.springframework.data.jdbc", // Spring Data Relational
|
||||
"org.springframework.data.relational", // Spring Data Relational
|
||||
"org.springframework.data" // Spring Data Commons
|
||||
).that(onlySpringData()) //
|
||||
.that(ignore(AuditingHandlerBeanDefinitionParser.class));
|
||||
.that(ignore(AuditingHandlerBeanDefinitionParser.class)) //
|
||||
.that(ignorePackage("org.springframework.data.aot.hint")) // ignoring aot, since it causes cycles in commons
|
||||
.that(ignorePackage("org.springframework.data.aot")); // ignoring aot, since it causes cycles in commons
|
||||
|
||||
ArchRule rule = SlicesRuleDefinition.slices() //
|
||||
.assignedFrom(subModuleSlicing()) //
|
||||
@@ -99,7 +97,7 @@ public class DependencyTests {
|
||||
|
||||
return new DescribedPredicate<>("Spring Data Classes") {
|
||||
@Override
|
||||
public boolean apply(JavaClass input) {
|
||||
public boolean test(JavaClass input) {
|
||||
return input.getPackageName().startsWith("org.springframework.data");
|
||||
}
|
||||
};
|
||||
@@ -109,12 +107,22 @@ public class DependencyTests {
|
||||
|
||||
return new DescribedPredicate<>("ignored class " + type.getName()) {
|
||||
@Override
|
||||
public boolean apply(JavaClass input) {
|
||||
public boolean test(JavaClass input) {
|
||||
return !input.getFullName().startsWith(type.getName());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private DescribedPredicate<JavaClass> ignorePackage(String type) {
|
||||
|
||||
return new DescribedPredicate<>("ignored class " + type) {
|
||||
@Override
|
||||
public boolean test(JavaClass input) {
|
||||
return !input.getPackageName().equals(type);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private String getFirstPackagePart(String subpackage) {
|
||||
|
||||
int index = subpackage.indexOf(".");
|
||||
|
||||
Reference in New Issue
Block a user