Search in sources :

Example 86 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter in project hazelcast by hazelcast.

the class ArchUnitRulesTest method should_fail_with_non_compliant_class.

@Test
public void should_fail_with_non_compliant_class() {
    JavaClasses classes = new ClassFileImporter().withImportOption(ONLY_INCLUDE_TESTS).importPackages("com.example.broken");
    assertThat(classes).isNotEmpty();
    assertThatThrownBy(() -> ArchUnitRules.SERIALIZABLE_SHOULD_HAVE_VALID_SERIAL_VERSION_UID.check(classes)).isInstanceOf(AssertionError.class).hasMessageContaining("was violated (1 times)");
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) Test(org.junit.Test)

Example 87 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter in project hazelcast by hazelcast.

the class ArchUnitRulesTest method should_NOT_fail_with_non_compliant_class.

@Test
public void should_NOT_fail_with_non_compliant_class() {
    JavaClasses classes = new ClassFileImporter().withImportOption(ONLY_INCLUDE_TESTS).importPackages("com.example.valid");
    assertThat(classes).isNotEmpty();
    ArchUnitRules.SERIALIZABLE_SHOULD_HAVE_VALID_SERIAL_VERSION_UID.check(classes);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) Test(org.junit.Test)

Example 88 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter in project hazelcast by hazelcast.

the class S3SerializableTest method serializable_classes_should_have_valid_serialVersionUID.

@Test
public void serializable_classes_should_have_valid_serialVersionUID() {
    String basePackage = S3Sources.class.getPackage().getName();
    JavaClasses classes = new ClassFileImporter().withImportOption(onlyCurrentModule()).importPackages(basePackage);
    ArchUnitRules.SERIALIZABLE_SHOULD_HAVE_VALID_SERIAL_VERSION_UID.check(classes);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test)

Example 89 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter in project hazelcast by hazelcast.

the class Elastic7SerializableTest method serializable_classes_should_have_valid_serialVersionUID.

@Test
public void serializable_classes_should_have_valid_serialVersionUID() {
    String basePackage = ElasticSources.class.getPackage().getName();
    JavaClasses classes = new ClassFileImporter().withImportOption(onlyCurrentModule()).importPackages(basePackage);
    ArchUnitRules.SERIALIZABLE_SHOULD_HAVE_VALID_SERIAL_VERSION_UID.check(classes);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test)

Example 90 with ClassFileImporter

use of com.tngtech.archunit.core.importer.ClassFileImporter in project hazelcast by hazelcast.

the class GrpcSerializableTest method serializable_classes_should_have_valid_serialVersionUID.

@Test
public void serializable_classes_should_have_valid_serialVersionUID() {
    String basePackage = GrpcService.class.getPackage().getName();
    JavaClasses classes = new ClassFileImporter().withImportOption(onlyCurrentModule()).importPackages(basePackage);
    ArchUnitRules.SERIALIZABLE_SHOULD_HAVE_VALID_SERIAL_VERSION_UID.check(classes);
}
Also used : JavaClasses(com.tngtech.archunit.core.domain.JavaClasses) ClassFileImporter(com.tngtech.archunit.core.importer.ClassFileImporter) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test)

Aggregations

ClassFileImporter (com.tngtech.archunit.core.importer.ClassFileImporter)136 JavaClasses (com.tngtech.archunit.core.domain.JavaClasses)98 Test (org.junit.Test)76 Test (org.junit.jupiter.api.Test)52 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)15 JavaClass (com.tngtech.archunit.core.domain.JavaClass)14 EvaluationResult (com.tngtech.archunit.lang.EvaluationResult)13 Workspace (com.structurizr.Workspace)12 ArchRule (com.tngtech.archunit.lang.ArchRule)12 Application (org.archifacts.core.model.Application)12 Component (com.structurizr.model.Component)10 Container (com.structurizr.model.Container)10 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)10 ArtifactContainer (org.archifacts.core.model.ArtifactContainer)10 JavaPackage (com.tngtech.archunit.core.domain.JavaPackage)5 LayeredArchitecture (com.tngtech.archunit.library.Architectures.LayeredArchitecture)5 OnionArchitecture (com.tngtech.archunit.library.Architectures.OnionArchitecture)5 Optional (java.util.Optional)5 Artifact (org.archifacts.core.model.Artifact)5 MiscArtifact (org.archifacts.core.model.MiscArtifact)5