use of io.lettuce.core.codec.StringCodec in project lettuce-core by lettuce-io.
the class CommandSegmentCommandFactoryUnitTests method setKeyValue.
@Test
void setKeyValue() {
RedisCommand<?, ?, ?> command = createCommand(methodOf(Commands.class, "set", String.class, String.class), new StringCodec(), "key", "value");
assertThat(toString(command)).isEqualTo("SET key<key> key<value>");
assertThat(command.getType()).isSameAs(CommandType.SET);
}
use of io.lettuce.core.codec.StringCodec in project lettuce-core by lettuce-io.
the class CommandSegmentCommandFactoryUnitTests method setWithArgs.
@Test
void setWithArgs() {
RedisCommand<?, ?, ?> command = createCommand(methodOf(Commands.class, "set", String.class, String.class, SetArgs.class), new StringCodec(), "key", "value", SetArgs.Builder.ex(123).nx());
assertThat(toString(command)).isEqualTo("SET key<key> key<value> EX 123 NX");
}
use of io.lettuce.core.codec.StringCodec in project lettuce-core by lettuce-io.
the class CommandSegmentCommandFactoryUnitTests method lowercaseCommandResolvesToStringCommand.
@Test
void lowercaseCommandResolvesToStringCommand() {
RedisCommand<?, ?, ?> command = createCommand(methodOf(Commands.class, "set3", String.class, String.class), new StringCodec(), "key", "value");
assertThat(toString(command)).isEqualTo("set key<key> value<value>");
assertThat(command.getType()).isNotInstanceOf(CommandType.class);
}
use of io.lettuce.core.codec.StringCodec in project lettuce-core by lettuce-io.
the class CommandSegmentCommandFactoryUnitTests method annotatedClientSetname.
@Test
void annotatedClientSetname() {
RedisCommand<?, ?, ?> command = createCommand(methodOf(Commands.class, "methodWithNamedParameters", String.class), new StringCodec(), "name");
assertThat(toString(command)).isEqualTo("CLIENT SETNAME key<name>");
}
use of io.lettuce.core.codec.StringCodec in project lettuce-core by lettuce-io.
the class ReactiveCommandSegmentCommandFactoryUnitTests method createCommand.
RedisCommand<?, ?, ?> createCommand(String methodName, Class<?> interfaceClass, Class<?>... parameterTypes) {
Method method = ReflectionUtils.findMethod(interfaceClass, methodName, parameterTypes);
CommandMethod commandMethod = DeclaredCommandMethod.create(method);
AnnotationCommandSegmentFactory segmentFactory = new AnnotationCommandSegmentFactory();
CommandSegments commandSegments = segmentFactory.createCommandSegments(commandMethod);
ReactiveCommandSegmentCommandFactory factory = new ReactiveCommandSegmentCommandFactory(commandSegments, commandMethod, new StringCodec(), outputFactoryResolver);
return factory.createCommand(new Object[] { "foo" });
}
Aggregations