Disallow empty expression in @DisabledIf
This commit ensures that a user provides a non-empty expression in declarations of @DisabledIf. Issue: SPR-14614
This commit is contained in:
@@ -82,7 +82,9 @@ public class DisabledIfCondition implements ContainerExecutionCondition, TestExe
|
||||
Optional<DisabledIf> disabledIf = findMergedAnnotation(element, DisabledIf.class);
|
||||
Assert.state(disabledIf.isPresent(), () -> "@DisabledIf must be present on " + element);
|
||||
|
||||
String expression = disabledIf.get().expression().trim();
|
||||
String expression = disabledIf.map(DisabledIf::expression).filter(StringUtils::hasText).orElseThrow(
|
||||
() -> new IllegalStateException(
|
||||
String.format("The expression in @DisabledIf on [%s] must not be blank", element)));
|
||||
|
||||
if (isDisabled(expression, extensionContext)) {
|
||||
String reason = disabledIf.map(DisabledIf::reason).filter(StringUtils::hasText).orElseGet(
|
||||
|
||||
Reference in New Issue
Block a user