[JAVA] Test with ArchUnit that "reference operation depends on QueryService, not Repository"

Let's test that "reference operation depends on QueryService, not Repository".

Test code


@AnalyzeClasses(packages = "com.example")
public class CommandQueryTest {

    @ArchTest
    static ArchRule get_endpoint_depend_on_query_service =
        classes().that().resideInAPackage("com.example.application")
            .should().onlyAccessClassesThat().resideInAPackage("com.example.queryservice");

If you just want to get a specific reference result, you can determine by testing that it depends on the QueryService class. If you have to depend on other classes, you can list them individually or test that they do not depend on the Repository class.

Recommended Posts

Test with ArchUnit that "reference operation depends on QueryService, not Repository"
Programs that use io_uring do not work with Docker on CentOS 8