TSK-991: Make archunit tests more readable
This commit is contained in:
parent
819b4ca699
commit
be06d36a96
|
|
@ -11,9 +11,7 @@ import com.tngtech.archunit.core.domain.JavaClasses;
|
||||||
import com.tngtech.archunit.core.importer.ClassFileImporter;
|
import com.tngtech.archunit.core.importer.ClassFileImporter;
|
||||||
import com.tngtech.archunit.core.importer.ImportOption.DoNotIncludeTests;
|
import com.tngtech.archunit.core.importer.ImportOption.DoNotIncludeTests;
|
||||||
import com.tngtech.archunit.lang.ArchRule;
|
import com.tngtech.archunit.lang.ArchRule;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
|
@ -99,7 +97,7 @@ class ArchitectureTest {
|
||||||
* https://www.archunit.org/userguide/html/000_Index.html#_cycle_checks
|
* https://www.archunit.org/userguide/html/000_Index.html#_cycle_checks
|
||||||
*/
|
*/
|
||||||
@TestFactory
|
@TestFactory
|
||||||
Collection<DynamicTest> freeOfCycles_subpackages() {
|
Stream<DynamicTest> freeOfCycles_subpackages() {
|
||||||
|
|
||||||
Stream<String> packagesToTest =
|
Stream<String> packagesToTest =
|
||||||
Stream.of(
|
Stream.of(
|
||||||
|
|
@ -116,45 +114,48 @@ class ArchitectureTest {
|
||||||
"pro.taskana.task.internal.(*)..",
|
"pro.taskana.task.internal.(*)..",
|
||||||
"pro.taskana.workbasket.api.(*)..",
|
"pro.taskana.workbasket.api.(*)..",
|
||||||
"pro.taskana.workbasket.internal.(*)..");
|
"pro.taskana.workbasket.internal.(*)..");
|
||||||
return packagesToTest
|
return packagesToTest.map(
|
||||||
.map(
|
|
||||||
p ->
|
p ->
|
||||||
dynamicTest(
|
dynamicTest(
|
||||||
p.replaceAll(Pattern.quote("pro.taskana."), "") + " is free of cycles",
|
p.replaceAll(Pattern.quote("pro.taskana."), "") + " is free of cycles",
|
||||||
() -> slices().matching(p).should().beFreeOfCycles().check(importedClasses)))
|
() -> slices().matching(p).should().beFreeOfCycles().check(importedClasses)));
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled("TBD")
|
@Disabled("TBD")
|
||||||
@Test
|
@TestFactory
|
||||||
void commonClassesShouldNotDependOnOtherDomainClasses() {
|
Stream<DynamicTest> commonClassesShouldNotDependOnOtherDomainClasses() {
|
||||||
ArchRule myRule =
|
|
||||||
|
Stream<String> packagesToTest =
|
||||||
|
Stream.of("..workbasket..", "..report..", "..history..", "..task..", "..classification..");
|
||||||
|
return packagesToTest.map(
|
||||||
|
p ->
|
||||||
|
dynamicTest(
|
||||||
|
p.replaceAll(Pattern.quote("."), "") + " should not be used by common",
|
||||||
|
() ->
|
||||||
noClasses()
|
noClasses()
|
||||||
.that()
|
.that()
|
||||||
.resideInAPackage("..common..")
|
.resideInAPackage("..common..")
|
||||||
.should()
|
.should()
|
||||||
.dependOnClassesThat()
|
.dependOnClassesThat()
|
||||||
.resideInAnyPackage(
|
.resideInAPackage(p)
|
||||||
"..classification..", "..history..", "..report..", "..task..", "..workbasket..");
|
.check(importedClasses)));
|
||||||
myRule.check(importedClasses);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestFactory
|
@TestFactory
|
||||||
Collection<DynamicTest> classesShouldNotDependOnReportDomainClasses() {
|
Stream<DynamicTest> classesShouldNotDependOnReportDomainClasses() {
|
||||||
|
|
||||||
Stream<String> packagesToTest =
|
Stream<String> packagesToTest =
|
||||||
Stream.of(
|
Stream.of(
|
||||||
"..workbasket..",
|
"..workbasket..",
|
||||||
"..history..",
|
"..history..",
|
||||||
"..task..",
|
"..task..",
|
||||||
|
// TBD
|
||||||
|
// "..common..",
|
||||||
"..classification..");
|
"..classification..");
|
||||||
return packagesToTest
|
return packagesToTest.map(
|
||||||
.map(
|
|
||||||
p ->
|
p ->
|
||||||
dynamicTest(
|
dynamicTest(
|
||||||
"Domain "
|
"Domain " + p.replaceAll(Pattern.quote("."), "") + " should not depend on reports",
|
||||||
+ p.replaceAll(Pattern.quote("."), "")
|
|
||||||
+ " should not depend on reports",
|
|
||||||
() ->
|
() ->
|
||||||
noClasses()
|
noClasses()
|
||||||
.that()
|
.that()
|
||||||
|
|
@ -162,8 +163,7 @@ class ArchitectureTest {
|
||||||
.should()
|
.should()
|
||||||
.dependOnClassesThat()
|
.dependOnClassesThat()
|
||||||
.resideInAnyPackage("..report..")
|
.resideInAnyPackage("..report..")
|
||||||
.check(importedClasses)))
|
.check(importedClasses)));
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Disabled
|
@Disabled
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue