Search in sources :

Example 36 with ArchRule

use of com.tngtech.archunit.lang.ArchRule in project taskana by Taskana.

the class ArchitectureTest method exceptionsThatShouldHaveToStringMethod.

@Test
void exceptionsThatShouldHaveToStringMethod() {
    ArchRule myRule = classes().that().areAssignableFrom(TaskanaRuntimeException.class).or().areAssignableFrom(TaskanaException.class).should(implementToString());
    myRule.check(importedClasses);
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) TaskanaRuntimeException(pro.taskana.common.api.exceptions.TaskanaRuntimeException) TaskanaException(pro.taskana.common.api.exceptions.TaskanaException) TaskanaIntegrationTest(testapi.TaskanaIntegrationTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 37 with ArchRule

use of com.tngtech.archunit.lang.ArchRule in project taskana by Taskana.

the class ArchitectureTest method everySubpackageShouldBeTestsForCyclicDependencies.

@Test
void everySubpackageShouldBeTestsForCyclicDependencies() {
    List<Pattern> excludePackages = Stream.of(// from TaskanaEngineConfiguration
    "pro.taskana", // all our acceptance tests
    "acceptance.*", // our test API
    "testapi.*").map(Pattern::compile).collect(Collectors.toList());
    ArchRule myRule = classes().should(beDefinedInTaskanaSubPackages(excludePackages));
    myRule.check(importedClasses);
}
Also used : Pattern(java.util.regex.Pattern) ArchRule(com.tngtech.archunit.lang.ArchRule) TaskanaIntegrationTest(testapi.TaskanaIntegrationTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 38 with ArchRule

use of com.tngtech.archunit.lang.ArchRule in project taskana by Taskana.

the class ArchitectureTest method testMethodNamesShouldMatchAccordingToOurGuidelines.

@Test
@Disabled("until we have renamed all tests")
void testMethodNamesShouldMatchAccordingToOurGuidelines() {
    ArchRule myRule = methods().that().areAnnotatedWith(Test.class).or().areAnnotatedWith(TestFactory.class).and().areNotDeclaredIn(ArchitectureTest.class).should().bePackagePrivate().andShould().haveNameMatching("^should_[A-Z][^_]+_(For|When)_[A-Z][^_]+$");
    myRule.check(importedClasses);
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) TaskanaIntegrationTest(testapi.TaskanaIntegrationTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest) Disabled(org.junit.jupiter.api.Disabled)

Example 39 with ArchRule

use of com.tngtech.archunit.lang.ArchRule in project taskana by Taskana.

the class ArchitectureTest method utilityClassesShouldNotBeInitializable.

@Test
void utilityClassesShouldNotBeInitializable() {
    ArchRule myRule = classes().that().resideInAPackage("..util..").and().areNotNestedClasses().should().haveOnlyPrivateConstructors();
    myRule.check(importedClasses);
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) TaskanaIntegrationTest(testapi.TaskanaIntegrationTest) Test(org.junit.jupiter.api.Test) DynamicTest(org.junit.jupiter.api.DynamicTest)

Example 40 with ArchRule

use of com.tngtech.archunit.lang.ArchRule in project BitBook by C-Otto.

the class ArchUnitIT method services_must_not_access_spring_data_repositories_directly.

@Test
void services_must_not_access_spring_data_repositories_directly() {
    ArchRule rule = ArchRuleDefinition.noClasses().that().areAssignableTo(Repository.class).should().dependOnClassesThat().haveSimpleNameEndingWith("Service");
    rule.check(importedClasses);
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) Repository(org.springframework.data.repository.Repository) Test(org.junit.jupiter.api.Test)

Aggregations

ArchRule (com.tngtech.archunit.lang.ArchRule)141 Test (org.junit.jupiter.api.Test)90 Test (org.junit.Test)37 ArchTest (com.tngtech.archunit.junit.ArchTest)19 CompositeArchRule (com.tngtech.archunit.lang.CompositeArchRule)19 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)18 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)13 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)12 DynamicTest (org.junit.jupiter.api.DynamicTest)12 TaskanaIntegrationTest (testapi.TaskanaIntegrationTest)12 EvaluationResult (com.tngtech.archunit.lang.EvaluationResult)6 JavaClass (com.tngtech.archunit.core.domain.JavaClass)5 Immutable (org.eclipse.sirius.components.annotations.Immutable)5 ArchConfiguration (com.tngtech.archunit.ArchConfiguration)4 JavaField (com.tngtech.archunit.core.domain.JavaField)4 CanBeAnnotatedTest (com.tngtech.archunit.core.domain.properties.CanBeAnnotatedTest)4 ArchCondition (com.tngtech.archunit.lang.ArchCondition)3 ClassViolatingCodingRules (com.tngtech.archunit.example.layers.ClassViolatingCodingRules)2 ImmutableProtocol (io.camunda.zeebe.protocol.record.ImmutableProtocol)2 Record (io.camunda.zeebe.protocol.record.Record)2