Skip to content

How to avoid excessive output when positively checking method calls #973

Answered by hankem
perlun asked this question in Q&A
Discussion options

You must be logged in to vote

I think you can achieve your goal with a custom ArchCondition:

// ...
.should(new ArchCondition<JavaClass>("call a method in SomeDBLayerClass") {
    @Override
    public void check(JavaClass javaClass, ConditionEvents conditionEvents) {
        if (javaClass.getMethodCallsFromSelf().stream().noneMatch(call -> call.getTargetOwner().isEquivalentTo(SomeDBLayerClass.class))) {
            conditionEvents.add(SimpleConditionEvent.violated(javaClass, javaClass.getName() + " does not call a method in SomeDBLayerClass"));
        }
    }
}) // ...

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@perlun
Comment options

Comment options

You must be logged in to vote
1 reply
@perlun
Comment options

Answer selected by perlun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants