Closed donalmurtagh closed 4 weeks ago
I figured out how to do this without using layers
@ArchTest
static final ArchRule noRepositoriesInControllers = noClasses()
.that().areAnnotatedWith(RestController.class)
.should().dependOnClassesThat().areAssignableTo(Repository.class);
Perhaps it would be helpful to add a method such as mayNotBeAccessedByLayers
to the layers API, but I'll close this because I've found a resolution to the original issue I was asking about.
I'm trying to write a JUnit5 test that prevents the controller layer from accessing the repository layer. My attempt looks like this
This doesn't quite work because there are some classes outside these 3 layers that do access classes in the Repositories layer. Ideally, there should be a a way to test this directly with something like
But if such a facility exists, I can't find it.