Skip to content

Commit

Permalink
Added Pathv1 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tishun committed Aug 21, 2024
1 parent 9b10744 commit 9b3892b
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 101 deletions.
27 changes: 10 additions & 17 deletions src/main/java/io/lettuce/core/RedisJsonCommandBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,7 @@
import io.lettuce.core.json.JsonPath;
import io.lettuce.core.json.arguments.JsonRangeArgs;
import io.lettuce.core.json.arguments.JsonSetArgs;
import io.lettuce.core.output.BooleanOutput;
import io.lettuce.core.output.IntegerListOutput;
import io.lettuce.core.output.IntegerOutput;
import io.lettuce.core.output.JsonValueListOutput;
import io.lettuce.core.output.KeyListOutput;
import io.lettuce.core.output.NumberListOutput;
import io.lettuce.core.output.StatusOutput;
import io.lettuce.core.output.ValueListOutput;
import io.lettuce.core.output.*;
import io.lettuce.core.protocol.BaseRedisCommandBuilder;
import io.lettuce.core.protocol.Command;
import io.lettuce.core.protocol.CommandArgs;
Expand Down Expand Up @@ -55,7 +48,7 @@ Command<K, V, List<Long>> jsonArrappend(K key, JsonPath jsonPath, JsonValue<K, V
args.add(value.asByteBuffer().array());
}

return createCommand(JSON_ARRAPPEND, new IntegerListOutput<>(codec), args);
return createCommand(JSON_ARRAPPEND, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, List<Long>> jsonArrindex(K key, JsonPath jsonPath, JsonValue<K, V> value, JsonRangeArgs range) {
Expand All @@ -74,7 +67,7 @@ Command<K, V, List<Long>> jsonArrindex(K key, JsonPath jsonPath, JsonValue<K, V>
range.build(args);
}

return createCommand(JSON_ARRINDEX, new IntegerListOutput<>(codec), args);
return createCommand(JSON_ARRINDEX, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, List<Long>> jsonArrinsert(K key, JsonPath jsonPath, int index, JsonValue<K, V>... values) {
Expand All @@ -92,7 +85,7 @@ Command<K, V, List<Long>> jsonArrinsert(K key, JsonPath jsonPath, int index, Jso
args.add(value.asByteBuffer().array());
}

return createCommand(JSON_ARRINSERT, new IntegerListOutput<>(codec), args);
return createCommand(JSON_ARRINSERT, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, List<Long>> jsonArrlen(K key, JsonPath jsonPath) {
Expand All @@ -103,7 +96,7 @@ Command<K, V, List<Long>> jsonArrlen(K key, JsonPath jsonPath) {
if (jsonPath != null && !jsonPath.isRootPath()) {
args.add(jsonPath.toString());
}
return createCommand(JSON_ARRLEN, new IntegerListOutput<>(codec), args);
return createCommand(JSON_ARRLEN, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, List<JsonValue<K, V>>> jsonArrpop(K key, JsonPath jsonPath, int index) {
Expand Down Expand Up @@ -136,7 +129,7 @@ Command<K, V, List<Long>> jsonArrtrim(K key, JsonPath jsonPath, JsonRangeArgs ra
range.build(args);
}

return createCommand(JSON_ARRTRIM, new IntegerListOutput<>(codec), args);
return createCommand(JSON_ARRTRIM, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, Long> jsonClear(K key, JsonPath jsonPath) {
Expand Down Expand Up @@ -247,7 +240,7 @@ Command<K, V, List<Long>> jsonObjlen(K key, JsonPath jsonPath) {
args.add(jsonPath.toString());
}

return createCommand(JSON_OBJLEN, new IntegerListOutput<>(codec), args);
return createCommand(JSON_OBJLEN, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, String> jsonSet(K key, JsonPath jsonPath, JsonValue<K, V> value, JsonSetArgs options) {
Expand Down Expand Up @@ -277,7 +270,7 @@ Command<K, V, List<Long>> jsonStrappend(K key, JsonPath jsonPath, JsonValue<K, V

args.add(value.asByteBuffer().array());

return createCommand(JSON_STRAPPEND, new IntegerListOutput<>(codec), args);
return createCommand(JSON_STRAPPEND, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, List<Long>> jsonStrlen(K key, JsonPath jsonPath) {
Expand All @@ -290,7 +283,7 @@ Command<K, V, List<Long>> jsonStrlen(K key, JsonPath jsonPath) {
args.add(jsonPath.toString());
}

return createCommand(JSON_STRLEN, new IntegerListOutput<>(codec), args);
return createCommand(JSON_STRLEN, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, List<Long>> jsonToggle(K key, JsonPath jsonPath) {
Expand All @@ -302,7 +295,7 @@ Command<K, V, List<Long>> jsonToggle(K key, JsonPath jsonPath) {
args.add(jsonPath.toString());
}

return createCommand(JSON_TOGGLE, new IntegerListOutput<>(codec), args);
return createCommand(JSON_TOGGLE, (CommandOutput) new ArrayOutput<>(codec), args);
}

Command<K, V, Long> jsonDel(K key, JsonPath jsonPath) {
Expand Down
Loading

0 comments on commit 9b3892b

Please sign in to comment.