Search in sources :

Example 1 with JavaClasses

use of com.tngtech.archunit.core.domain.JavaClasses in project AngularPortfolioMgr by Angular2Guy.

the class MyArchitectureTests method ruleGeneralCodingRules.

@Test
public void ruleGeneralCodingRules() {
    ArchRule archRule = CompositeArchRule.of(GeneralCodingRules.NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS).and(NO_CLASSES_SHOULD_USE_FIELD_INJECTION).because("Good practice");
    JavaClasses classesToCheck = this.importedClasses.that(JavaClass.Predicates.resideOutsideOfPackages("..adapter.clients.test.."));
    archRule.check(classesToCheck);
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) CompositeArchRule(com.tngtech.archunit.lang.CompositeArchRule) JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ArchTest(com.tngtech.archunit.junit.ArchTest) Test(org.junit.jupiter.api.Test)

Example 2 with JavaClasses

use of com.tngtech.archunit.core.domain.JavaClasses in project AngularPortfolioMgr by Angular2Guy.

the class MyArchitectureTests method ruleGeneralCodingRulesLoggers.

@Test
public void ruleGeneralCodingRulesLoggers() {
    JavaClasses classesToCheck = this.importedClasses.that(JavaClass.Predicates.resideOutsideOfPackages("..domain.utils.."));
    ArchRuleDefinition.fields().that().haveRawType(Logger.class).should().bePrivate().andShould().beStatic().andShould().beFinal().because("we agreed on this convention").check(classesToCheck);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ArchTest(com.tngtech.archunit.junit.ArchTest) Test(org.junit.jupiter.api.Test)

Example 3 with JavaClasses

use of com.tngtech.archunit.core.domain.JavaClasses in project AngularAndSpring by Angular2Guy.

the class MyArchitectureTests method ruleGeneralCodingRules.

@Test
public void ruleGeneralCodingRules() {
    ArchRule archRule = CompositeArchRule.of(GeneralCodingRules.NO_CLASSES_SHOULD_ACCESS_STANDARD_STREAMS).and(NO_CLASSES_SHOULD_USE_FIELD_INJECTION).because("Good practice");
    JavaClasses classesToCheck = this.importedClasses.that(JavaClass.Predicates.resideOutsideOfPackages("..adapter.clients.test.."));
    archRule.check(classesToCheck);
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) CompositeArchRule(com.tngtech.archunit.lang.CompositeArchRule) JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ArchTest(com.tngtech.archunit.junit.ArchTest) Test(org.junit.jupiter.api.Test)

Example 4 with JavaClasses

use of com.tngtech.archunit.core.domain.JavaClasses in project corrigeExamBack by barais.

the class ArchTest method servicesAndRepositoriesShouldNotDependOnWebLayer.

@Test
void servicesAndRepositoriesShouldNotDependOnWebLayer() {
    JavaClasses importedClasses = new ClassFileImporter().withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS).importPackages("com.mycompany.myapp");
    noClasses().that().resideInAnyPackage("..service..").or().resideInAnyPackage("..repository..").should().dependOnClassesThat().resideInAnyPackage("..com.mycompany.myapp.web..").because("Services and repositories should not depend on web layer").check(importedClasses);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) Test(org.junit.jupiter.api.Test)

Example 5 with JavaClasses

use of com.tngtech.archunit.core.domain.JavaClasses in project SoftwareEngineeringProject by AlioLeuchtmannUni.

the class ArchTest method servicesAndRepositoriesShouldNotDependOnWebLayer.

@Test
void servicesAndRepositoriesShouldNotDependOnWebLayer() {
    JavaClasses importedClasses = new ClassFileImporter().withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS).importPackages("praktikumsverwaltung");
    noClasses().that().resideInAnyPackage("praktikumsverwaltung.service..").or().resideInAnyPackage("praktikumsverwaltung.repository..").should().dependOnClassesThat().resideInAnyPackage("..praktikumsverwaltung.web..").because("Services and repositories should not depend on web layer").check(importedClasses);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) Test(org.junit.jupiter.api.Test)

Aggregations

JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)248 Test (org.junit.Test)184 ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)98 JavaClass (com.tngtech.archunit.core.domain.JavaClass)72 Test (org.junit.jupiter.api.Test)54 JavaMethodCall (com.tngtech.archunit.core.domain.JavaMethodCall)19 ArchRule (com.tngtech.archunit.lang.ArchRule)19 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)19 JavaFieldAccess (com.tngtech.archunit.core.domain.JavaFieldAccess)16 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)15 JavaMethod (com.tngtech.archunit.core.domain.JavaMethod)15 MethodCallTarget (com.tngtech.archunit.core.domain.AccessTarget.MethodCallTarget)14 EvaluationResult (com.tngtech.archunit.lang.EvaluationResult)13 Workspace (com.structurizr.Workspace)12 JavaConstructorCall (com.tngtech.archunit.core.domain.JavaConstructorCall)12 Set (java.util.Set)12 Application (org.archifacts.core.model.Application)12 Component (com.structurizr.model.Component)10 Container (com.structurizr.model.Container)10 ArtifactContainer (org.archifacts.core.model.ArtifactContainer)10