use of io.lettuce.test.LettuceExtension in project lettuce-core by lettuce-io.
the class EnabledOnCommandCondition method evaluateExecutionCondition.
@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
Optional<EnabledOnCommand> optional = AnnotationUtils.findAnnotation(context.getElement(), EnabledOnCommand.class);
if (optional.isPresent()) {
String command = optional.get().value();
StatefulRedisConnection connection = new LettuceExtension().resolve(context, StatefulRedisConnection.class);
RedisConditions conditions = RedisConditions.of(connection);
boolean hasCommand = conditions.hasCommand(command);
return hasCommand ? enabled("Enabled on command " + command) : disabled("Disabled, command " + command + " not available on Redis version " + conditions.getRedisVersion());
}
return ENABLED_BY_DEFAULT;
}
Aggregations