Let's test that "reference operation depends on QueryService, not Repository".
@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.