use of com.tngtech.archunit.core.domain.JavaClasses in project auth0-full-stack-java-example by oktadev.
the class ArchTest method servicesAndRepositoriesShouldNotDependOnWebLayer.
@Test
void servicesAndRepositoriesShouldNotDependOnWebLayer() {
JavaClasses importedClasses = new ClassFileImporter().withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS).importPackages("com.auth0.flickr2");
noClasses().that().resideInAnyPackage("com.auth0.flickr2.service..").or().resideInAnyPackage("com.auth0.flickr2.repository..").should().dependOnClassesThat().resideInAnyPackage("..com.auth0.flickr2.web..").because("Services and repositories should not depend on web layer").check(importedClasses);
}
use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class GivenThatIsTestedConsistentlyTest method classes_that_tests_all_relevant_methods.
@Test
public void classes_that_tests_all_relevant_methods() {
JavaClasses classes = importClassesWithContext(GivenClassesThatTest.class, ClassesThat.class);
JavaClass test = classes.get(GivenClassesThatTest.class);
for (JavaMethod method : classes.get(ClassesThat.class).getMethods()) {
assertAccessFrom(test, method);
}
}
use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ArchitecturesTest method layered_architecture_allows_individual_empty_optionalLayer.
@Test
public void layered_architecture_allows_individual_empty_optionalLayer() {
LayeredArchitecture architecture = layeredArchitecture().optionalLayer("can be absent").definedBy(absolute("should.not.be.found.."));
JavaClasses classes = new ClassFileImporter().importPackages(absolute(""));
EvaluationResult result = architecture.evaluate(classes);
assertThat(result.hasViolation()).as("result of evaluating empty optionalLayer has violation").isFalse();
assertThat(result.getFailureReport().isEmpty()).as("failure report").isTrue();
}
use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ArchitecturesTest method onion_architecture_rejects_empty_layers_by_default.
@Test
public void onion_architecture_rejects_empty_layers_by_default() {
OnionArchitecture architecture = anOnionArchitectureWithEmptyLayers();
JavaClasses classes = new ClassFileImporter().importPackages(absolute("onionarchitecture"));
EvaluationResult result = architecture.evaluate(classes);
assertFailureOnionArchitectureWithEmptyLayers(result);
}
use of com.tngtech.archunit.core.domain.JavaClasses in project ArchUnit by TNG.
the class ArchitecturesTest method layered_architecture_allows_empty_layers_if_all_layers_are_optional.
@Test
public void layered_architecture_allows_empty_layers_if_all_layers_are_optional() {
LayeredArchitecture architecture = aLayeredArchitectureWithEmptyLayers().withOptionalLayers(true);
assertThat(architecture.getDescription()).startsWith("Layered architecture consisting of (optional)");
JavaClasses classes = new ClassFileImporter().importPackages(absolute(""));
assertThatRule(architecture).checking(classes).hasNoViolation();
}
Aggregations