Closed sebarthel89 closed 2 years ago
This was a conscious breaking change with ArchUnit 0.12.0 for #209.
You can use a custom ArchCondition that excludes accesses to self:
// ...
.should(new ArchCondition<JavaClass>("access other classes that have simple name ending with Service") {
@Override
public void check(JavaClass javaClass, ConditionEvents events) {
javaClass.getAccessesFromSelf().stream().filter(access ->
!access.getTargetOwner().equals(javaClass) && access.getTargetOwner().getName().endsWith("Service")
)
.forEach(access -> events.add(SimpleConditionEvent.satisfied(javaClass, access.getDescription())));
}
});
thank you !
We use a layered architecture where one layer is called "application". You might know that from a domain driven design package structure, which comes with layers for interfaces, application, domain and infrastructure.
We have the following code to do not allow access from classes with suffix
ApplicationService
to other classes calledApplicationService
.This worked nicely with version
0.11.0
. Now, we updated to version0.23.0
which causes problems. The presented rule shows violation method calls of the same class. The following class violates the rule:To be concrete, it violates because the method
method
calls a methodprivateMethod
of a class with the suffixApplicationService
, that is the same class. We would like to exclude this rule violating for any access within the same class that worked like that in previous versions.Maybe I do miss something here that is now available in newer version. I would appreciate suggestions or maybe it's a bug?
Thanks in advance !