diff --git a/glide-core/src/request_type.rs b/glide-core/src/request_type.rs index 41138cadaf..55c21fe5cf 100644 --- a/glide-core/src/request_type.rs +++ b/glide-core/src/request_type.rs @@ -112,6 +112,7 @@ pub enum RequestType { RPushX = 102, LPushX = 103, ZMScore = 104, + ZDiffStore = 106, } fn get_two_word_command(first: &str, second: &str) -> Cmd { @@ -227,6 +228,7 @@ impl From<::protobuf::EnumOrUnknown> for RequestType { ProtobufRequestType::Blpop => RequestType::Blpop, ProtobufRequestType::Spop => RequestType::Spop, ProtobufRequestType::ZMScore => RequestType::ZMScore, + ProtobufRequestType::ZDiffStore => RequestType::ZDiffStore, } } } @@ -338,6 +340,7 @@ impl RequestType { RequestType::Blpop => Some(cmd("BLPOP")), RequestType::Spop => Some(cmd("SPOP")), RequestType::ZMScore => Some(cmd("ZMSCORE")), + RequestType::ZDiffStore => Some(cmd("ZDIFFSTORE")), } } } diff --git a/java/client/src/main/java/glide/api/BaseClient.java b/java/client/src/main/java/glide/api/BaseClient.java index 9c5ac3c55a..e926a7f73e 100644 --- a/java/client/src/main/java/glide/api/BaseClient.java +++ b/java/client/src/main/java/glide/api/BaseClient.java @@ -60,8 +60,8 @@ import static redis_request.RedisRequestOuterClass.RequestType.Type; import static redis_request.RedisRequestOuterClass.RequestType.Unlink; import static redis_request.RedisRequestOuterClass.RequestType.XAdd; -import static redis_request.RedisRequestOuterClass.RequestType.ZMScore; import static redis_request.RedisRequestOuterClass.RequestType.ZDiffStore; +import static redis_request.RedisRequestOuterClass.RequestType.ZMScore; import static redis_request.RedisRequestOuterClass.RequestType.ZPopMax; import static redis_request.RedisRequestOuterClass.RequestType.ZPopMin; import static redis_request.RedisRequestOuterClass.RequestType.ZScore; @@ -728,7 +728,7 @@ public CompletableFuture zmscore(@NonNull String key, @NonNull String[ @Override public CompletableFuture zdiffstore(@NonNull String destination, @NonNull String[] keys) { String[] arguments = - ArrayUtils.addAll(new String[] {destination, Long.toString(keys.length)}, keys); + ArrayUtils.addAll(new String[] {destination, Long.toString(keys.length)}, keys); return commandManager.submitNewCommand(ZDiffStore, arguments, this::handleLongResponse); } diff --git a/java/client/src/main/java/glide/api/models/BaseTransaction.java b/java/client/src/main/java/glide/api/models/BaseTransaction.java index d4d2b7d10a..b1886a4826 100644 --- a/java/client/src/main/java/glide/api/models/BaseTransaction.java +++ b/java/client/src/main/java/glide/api/models/BaseTransaction.java @@ -71,8 +71,8 @@ import static redis_request.RedisRequestOuterClass.RequestType.Type; import static redis_request.RedisRequestOuterClass.RequestType.Unlink; import static redis_request.RedisRequestOuterClass.RequestType.XAdd; -import static redis_request.RedisRequestOuterClass.RequestType.ZMScore; import static redis_request.RedisRequestOuterClass.RequestType.ZDiffStore; +import static redis_request.RedisRequestOuterClass.RequestType.ZMScore; import static redis_request.RedisRequestOuterClass.RequestType.ZPopMax; import static redis_request.RedisRequestOuterClass.RequestType.ZPopMin; import static redis_request.RedisRequestOuterClass.RequestType.ZScore; @@ -1504,7 +1504,7 @@ public T zmscore(@NonNull String key, @NonNull String[] members) { */ public T zdiffstore(@NonNull String destination, @NonNull String[] keys) { ArgsArray commandArgs = - buildArgs(ArrayUtils.addAll(new String[] {destination, Long.toString(keys.length)}, keys)); + buildArgs(ArrayUtils.addAll(new String[] {destination, Long.toString(keys.length)}, keys)); protobufTransaction.addCommands(buildCommand(ZDiffStore, commandArgs)); return getThis(); } diff --git a/java/client/src/test/java/glide/api/RedisClientTest.java b/java/client/src/test/java/glide/api/RedisClientTest.java index 50c9742de9..fade1af011 100644 --- a/java/client/src/test/java/glide/api/RedisClientTest.java +++ b/java/client/src/test/java/glide/api/RedisClientTest.java @@ -91,8 +91,8 @@ import static redis_request.RedisRequestOuterClass.RequestType.Type; import static redis_request.RedisRequestOuterClass.RequestType.Unlink; import static redis_request.RedisRequestOuterClass.RequestType.XAdd; -import static redis_request.RedisRequestOuterClass.RequestType.ZMScore; import static redis_request.RedisRequestOuterClass.RequestType.ZDiffStore; +import static redis_request.RedisRequestOuterClass.RequestType.ZMScore; import static redis_request.RedisRequestOuterClass.RequestType.ZPopMax; import static redis_request.RedisRequestOuterClass.RequestType.ZPopMin; import static redis_request.RedisRequestOuterClass.RequestType.ZScore; @@ -2296,7 +2296,6 @@ public void zmscore_returns_success() { assertEquals(value, payload); } - @SneakyThrows @Test public void zdiffstore_returns_success() { @@ -2311,7 +2310,7 @@ public void zdiffstore_returns_success() { // match on protobuf request when(commandManager.submitNewCommand(eq(ZDiffStore), eq(arguments), any())) - .thenReturn(testResponse); + .thenReturn(testResponse); // exercise CompletableFuture response = service.zdiffstore(destKey, keys); diff --git a/java/client/src/test/java/glide/api/models/TransactionTests.java b/java/client/src/test/java/glide/api/models/TransactionTests.java index 7b5a7623b4..7818ef382b 100644 --- a/java/client/src/test/java/glide/api/models/TransactionTests.java +++ b/java/client/src/test/java/glide/api/models/TransactionTests.java @@ -76,8 +76,8 @@ import static redis_request.RedisRequestOuterClass.RequestType.Type; import static redis_request.RedisRequestOuterClass.RequestType.Unlink; import static redis_request.RedisRequestOuterClass.RequestType.XAdd; -import static redis_request.RedisRequestOuterClass.RequestType.ZMScore; import static redis_request.RedisRequestOuterClass.RequestType.ZDiffStore; +import static redis_request.RedisRequestOuterClass.RequestType.ZMScore; import static redis_request.RedisRequestOuterClass.RequestType.ZPopMax; import static redis_request.RedisRequestOuterClass.RequestType.ZPopMin; import static redis_request.RedisRequestOuterClass.RequestType.ZScore; @@ -353,14 +353,14 @@ public void transaction_builds_protobuf_request(BaseTransaction transaction) transaction.zdiffstore("destKey", new String[] {"key1", "key2"}); results.add( - Pair.of( - ZDiffStore, - ArgsArray.newBuilder() - .addArgs("destKey") - .addArgs("2") - .addArgs("key1") - .addArgs("key2") - .build())); + Pair.of( + ZDiffStore, + ArgsArray.newBuilder() + .addArgs("destKey") + .addArgs("2") + .addArgs("key1") + .addArgs("key2") + .build())); transaction.xadd("key", Map.of("field1", "foo1")); results.add(Pair.of(XAdd, buildArgs("key", "*", "field1", "foo1"))); diff --git a/java/integTest/src/test/java/glide/SharedCommandTests.java b/java/integTest/src/test/java/glide/SharedCommandTests.java index 20c09a5fe9..5b97a3fc2b 100644 --- a/java/integTest/src/test/java/glide/SharedCommandTests.java +++ b/java/integTest/src/test/java/glide/SharedCommandTests.java @@ -1362,8 +1362,8 @@ public void zdiffstore(BaseClient client) { assertEquals(2, client.zdiffstore(key4, new String[] {key1, key2}).get()); assertEquals( - Map.of("one", 1.0, "three", 3.0), - client.zrangeWithScores(key4, new RangeByIndex(0, -1)).get()); + Map.of("one", 1.0, "three", 3.0), + client.zrangeWithScores(key4, new RangeByIndex(0, -1)).get()); assertEquals(1, client.zdiffstore(key4, new String[] {key3, key2, key1}).get()); assertEquals(Map.of("four", 4.0), client.zrangeWithScores(key4, new RangeByIndex(0, -1)).get()); @@ -1378,9 +1378,9 @@ public void zdiffstore(BaseClient client) { // Key exists, but it is not a set assertEquals(OK, client.set(key5, "bar").get()); ExecutionException executionException = - assertThrows( - ExecutionException.class, - () -> client.zdiffstore(key4, new String[] {key5, key1}).get()); + assertThrows( + ExecutionException.class, + () -> client.zdiffstore(key4, new String[] {key5, key1}).get()); assertTrue(executionException.getCause() instanceof RequestException); }