Search in sources :

Example 66 with ClassFileImporter

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

the class JavaWildcardTypeTest method importWildcardTypeOf.

private JavaWildcardType importWildcardTypeOf(Class<?> clazz, int typeParameterIndex) {
    JavaType listType = new ClassFileImporter().importClass(clazz).getTypeParameters().get(typeParameterIndex).getUpperBounds().get(0);
    JavaType wildcardType = ((JavaParameterizedType) listType).getActualTypeArguments().get(0);
    return (JavaWildcardType) wildcardType;
}
Also used : ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter)

Example 67 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter in project jhipster-lite by jhipster.

the class AnnotationArchTest method shouldHaveIntegrationTestAnnotation.

@Test
void shouldHaveIntegrationTestAnnotation() {
    JavaClasses importedClasses = new ClassFileImporter().importPackages("tech.jhipster.lite");
    ArchRule rule = classes().that().resideInAnyPackage("tech.jhipster.lite..").and().haveSimpleNameEndingWith("IT").should().beAnnotatedWith(IntegrationTest.class).orShould().beAnnotatedWith(Nested.class);
    rule.check(importedClasses);
}
Also used : ArchRule(com.tngtech.archunit.lang.ArchRule) JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) Test(org.junit.jupiter.api.Test)

Example 68 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter in project jhipster-lite by jhipster.

the class HexagonalArchTest method primaryShouldNotInteractWithSecondary.

@Test
void primaryShouldNotInteractWithSecondary() {
    JavaClasses importedClasses = new ClassFileImporter().withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS).importPackages("tech.jhipster.lite");
    noClasses().that().resideInAnyPackage("..primary..").should().dependOnClassesThat().resideInAnyPackage("..secondary..").because("Primary should not interact with secondary").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 69 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter in project jhipster-lite by jhipster.

the class HexagonalArchTest method domainShouldNotInteractWithOutside.

@Test
void domainShouldNotInteractWithOutside() {
    JavaClasses importedClasses = new ClassFileImporter().withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS).importPackages("tech.jhipster.lite");
    noClasses().that().resideInAnyPackage("..domain..").should().dependOnClassesThat().resideInAnyPackage("..application..", "..infrastructure..", "..primary..", "..secondary..").because("Domain should not interact with application, infrastructure, primary or secondary").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 70 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter in project jhipster-registry by jhipster.

the class ArchTest method servicesAndRepositoriesShouldNotDependOnWebLayer.

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