Spaces:
Build error
Build error
File size: 1,392 Bytes
442299c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
package com.dalab.discovery.common;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.lang.ArchRule;
import com.tngtech.archunit.lang.syntax.ArchRuleDefinition;
public class TechnicalStructureTest {
private static final String BASE_PACKAGE = "com.dalab.discovery";
@Test
@Timeout(60)
public void respectsTechnicalArchitectureLayers() {
JavaClasses importedClasses = new ClassFileImporter()
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
.withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_ARCHIVES)
.importPackages(BASE_PACKAGE);
// Basic rule - all web controllers should only depend on interfaces, not
// implementations
ArchRule controllerRule = ArchRuleDefinition.classes()
.that().haveNameMatching(".*Controller")
.should().onlyDependOnClassesThat()
.haveNameNotMatching(".*Impl");
controllerRule.check(importedClasses);
}
}
|