I got seemingly trivial use-case, and still I cannot figure it out. Let’s take a look at the package structure. — CommonPackage — Package1 —- DAOs —- Common —- Service — Package2 —- subpackage1 —- subpackage2 What I want to achieve is to create a rule, in which all the classes in the Package2, cannot use any of the classes
Tag: archunit
How to check that a constructor is called in the right classes with ArchUnit?
Is there any way to enforce a rule like this one with ArchUnit : The issue here is that beCalledInClassesThat does not exists and I don’t find anything that will allow me to implement such a test. Answer Whenever you miss something in the predefined fluent API, try to define a custom predicate/condition. In your case: does this work for
ArchUnit – is there a way to check package access with a generic placeholder?
I would like to check whether FOO.model is only accessed by FOO.service and BAR.model is only accessed by BAR.service and so on. Is there a way to achieve this with ArchUnit? Like (pseudocode) I’m aware I could write a test that iterates over all FOO, BAR etc packages, or write a separate test for every package, but I’m looking for
How to validate that a method annotation is using an attribute with an specific value using archunit
I have an @Audit annotation, it has many optional attributes, I need to enforce the use of one boolean attribute useAccount = true for certain packages. I am trying to use archunit to accomplish this validation, that way whenever a developer commits code that breaks the rule the CI will break and inform the team. This would break the build: