Search in sources :

Example 6 with FailureReport

use of com.tngtech.archunit.lang.FailureReport in project ArchUnit by TNG.

the class ClassesShouldConjunctionTest method orShould_ORs_conditions_that.

@Test
@UseDataProvider("ORed_conditions_that")
public void orShould_ORs_conditions_that(ArchRule rule) {
    EvaluationResult result = rule.evaluate(importClasses(RightOne.class, RightTwo.class, Wrong.class, OtherWrong.class));
    FailureReport report = result.getFailureReport();
    assertThat(report.toString()).contains(String.format("no classes should access classes that have fully qualified name '%s' or should have fully qualified name '%s'", Wrong.class.getName(), Wrong.class.getName()));
    assertThat(report.getDetails()).usingElementComparator(matchesRegex()).contains(classHasFullNameRegex(Wrong.class), otherWrongCallsWrongRegex());
}
Also used : FailureReport(com.tngtech.archunit.lang.FailureReport) EvaluationResult(com.tngtech.archunit.lang.EvaluationResult) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 7 with FailureReport

use of com.tngtech.archunit.lang.FailureReport in project ArchUnit by TNG.

the class ClassesShouldConjunctionTest method orShould_ORs_conditions.

@Test
@UseDataProvider("ORed_conditions")
public void orShould_ORs_conditions(ArchRule rule) {
    EvaluationResult result = rule.evaluate(importClasses(RightOne.class, RightTwo.class, Wrong.class));
    FailureReport report = result.getFailureReport();
    assertThat(report.toString()).contains(String.format("classes should have fully qualified name '%s' or should have fully qualified name '%s'", RightOne.class.getName(), RightTwo.class.getName()));
    assertThat(report.getDetails()).containsOnly(String.format("%s and %s", doesntHaveFqnMessage(Wrong.class, RightOne.class), doesntHaveFqnMessage(Wrong.class, RightTwo.class)));
}
Also used : FailureReport(com.tngtech.archunit.lang.FailureReport) EvaluationResult(com.tngtech.archunit.lang.EvaluationResult) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

FailureReport (com.tngtech.archunit.lang.FailureReport)7 Test (org.junit.Test)7 EvaluationResult (com.tngtech.archunit.lang.EvaluationResult)6 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)6 ArchConfiguration (com.tngtech.archunit.ArchConfiguration)1 Slow (com.tngtech.archunit.Slow)1 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)1 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)1 MAX_NUMBER_OF_CYCLES_TO_DETECT_PROPERTY_NAME (com.tngtech.archunit.library.dependencies.CycleConfiguration.MAX_NUMBER_OF_CYCLES_TO_DETECT_PROPERTY_NAME)1 SliceRuleTest.getNumberOfCyclesInCompleteGraph (com.tngtech.archunit.library.dependencies.SliceRuleTest.getNumberOfCyclesInCompleteGraph)1 SlicesRuleDefinition.slices (com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices)1 CompleteNineNodesGraphRoot (com.tngtech.archunit.library.dependencies.testexamples.completedependencygraph.ninenodes.CompleteNineNodesGraphRoot)1 ArchConfigurationRule (com.tngtech.archunit.testutil.ArchConfigurationRule)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Rule (org.junit.Rule)1 Category (org.junit.experimental.categories.Category)1