Search in sources :

Example 6 with StringCodec

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);
}
Also used : StringCodec(io.lettuce.core.codec.StringCodec) Test(org.junit.jupiter.api.Test)

Example 7 with StringCodec

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");
}
Also used : StringCodec(io.lettuce.core.codec.StringCodec) SetArgs(io.lettuce.core.SetArgs) Test(org.junit.jupiter.api.Test)

Example 8 with StringCodec

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);
}
Also used : StringCodec(io.lettuce.core.codec.StringCodec) Test(org.junit.jupiter.api.Test)

Example 9 with StringCodec

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>");
}
Also used : StringCodec(io.lettuce.core.codec.StringCodec) Test(org.junit.jupiter.api.Test)

Example 10 with StringCodec

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" });
}
Also used : AnnotationCommandSegmentFactory(io.lettuce.core.dynamic.segment.AnnotationCommandSegmentFactory) StringCodec(io.lettuce.core.codec.StringCodec) CommandSegments(io.lettuce.core.dynamic.segment.CommandSegments) Method(java.lang.reflect.Method)

Aggregations

StringCodec (io.lettuce.core.codec.StringCodec)16 Test (org.junit.jupiter.api.Test)12 ResolvableType (io.lettuce.core.dynamic.support.ResolvableType)4 ScanArgs (io.lettuce.core.ScanArgs)1 ScoredValue (io.lettuce.core.ScoredValue)1 SetArgs (io.lettuce.core.SetArgs)1 Timeout (io.lettuce.core.dynamic.domain.Timeout)1 AnnotationCommandSegmentFactory (io.lettuce.core.dynamic.segment.AnnotationCommandSegmentFactory)1 CommandSegments (io.lettuce.core.dynamic.segment.CommandSegments)1 CommandArgs (io.lettuce.core.protocol.CommandArgs)1 Method (java.lang.reflect.Method)1 List (java.util.List)1