Skip to content

Commit

Permalink
Remove calls to deprecated MethodMatcher methods
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Feb 23, 2024
1 parent e2a69f4 commit 7105dbc
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public Set<String> getTags() {
}

@Override
public Validated validate() {
Validated validated = super.validate()
public Validated<Object> validate() {
Validated<Object> validated = super.validate()
.and(Validated.required("assertions", DEFAULT_ASSERTIONS));
if (validated.isValid()) {
validated = validated.and(Validated.test(
Expand Down Expand Up @@ -189,17 +189,13 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Set<M
Set<J.Block> methodBodies = new HashSet<>();

methodMatchers.forEach(matcher -> {
Set<J.Block> declarationBodies = matcherPatternToClassInvocation.computeIfAbsent(matcherPattern(matcher),
Set<J.Block> declarationBodies = matcherPatternToClassInvocation.computeIfAbsent(matcher.toString(),
k -> findMethodDeclarations(classDeclaration, matcher));
methodBodies.addAll(declarationBodies);
});
return methodBodies.stream().anyMatch(this::methodHasAssertion);
}

private String matcherPattern(MethodMatcher methodMatcher) {
return methodMatcher.getTargetTypePattern() + " " + methodMatcher.getMethodNamePattern() + "(" + methodMatcher.getArgumentPattern() + ")";
}

private Set<J.Block> findMethodDeclarations(J.ClassDeclaration classDeclaration, MethodMatcher methodMatcher) {
JavaIsoVisitor<Set<J.Block>> findMethodDeclarationVisitor = new JavaIsoVisitor<Set<J.Block>>() {
@Override
Expand Down

0 comments on commit 7105dbc

Please sign in to comment.