Search in sources :

Example 1 with ArchTest

use of com.tngtech.archunit.junit.ArchTest in project jmolecules-integrations by xmolecules.

the class JMoleculesOnionSimpleArchitectureRulesTest method ensureOnionSimple.

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

Example 2 with ArchTest

use of com.tngtech.archunit.junit.ArchTest in project zeebe by zeebe-io.

the class ImmutableProtocolTest method shouldAnnotateImmutableProtocol.

@ArchTest
void shouldAnnotateImmutableProtocol(final JavaClasses importedClasses) {
    // given
    final ArchRule rule = ArchRuleDefinition.classes().that().areInterfaces().and().resideInAnyPackage("io.camunda.zeebe.protocol.record.value..").or(Predicates.equivalentTo(Record.class)).and(DescribedPredicate.not(getExcludedClasses())).should().beAnnotatedWith(Value.Immutable.class).andShould().beAnnotatedWith(ImmutableProtocol.class).andShould(new BuilderCondition());
    // then
    rule.check(importedClasses);
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) Record(io.camunda.zeebe.protocol.record.Record) ImmutableProtocol(io.camunda.zeebe.protocol.record.ImmutableProtocol) ArchTest(com.tngtech.archunit.junit.ArchTest)

Example 3 with ArchTest

use of com.tngtech.archunit.junit.ArchTest in project zeebe by zeebe-io.

the class ImmutableProtocolTest method shouldNotAnnotateExcludedClasses.

@ArchTest
void shouldNotAnnotateExcludedClasses(final JavaClasses importedClasses) {
    // given
    final ArchRule rule = ArchRuleDefinition.classes().that(getExcludedClasses()).should().notBeAnnotatedWith(ImmutableProtocol.class).orShould().notBeAnnotatedWith(Value.Immutable.class);
    // then
    rule.check(importedClasses);
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) Value(org.immutables.value.Value) ArchTest(com.tngtech.archunit.junit.ArchTest)

Example 4 with ArchTest

use of com.tngtech.archunit.junit.ArchTest 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 5 with ArchTest

use of com.tngtech.archunit.junit.ArchTest 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)

Aggregations

ArchTest (com.tngtech.archunit.junit.ArchTest)9 EvaluationResult (com.tngtech.archunit.lang.EvaluationResult)5 ArchRule (com.tngtech.archunit.lang.ArchRule)4 ImmutableProtocol (io.camunda.zeebe.protocol.record.ImmutableProtocol)2 Record (io.camunda.zeebe.protocol.record.Record)2 Value (org.immutables.value.Value)2 AppByAnnotation (org.jmolecules.archunit.layered.AppByAnnotation)2 DomainByAnnotation (org.jmolecules.archunit.layered.DomainByAnnotation)2 UiByAnnotation (org.jmolecules.archunit.layered.UiByAnnotation)2 AppType (org.jmolecules.archunit.layered.app.AppType)2 DomainType (org.jmolecules.archunit.layered.domain.DomainType)2 InfraType (org.jmolecules.archunit.layered.infra.InfraType)2 UiType (org.jmolecules.archunit.layered.ui.UiType)2 Collection (java.util.Collection)1 Map (java.util.Map)1 InfraByAnnotation (org.jmolecules.archunit.layered.InfraByAnnotation)1 AppServiceByAnnotation (org.jmolecules.archunit.onion.classical.AppServiceByAnnotation)1 DomainServiceByAnnotation (org.jmolecules.archunit.onion.classical.DomainServiceByAnnotation)1 InfraByAnnotation (org.jmolecules.archunit.onion.classical.InfraByAnnotation)1 AppType (org.jmolecules.archunit.onion.classical.app.AppType)1