Search in sources :

Example 1 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter 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 2 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter 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)

Example 3 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter in project moduliths by moduliths.

the class ModuleDetectionStrategyUnitTest method detectsJMoleculesAnnotatedModule.

// #188
@Test
void detectsJMoleculesAnnotatedModule() {
    JavaClasses classes = // 
    new ClassFileImporter().withImportOption(// 
    new ImportOption.OnlyIncludeTests()).importPackages("jmolecules");
    JavaPackage javaPackage = JavaPackage.of(Classes.of(classes), "jmolecules");
    assertThat(ModuleDetectionStrategy.explictlyAnnotated().getModuleBasePackages(javaPackage)).containsExactly(javaPackage);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) Test(org.junit.jupiter.api.Test)

Example 4 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter in project arch-unit-build-plugin-core by societe-generale.

the class NoJavaUtilDateRuleTestTest method assertNoExceptionIsThrownFor.

private void assertNoExceptionIsThrownFor(Class clazz) {
    JavaClasses classToTest = new ClassFileImporter().importClasses(clazz);
    assertThatCode(() -> classes().should(NoJavaUtilDateRuleTest.notUseJavaUtilDate()).check(classToTest)).doesNotThrowAnyException();
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter)

Example 5 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter in project good-food by silas-riacourt.

the class ArchTest method servicesAndRepositoriesShouldNotDependOnWebLayer.

@Test
void servicesAndRepositoriesShouldNotDependOnWebLayer() {
    JavaClasses importedClasses = new ClassFileImporter().withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS).importPackages("fr.cesi.cube");
    noClasses().that().resideInAnyPackage("fr.cesi.cube.service..").or().resideInAnyPackage("fr.cesi.cube.repository..").should().dependOnClassesThat().resideInAnyPackage("..fr.cesi.cube.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

ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)136 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)98 Test (org.junit.Test)76 Test (org.junit.jupiter.api.Test)52 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)15 JavaClass (com.tngtech.archunit.core.domain.JavaClass)14 EvaluationResult (com.tngtech.archunit.lang.EvaluationResult)13 Workspace (com.structurizr.Workspace)12 ArchRule (com.tngtech.archunit.lang.ArchRule)12 Application (org.archifacts.core.model.Application)12 Component (com.structurizr.model.Component)10 Container (com.structurizr.model.Container)10 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)10 ArtifactContainer (org.archifacts.core.model.ArtifactContainer)10 JavaPackage (com.tngtech.archunit.core.domain.JavaPackage)5 LayeredArchitecture (com.tngtech.archunit.library.Architectures.LayeredArchitecture)5 OnionArchitecture (com.tngtech.archunit.library.Architectures.OnionArchitecture)5 Optional (java.util.Optional)5 Artifact (org.archifacts.core.model.Artifact)5 MiscArtifact (org.archifacts.core.model.MiscArtifact)5