Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* @see EnabledOnCommandCondition
* @author Mark Paluch
* @author Christoph Strobl
* @author Heramb Joshi
*/
class EnabledOnCommandCondition implements ExecutionCondition {

Expand All @@ -55,9 +56,11 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con

ExtensionContext.Store store = context.getRoot().getStore(NAMESPACE);
RedisConditions conditions = store.getOrComputeIfAbsent(RedisConditions.class, ignore -> {

try (StatefulRedisConnection connection = lettuceExtension.resolve(context, StatefulRedisConnection.class)) {
try {
StatefulRedisConnection connection = lettuceExtension.resolve(context, StatefulRedisConnection.class);
return RedisConditions.of(connection);
} catch (Exception e) {
return RedisConditions.emptyConnection();
}
}, RedisConditions.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
Expand All @@ -35,6 +36,7 @@
* Collection of utility methods to test conditions during test execution.
*
* @author Mark Paluch
* @author Heramb Joshi
*/
class RedisConditions {

Expand Down Expand Up @@ -62,6 +64,19 @@ private RedisConditions(RedisClusterCommands<String, String> commands) {
}
}

private RedisConditions(){
commands = new HashMap<>();
version = new Version(1);
}

/**
* Create empty {@link RedisConditions}.
*
* @return
*/public static RedisConditions emptyConnection() {
return new RedisConditions();
}

/**
* Create {@link RedisCommands} given {@link StatefulRedisConnection}.
*
Expand Down
Loading