use of com.tngtech.archunit.core.importer.ClassFileImporter in project micrometer by micrometer-metrics.
the class JvmGcMetricsTest method noJvmImplementationSpecificApiSignatures.
@Test
void noJvmImplementationSpecificApiSignatures() {
JavaClasses importedClasses = new ClassFileImporter().importPackages("io.micrometer.binder.jvm");
ArchRule noSunManagementInMethodSignatures = methods().should().notHaveRawReturnType(resideInAPackage("com.sun.management..")).andShould().notHaveRawParameterTypes(DescribedPredicate.anyElementThat(resideInAPackage("com.sun.management..")));
noSunManagementInMethodSignatures.check(importedClasses);
}
use of com.tngtech.archunit.core.importer.ClassFileImporter in project jhipster-sample-app-websocket 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.sample");
noClasses().that().resideInAnyPackage("io.github.jhipster.sample.service..").or().resideInAnyPackage("io.github.jhipster.sample.repository..").should().dependOnClassesThat().resideInAnyPackage("..io.github.jhipster.sample.web..").because("Services and repositories should not depend on web layer").check(importedClasses);
}
use of com.tngtech.archunit.core.importer.ClassFileImporter in project jhipster-sample-app-elasticsearch 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.sample");
noClasses().that().resideInAnyPackage("io.github.jhipster.sample.service..").or().resideInAnyPackage("io.github.jhipster.sample.repository..").should().dependOnClassesThat().resideInAnyPackage("..io.github.jhipster.sample.web..").because("Services and repositories should not depend on web layer").check(importedClasses);
}
use of com.tngtech.archunit.core.importer.ClassFileImporter in project jhipster-sample-app-dto 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.sample");
noClasses().that().resideInAnyPackage("io.github.jhipster.sample.service..").or().resideInAnyPackage("io.github.jhipster.sample.repository..").should().dependOnClassesThat().resideInAnyPackage("..io.github.jhipster.sample.web..").because("Services and repositories should not depend on web layer").check(importedClasses);
}
use of com.tngtech.archunit.core.importer.ClassFileImporter in project solarthing by wildmountainfarms.
the class ArchTest method classes_contain_both_equals_and_hash_code_or_contain_neither.
@Test
void classes_contain_both_equals_and_hash_code_or_contain_neither() {
// TODO Note this only checks the method name, so someone could overload equals or hashCode and cause errors
JavaClasses importedClasses = new ClassFileImporter().importPackages("me.retrodaredevil");
for (JavaClass javaClass : importedClasses) {
boolean overridesEquals = javaClass.getMethods().stream().anyMatch(method -> "equals".equals(method.getName()));
boolean overridesHashCode = javaClass.getMethods().stream().anyMatch(method -> "hashCode".equals(method.getName()));
if (overridesEquals != overridesHashCode) {
if (overridesEquals) {
fail(javaClass + " overrides equals but not hashCode()!");
} else {
fail(javaClass + " overrides hashCode() but not equals()!");
}
}
}
}
Aggregations