Search in sources :

Example 1 with GivenSlices

use of com.tngtech.archunit.library.dependencies.syntax.GivenSlices in project ArchUnit by TNG.

the class GivenSlicesTest method restricting_slices_that_should_not_depend_on_each_other.

@Test
public void restricting_slices_that_should_not_depend_on_each_other() {
    archConfigurationRule.setFailOnEmptyShould(false);
    GivenSlices givenSlices = slices().matching("..testclasses.(*)..");
    JavaClasses classes = new ClassFileImporter().importPackages("com.tngtech.archunit.library.testclasses");
    EvaluationResult result = givenSlices.that(DescribedPredicate.<Slice>alwaysFalse()).and(DescribedPredicate.<Slice>alwaysTrue()).should().notDependOnEachOther().evaluate(classes);
    assertThat(result.hasViolation()).as("Result has violation").isFalse();
    result = givenSlices.that(DescribedPredicate.<Slice>alwaysTrue()).or(DescribedPredicate.<Slice>alwaysFalse()).should().notDependOnEachOther().evaluate(classes);
    assertThat(result.hasViolation()).as("Result has violation").isTrue();
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) EvaluationResult(com.tngtech.archunit.lang.EvaluationResult) GivenSlices(com.tngtech.archunit.library.dependencies.syntax.GivenSlices) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) ArchitecturesTest(com.tngtech.archunit.library.ArchitecturesTest) Test(org.junit.Test)

Aggregations

JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)1 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)1 EvaluationResult (com.tngtech.archunit.lang.EvaluationResult)1 ArchitecturesTest (com.tngtech.archunit.library.ArchitecturesTest)1 GivenSlices (com.tngtech.archunit.library.dependencies.syntax.GivenSlices)1 Test (org.junit.Test)1