Search in sources :

Example 11 with StringCodec

use of io.lettuce.core.codec.StringCodec in project lettuce-core by lettuce-io.

the class CommandSegmentCommandFactoryUnitTests method setKeyValueWithHintedValue.

@Test
void setKeyValueWithHintedValue() {
    RedisCommand<?, ?, ?> command = createCommand(methodOf(Commands.class, "set2", String.class, String.class), new StringCodec(), "key", "value");
    assertThat(toString(command)).isEqualTo("SET key<key> value<value>");
    assertThat(command.getType()).isSameAs(CommandType.SET);
}
Also used : StringCodec(io.lettuce.core.codec.StringCodec) Test(org.junit.jupiter.api.Test)

Example 12 with StringCodec

use of io.lettuce.core.codec.StringCodec in project lettuce-core by lettuce-io.

the class CommandSegmentCommandFactoryUnitTests method varargsMethodWithParameterIndexAccess.

@Test
void varargsMethodWithParameterIndexAccess() {
    RedisCommand<?, ?, ?> command = createCommand(methodOf(Commands.class, "varargsWithParamIndexes", ScanArgs.class, String[].class), new StringCodec(), ScanArgs.Builder.limit(1), new String[] { "a", "b" });
    assertThat(toString(command)).isEqualTo("MGET a b COUNT 1");
}
Also used : StringCodec(io.lettuce.core.codec.StringCodec) ScanArgs(io.lettuce.core.ScanArgs) Test(org.junit.jupiter.api.Test)

Example 13 with StringCodec

use of io.lettuce.core.codec.StringCodec in project lettuce-core by lettuce-io.

the class CommandSegmentCommandFactoryUnitTests method asyncWithTimeout.

@Test
void asyncWithTimeout() {
    try {
        createCommand(methodOf(MethodsWithTimeout.class, "async", String.class, Timeout.class), new StringCodec());
        fail("Missing CommandCreationException");
    } catch (CommandCreationException e) {
        assertThat(e).hasMessageContaining("Asynchronous command methods do not support Timeout parameters");
    }
}
Also used : StringCodec(io.lettuce.core.codec.StringCodec) Timeout(io.lettuce.core.dynamic.domain.Timeout) Test(org.junit.jupiter.api.Test)

Example 14 with StringCodec

use of io.lettuce.core.codec.StringCodec in project lettuce-core by lettuce-io.

the class CommandSegmentCommandFactoryUnitTests method resolvesUnknownCommandToStringBackedCommandType.

@Test
void resolvesUnknownCommandToStringBackedCommandType() {
    RedisCommand<?, ?, ?> command = createCommand(methodOf(Commands.class, "unknownCommand"), new StringCodec());
    assertThat(toString(command)).isEqualTo("XYZ");
    assertThat(command.getType()).isNotInstanceOf(CommandType.class);
}
Also used : StringCodec(io.lettuce.core.codec.StringCodec) Test(org.junit.jupiter.api.Test)

Example 15 with StringCodec

use of io.lettuce.core.codec.StringCodec in project lettuce-core by lettuce-io.

the class ParameterBinderUnitTests method bind.

private CommandArgs<String, String> bind(CommandMethod commandMethod, Object object) {
    DefaultMethodParametersAccessor parametersAccessor = new DefaultMethodParametersAccessor(commandMethod.getParameters(), object);
    CommandArgs<String, String> args = new CommandArgs<>(new StringCodec());
    binder.bind(args, StringCodec.UTF8, segments, parametersAccessor);
    return args;
}
Also used : CommandArgs(io.lettuce.core.protocol.CommandArgs) StringCodec(io.lettuce.core.codec.StringCodec)

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