You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using ArchUnit since quite a while, works as a charm. So thanks for all your efforts.
I now have a Java application where I want to check for correct dependencies in a layered architecture.
Therefore I am using Architectures.LayeredArchitecture to define all the various technical layers and use mayOnlyAccessLayers(...) and mayOnlyBeAccessedByLayers(...) to define what dependencies are correct and which should be reported as architecture violations.
This more or less works well, but I have one case where wrong dependencies are not reported, so perhaps you can help out with that. (I could provide a thinned out code example if needed):
Let's say I have two layers L1 and L2. L1 should not depend on any classes of L2, i.e. wrong dependencies L1->L2 should be reported by ArchUnit, i.e. from any class C1 in L1 with a dependency to a class C2 in L2 :
a) This works as expected when C1 has a method where C2 is a type in the parameter list, like in public void myMethod(C2 myParameter) { ... }
b) This works as expected when C1 has a method where C2 is the type of the return value like in public C2 myMethod(int myInteger) { ... }
c) But: When C2 is only used internally inside the method, this wrong dependency is not found like in public boolean myMethod(int myInteger) { C2 myCTwo = new C2(); ... }
Am I doing something wrong? Is this a wanted or known behaviour?
And: Could I myself add something (like a check for such a JavaAccess in something like a predicate?) to the LayeredArchitecture so
that its current standard behaviour would find and report such wrong dependencies as well?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am using ArchUnit since quite a while, works as a charm. So thanks for all your efforts.
I now have a Java application where I want to check for correct dependencies in a layered architecture.
Therefore I am using
Architectures.LayeredArchitecture
to define all the various technical layers and usemayOnlyAccessLayers(...)
andmayOnlyBeAccessedByLayers(...)
to define what dependencies are correct and which should be reported as architecture violations.This more or less works well, but I have one case where wrong dependencies are not reported, so perhaps you can help out with that. (I could provide a thinned out code example if needed):
Let's say I have two layers L1 and L2. L1 should not depend on any classes of L2, i.e. wrong dependencies L1->L2 should be reported by ArchUnit, i.e. from any class C1 in L1 with a dependency to a class C2 in L2 :
a) This works as expected when C1 has a method where C2 is a type in the parameter list, like in
public void myMethod(C2 myParameter) { ... }
b) This works as expected when C1 has a method where C2 is the type of the return value like in
public C2 myMethod(int myInteger) { ... }
c) But: When C2 is only used internally inside the method, this wrong dependency is not found like in
public boolean myMethod(int myInteger) { C2 myCTwo = new C2(); ... }
Am I doing something wrong? Is this a wanted or known behaviour?
And: Could I myself add something (like a check for such a JavaAccess in something like a predicate?) to the
LayeredArchitecture
sothat its current standard behaviour would find and report such wrong dependencies as well?
Thx for your help in advance.
Beta Was this translation helpful? Give feedback.
All reactions