Search in sources :

Example 66 with EvaluationResult

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

the class ViolationHandlingTest method constructor_calls_are_handled.

@Test
public void constructor_calls_are_handled() {
    EvaluationResult result = noClasses().should().accessClassesThat().haveFullyQualifiedName(Target.class.getName()).evaluate(importClasses(Origin.class, Target.class));
    ConstructorCallRecorder constructorCallRecorder = new ConstructorCallRecorder();
    result.handleViolations(constructorCallRecorder);
    assertThatAccesses(constructorCallRecorder.getAccesses()).containOnly(expectedAccess().from(Origin.class, "callConstructor").toConstructor(Target.class), expectedAccess().from(Origin.class, "callConstructor").toConstructor(Target.class, String.class));
}
Also used : EvaluationResult(com.tngtech.archunit.lang.EvaluationResult) Test(org.junit.Test)

Example 67 with EvaluationResult

use of com.tngtech.archunit.lang.EvaluationResult in project jmolecules-integrations by xmolecules.

the class JMoleculesDddRulesUnitTest method detectsViolations.

@ArchTest
void detectsViolations(JavaClasses classes) {
    EvaluationResult result = JMoleculesDddRules.all().evaluate(classes);
    assertThat(result.getFailureReport().getDetails()).satisfiesExactlyInAnyOrder(violation(SampleAggregate.class, "invalid", OtherEntity.class, OtherAggregate.class), // 
    violation(SampleAggregate.class, "invalidAggregate", OtherAggregate.class, Association.class), // 
    violation(SampleAggregate.class, "invalidAggregateInCollection", Collection.class, Association.class), // 
    violation(SampleAggregate.class, "invalidAggregateInMap", Map.class, Association.class), // 
    violation(SampleAggregate.class, "invalidAnnotatedAggregate", AnnotatedAggregate.class, Association.class), // 
    violation(SampleAggregate.class, "invalidInCollection", Collection.class, OtherAggregate.class), // 
    violation(SampleAggregate.class, "invalidInMap", Map.class, OtherAggregate.class), violation("Type.*%s.*%s.*", AnnotatedAggregate.class.getSimpleName(), Identity.class.getName()));
}
Also used : Association(org.jmolecules.ddd.types.Association) Collection(java.util.Collection) Map(java.util.Map) EvaluationResult(com.tngtech.archunit.lang.EvaluationResult) ArchTest(com.tngtech.archunit.junit.ArchTest)

Example 68 with EvaluationResult

use of com.tngtech.archunit.lang.EvaluationResult in project jmolecules-integrations by xmolecules.

the class JMoleculesLayeredRulesTest method ensureStrictLayering.

@ArchTest
void ensureStrictLayering(JavaClasses types) {
    EvaluationResult result = JMoleculesArchitectureRules.ensureLayeringStrict().evaluate(types);
    assertThat(result.getFailureReport().getDetails()).satisfiesExactlyInAnyOrder(// 
    violation(AppType.class, InfraType.class), // 
    violation(AppType.class, InfraByAnnotation.class), // 
    violation(AppType.class, UiType.class), // 
    violation(AppType.class, UiByAnnotation.class), // 
    violation(DomainType.class, AppType.class), // 
    violation(DomainType.class, AppByAnnotation.class), // 
    violation(DomainType.class, UiType.class), // 
    violation(DomainType.class, UiByAnnotation.class), // 
    violation(InfraType.class, DomainType.class), // 
    violation(InfraType.class, DomainByAnnotation.class), // 
    violation(InfraType.class, AppType.class), // 
    violation(InfraType.class, AppByAnnotation.class), // 
    violation(InfraType.class, UiType.class), // 
    violation(InfraType.class, UiByAnnotation.class), // 
    violation(UiType.class, DomainType.class), // 
    violation(UiType.class, DomainByAnnotation.class), // 
    violation(UiType.class, InfraType.class), // 
    violation(UiType.class, InfraByAnnotation.class));
}
Also used : AppByAnnotation(org.jmolecules.archunit.layered.AppByAnnotation) UiByAnnotation(org.jmolecules.archunit.layered.UiByAnnotation) DomainType(org.jmolecules.archunit.layered.domain.DomainType) UiType(org.jmolecules.archunit.layered.ui.UiType) DomainByAnnotation(org.jmolecules.archunit.layered.DomainByAnnotation) InfraByAnnotation(org.jmolecules.archunit.layered.InfraByAnnotation) AppType(org.jmolecules.archunit.layered.app.AppType) InfraType(org.jmolecules.archunit.layered.infra.InfraType) EvaluationResult(com.tngtech.archunit.lang.EvaluationResult) ArchTest(com.tngtech.archunit.junit.ArchTest)

Example 69 with EvaluationResult

use of com.tngtech.archunit.lang.EvaluationResult in project jmolecules-integrations by xmolecules.

the class JMoleculesLayeredRulesTest method ensureLayering.

@ArchTest
void ensureLayering(JavaClasses types) {
    EvaluationResult result = JMoleculesArchitectureRules.ensureLayering().evaluate(types);
    // 
    assertThat(result.getFailureReport().getDetails()).satisfiesExactlyInAnyOrder(// 
    violation(AppType.class, UiType.class), // 
    violation(AppType.class, UiByAnnotation.class), // 
    violation(DomainType.class, AppType.class), // 
    violation(DomainType.class, AppByAnnotation.class), // 
    violation(DomainType.class, UiType.class), // 
    violation(DomainType.class, UiByAnnotation.class), // 
    violation(InfraType.class, DomainType.class), // 
    violation(InfraType.class, DomainByAnnotation.class), // 
    violation(InfraType.class, AppType.class), // 
    violation(InfraType.class, AppByAnnotation.class), // 
    violation(InfraType.class, UiType.class), // 
    violation(InfraType.class, UiByAnnotation.class));
}
Also used : AppByAnnotation(org.jmolecules.archunit.layered.AppByAnnotation) UiByAnnotation(org.jmolecules.archunit.layered.UiByAnnotation) DomainType(org.jmolecules.archunit.layered.domain.DomainType) UiType(org.jmolecules.archunit.layered.ui.UiType) DomainByAnnotation(org.jmolecules.archunit.layered.DomainByAnnotation) AppType(org.jmolecules.archunit.layered.app.AppType) InfraType(org.jmolecules.archunit.layered.infra.InfraType) EvaluationResult(com.tngtech.archunit.lang.EvaluationResult) ArchTest(com.tngtech.archunit.junit.ArchTest)

Example 70 with EvaluationResult

use of com.tngtech.archunit.lang.EvaluationResult in project jmolecules-integrations by xmolecules.

the class JMoleculesOnionClassicalArchitectureRulesTest method ensureOnionClasical.

@ArchTest
void ensureOnionClasical(JavaClasses types) {
    EvaluationResult result = JMoleculesArchitectureRules.ensureOnionClassical().evaluate(types);
    // 
    assertThat(result.getFailureReport().getDetails()).satisfiesExactlyInAnyOrder(// 
    violation(AppType.class, InfraType.class), // 
    violation(AppType.class, InfraByAnnotation.class), // 
    violation(DomainServiceType.class, AppType.class), // 
    violation(DomainServiceType.class, AppServiceByAnnotation.class), // 
    violation(DomainServiceType.class, InfraType.class), // 
    violation(DomainServiceType.class, InfraByAnnotation.class), // 
    violation(DomainModelType.class, AppType.class), // 
    violation(DomainModelType.class, AppServiceByAnnotation.class), // 
    violation(DomainModelType.class, InfraType.class), // 
    violation(DomainModelType.class, InfraByAnnotation.class), // 
    violation(DomainModelType.class, DomainServiceType.class), // 
    violation(DomainModelType.class, DomainServiceByAnnotation.class));
}
Also used : DomainServiceType(org.jmolecules.archunit.onion.classical.domainservice.DomainServiceType) InfraByAnnotation(org.jmolecules.archunit.onion.classical.InfraByAnnotation) AppServiceByAnnotation(org.jmolecules.archunit.onion.classical.AppServiceByAnnotation) DomainServiceByAnnotation(org.jmolecules.archunit.onion.classical.DomainServiceByAnnotation) AppType(org.jmolecules.archunit.onion.classical.app.AppType) InfraType(org.jmolecules.archunit.onion.classical.infra.InfraType) DomainModelType(org.jmolecules.archunit.onion.classical.domainmodel.DomainModelType) EvaluationResult(com.tngtech.archunit.lang.EvaluationResult) ArchTest(com.tngtech.archunit.junit.ArchTest)

Aggregations

EvaluationResult (com.tngtech.archunit.lang.EvaluationResult)140 Test (org.junit.Test)132 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)107 CanBeAnnotatedTest (com.tngtech.archunit.core.domain.properties.CanBeAnnotatedTest)63 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)13 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)13 SomeClass (com.tngtech.archunit.lang.syntax.elements.testclasses.SomeClass)12 WrongNamedClass (com.tngtech.archunit.lang.syntax.elements.testclasses.WrongNamedClass)12 ArchCondition (com.tngtech.archunit.lang.ArchCondition)7 ArchRule (com.tngtech.archunit.lang.ArchRule)6 FailureReport (com.tngtech.archunit.lang.FailureReport)6 ClassWithVariousMembers (com.tngtech.archunit.lang.syntax.elements.GivenCodeUnitsTest.ClassWithVariousMembers)6 SimpleFieldAndMethod (com.tngtech.archunit.lang.syntax.elements.testclasses.SimpleFieldAndMethod)6 ArchTest (com.tngtech.archunit.junit.ArchTest)5 OnionArchitecture (com.tngtech.archunit.library.Architectures.OnionArchitecture)5 ArchConfiguration (com.tngtech.archunit.ArchConfiguration)4 JavaMember (com.tngtech.archunit.core.domain.JavaMember)4 ConditionEvents (com.tngtech.archunit.lang.ConditionEvents)4 ClassWithVariousMembers (com.tngtech.archunit.lang.syntax.elements.GivenMembersTest.ClassWithVariousMembers)3 Date (java.util.Date)3