Skip to content

Commit

Permalink
Rebase + Spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
SanHalacogluImproving committed Apr 10, 2024
1 parent 721374a commit 9bfcf12
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
3 changes: 3 additions & 0 deletions glide-core/src/request_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -227,6 +228,7 @@ impl From<::protobuf::EnumOrUnknown<ProtobufRequestType>> for RequestType {
ProtobufRequestType::Blpop => RequestType::Blpop,
ProtobufRequestType::Spop => RequestType::Spop,
ProtobufRequestType::ZMScore => RequestType::ZMScore,
ProtobufRequestType::ZDiffStore => RequestType::ZDiffStore,
}
}
}
Expand Down Expand Up @@ -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")),
}
}
}
4 changes: 2 additions & 2 deletions java/client/src/main/java/glide/api/BaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -728,7 +728,7 @@ public CompletableFuture<Double[]> zmscore(@NonNull String key, @NonNull String[
@Override
public CompletableFuture<Long> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
5 changes: 2 additions & 3 deletions java/client/src/test/java/glide/api/RedisClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -2296,7 +2296,6 @@ public void zmscore_returns_success() {
assertEquals(value, payload);
}


@SneakyThrows
@Test
public void zdiffstore_returns_success() {
Expand All @@ -2311,7 +2310,7 @@ public void zdiffstore_returns_success() {

// match on protobuf request
when(commandManager.<Long>submitNewCommand(eq(ZDiffStore), eq(arguments), any()))
.thenReturn(testResponse);
.thenReturn(testResponse);

// exercise
CompletableFuture<Long> response = service.zdiffstore(destKey, keys);
Expand Down
18 changes: 9 additions & 9 deletions java/client/src/test/java/glide/api/models/TransactionTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")));
Expand Down
10 changes: 5 additions & 5 deletions java/integTest/src/test/java/glide/SharedCommandTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
}

Expand Down

0 comments on commit 9bfcf12

Please sign in to comment.