Skip to content

Instantly share code, notes, and snippets.

@andres-sacco
Created January 16, 2021 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andres-sacco/d6395e88a6bbb2135ad391ab8cce49ba to your computer and use it in GitHub Desktop.
Save andres-sacco/d6395e88a6bbb2135ad391ab8cce49ba to your computer and use it in GitHub Desktop.
Model rules
import static com.almundo.api.flights.cvc.architecture.CustomArchConditions.HAVE_EQUALS_AND_HASH_CODE;
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;
import com.tngtech.archunit.core.importer.ImportOption;
import com.tngtech.archunit.junit.AnalyzeClasses;
import com.tngtech.archunit.junit.ArchTest;
import com.tngtech.archunit.lang.ArchRule;
@AnalyzeClasses(packages = "com.example.archunit", importOptions = ImportOption.DoNotIncludeTests.class)
class ModelRulesTest {
@ArchTest
static final ArchRule classesShouldOverrideEqualsAndHashCode = classes().that()
.resideInAnyPackage("com.example.archunit.model")
.and().areNotMemberClasses()
.should(HAVE_EQUALS_AND_HASH_CODE)
.because("Model classes should override equals and hashCode methods");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment