use of com.tngtech.archunit.core.importer.ClassFileImporter in project SORMAS-Project by hzi-braunschweig.
the class DatabaseExportServiceTest method test_all_entities_have_export_configuration.
@Test
public void test_all_entities_have_export_configuration() {
Collection<String> exportableTables = DatabaseExportService.EXPORT_CONFIGS.values();
Set<String> missingEntities = new HashSet<>();
Set<String> exportedButNotWanted = new HashSet<>();
JavaClasses classes = new ClassFileImporter().importPackages("de.symeda.sormas.backend");
for (JavaClass clazz : classes) {
if (clazz.isAnnotatedWith(Entity.class)) {
Entity entityAnnotation = clazz.getAnnotationOfType(Entity.class);
String tableName = entityAnnotation.name();
if (StringUtils.isBlank(tableName)) {
tableName = clazz.getSimpleName().toLowerCase();
}
if (!exportableTables.contains(tableName)) {
missingEntities.add(clazz.getSimpleName());
} else if (NOT_EXPORTED_ENTITIES.contains(clazz.reflect())) {
exportedButNotWanted.add(clazz.getSimpleName());
}
}
}
// remove not exported entities from the list of missing ones
NOT_EXPORTED_ENTITIES.forEach(e -> missingEntities.remove(e.getSimpleName()));
assertThat("Missing export configuration for entities [" + String.join(", ", missingEntities) + "]", missingEntities, hasSize(0));
assertThat("Export configuration not wanted for entities [" + String.join(", ", exportedButNotWanted) + "]", exportedButNotWanted, hasSize(0));
}
use of com.tngtech.archunit.core.importer.ClassFileImporter 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.importer.ClassFileImporter 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.importer.ClassFileImporter 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.importer.ClassFileImporter 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