From db3dd86a986975d2f6809e289270dc62545eeceb Mon Sep 17 00:00:00 2001 From: Llewellyn Falco Date: Mon, 10 Mar 2025 12:45:30 -0600 Subject: [PATCH] - r use querable Co-Authored-By: Jay Bazuzi --- .../namer/AttributeStackSelector.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/approvaltests/src/main/java/org/approvaltests/namer/AttributeStackSelector.java b/approvaltests/src/main/java/org/approvaltests/namer/AttributeStackSelector.java index 0ff26d0d..03bf11c5 100644 --- a/approvaltests/src/main/java/org/approvaltests/namer/AttributeStackSelector.java +++ b/approvaltests/src/main/java/org/approvaltests/namer/AttributeStackSelector.java @@ -111,22 +111,16 @@ private boolean isJunit3Test(Class clazz) private boolean isTestAttribute(Class clazz, String methodName) { Queryable methods = getMethodsByName(clazz, methodName); - for (Method method : methods) - { - for (Class attribute : attributes) - { - if (method.isAnnotationPresent(attribute)) - { - checkConditionsForAttribute(attribute); - return true; - } - } - } - return false; + Class attribute = Queryable.as(attributes) // + .first(a -> methods.any(m -> m.isAnnotationPresent(a))); + checkConditionsForAttribute(attribute); + return attribute != null; } // TODO: clean this up, should be pluggable private static void checkConditionsForAttribute(Class attribute) { + if (attribute == null) + { return; } if ("org.junit.jupiter.api.TestFactory".equals(attribute.getName())) { if (!isDynamicWrapperPresent())