use of com.tngtech.archunit.core.domain.JavaClasses 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);
}
use of com.tngtech.archunit.core.domain.JavaClasses in project checkstyle by checkstyle.
the class ArchUnitTest method nonProtectedCheckMethodsTest.
/**
* The goal is to ensure all classes of a specific name pattern have non-protected methods,
* except for those which are annotated with {@code Override}. In the bytecode there is no
* trace anymore if this method was annotated with {@code Override} or not (limitation of
* Archunit), eventually we need to make checkstyle's Check on this.
* Test contains assertions in the callstack, but TeamCity inspection does not see them.
*
* @noinspection JUnitTestMethodWithNoAssertions
*/
@Test
public void nonProtectedCheckMethodsTest() {
// This list contains methods which have been overridden and are set to ignore in this test.
final String[] methodsWithOverrideAnnotation = { "processFiltered", "getMethodName", "mustCheckName", "postProcessHeaderLines", "getLogMessageId" };
final String ignoreMethodList = String.join("|", methodsWithOverrideAnnotation);
final JavaClasses importedClasses = new ClassFileImporter().withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS).importPackages("com.puppycrawl.tools.checkstyle.checks");
final ArchRule checkMethodsShouldNotBeProtectedRule = methods().that().haveNameNotMatching(".*(" + ignoreMethodList + ")").and().areDeclaredInClassesThat().haveSimpleNameEndingWith("Check").and().areDeclaredInClassesThat().doNotHaveModifier(JavaModifier.ABSTRACT).should().notBeProtected();
checkMethodsShouldNotBeProtectedRule.check(importedClasses);
}
use of com.tngtech.archunit.core.domain.JavaClasses in project hazelcast by hazelcast.
the class KinesisSerializableTest method serializable_classes_should_have_valid_serialVersionUID.
@Test
public void serializable_classes_should_have_valid_serialVersionUID() {
String basePackage = KinesisSinks.class.getPackage().getName();
JavaClasses classes = new ClassFileImporter().withImportOption(onlyCurrentModule()).importPackages(basePackage);
ArchUnitRules.SERIALIZABLE_SHOULD_HAVE_VALID_SERIAL_VERSION_UID.check(classes);
}
use of com.tngtech.archunit.core.domain.JavaClasses in project hazelcast by hazelcast.
the class HadoopSerializableTest method serializable_classes_should_have_valid_serialVersionUID.
@Test
public void serializable_classes_should_have_valid_serialVersionUID() {
String basePackage = HadoopSources.class.getPackage().getName();
JavaClasses classes = new ClassFileImporter().withImportOption(onlyCurrentModule()).importPackages(basePackage);
ArchUnitRules.SERIALIZABLE_SHOULD_HAVE_VALID_SERIAL_VERSION_UID.check(classes);
}
use of com.tngtech.archunit.core.domain.JavaClasses in project hazelcast by hazelcast.
the class CdcMysqlSerializableTest method serializable_classes_should_have_valid_serialVersionUID.
@Test
public void serializable_classes_should_have_valid_serialVersionUID() {
String basePackage = MySqlCdcSources.class.getPackage().getName();
JavaClasses classes = new ClassFileImporter().withImportOption(onlyCurrentModule()).importPackages(basePackage);
ArchUnitRules.SERIALIZABLE_SHOULD_HAVE_VALID_SERIAL_VERSION_UID.check(classes);
}
Aggregations