diff --git a/java/client/src/main/java/glide/api/BaseClient.java b/java/client/src/main/java/glide/api/BaseClient.java index c16efe24f6..d8b5659484 100644 --- a/java/client/src/main/java/glide/api/BaseClient.java +++ b/java/client/src/main/java/glide/api/BaseClient.java @@ -2810,8 +2810,10 @@ public CompletableFuture zscan(@NonNull String key, long cursor) { } @Override - public CompletableFuture zscan(@NonNull String key, long cursor, @NonNull ZScanOptions zscanOptions) { - String[] arguments = concatenateArrays(new String[] {key, Long.toString(cursor)}, zscanOptions.toArgs()); + public CompletableFuture zscan( + @NonNull String key, long cursor, @NonNull ZScanOptions zscanOptions) { + String[] arguments = + concatenateArrays(new String[] {key, Long.toString(cursor)}, zscanOptions.toArgs()); return commandManager.submitNewCommand(ZScan, arguments, this::handleArrayResponse); } } diff --git a/java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java b/java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java index 5538632088..e469a14fb7 100644 --- a/java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java +++ b/java/client/src/main/java/glide/api/commands/SortedSetBaseCommands.java @@ -20,7 +20,6 @@ import glide.api.models.commands.WeightAggregateOptions.WeightedKeys; import glide.api.models.commands.ZAddOptions; import glide.api.models.commands.scan.ZScanOptions; - import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -1619,7 +1618,6 @@ CompletableFuture> zinterWithScores( * @param key The key of the set. * @param cursor The cursor that points to the next iteration of results. * @param zScanOptions The {@link ZScanOptions}. - * * @return An Array of Objects. The first element is always the * cursor for the next iteration of results. 0 will be the cursor * returned on the last iteration of the set. The second element is always an diff --git a/java/client/src/test/java/glide/api/RedisClientTest.java b/java/client/src/test/java/glide/api/RedisClientTest.java index ced43517dc..b36bb3b4c4 100644 --- a/java/client/src/test/java/glide/api/RedisClientTest.java +++ b/java/client/src/test/java/glide/api/RedisClientTest.java @@ -314,7 +314,6 @@ import glide.managers.CommandManager; import glide.managers.ConnectionManager; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -9033,7 +9032,7 @@ public void zscan_returns_success() { // match on protobuf request when(commandManager.submitNewCommand(eq(ZScan), eq(arguments), any())) - .thenReturn(testResponse); + .thenReturn(testResponse); // exercise CompletableFuture response = service.zscan(key, cursor); @@ -9051,9 +9050,9 @@ public void zscan_with_options_returns_success() { String key = "testKey"; long cursor = 0; String[] arguments = - new String[] { - key, Long.toString(cursor), MATCH_OPTION_STRING, "*", COUNT_OPTION_STRING, "1" - }; + new String[] { + key, Long.toString(cursor), MATCH_OPTION_STRING, "*", COUNT_OPTION_STRING, "1" + }; Object[] value = new Object[] {0L, new String[] {"hello", "world"}}; CompletableFuture testResponse = new CompletableFuture<>(); @@ -9061,11 +9060,11 @@ public void zscan_with_options_returns_success() { // match on protobuf request when(commandManager.submitNewCommand(eq(ZScan), eq(arguments), any())) - .thenReturn(testResponse); + .thenReturn(testResponse); // exercise CompletableFuture response = - service.zscan(key, cursor, ZScanOptions.builder().matchPattern("*").count(1L).build()); + service.zscan(key, cursor, ZScanOptions.builder().matchPattern("*").count(1L).build()); Object[] payload = response.get(); // verify diff --git a/java/integTest/src/test/java/glide/SharedCommandTests.java b/java/integTest/src/test/java/glide/SharedCommandTests.java index 3d29e2b751..fbb21720cd 100644 --- a/java/integTest/src/test/java/glide/SharedCommandTests.java +++ b/java/integTest/src/test/java/glide/SharedCommandTests.java @@ -7131,12 +7131,12 @@ public void zscan(BaseClient client) { // Setup test data Map numberMap = new HashMap<>(); - for(Double i = 0.0; i < 125; i ++) { + for (Double i = 0.0; i < 125; i++) { numberMap.put(String.valueOf(i), i); } String[] charMembers = new String[] {"a", "b", "c", "d", "e"}; Map charMap = new HashMap<>(); - for(Double i = 0.0; i < 5; i ++) { + for (Double i = 0.0; i < 5; i++) { charMap.put(charMembers[i.intValue()], i); } @@ -7154,13 +7154,19 @@ public void zscan(BaseClient client) { assertEquals(charMembers.length, client.zadd(key1, charMap).get()); result = client.zscan(key1, initialCursor).get(); assertEquals(String.valueOf(initialCursor), result[resultCursorIndex]); - assertEquals(charMap.size() * 2, ((Object[]) result[resultCollectionIndex]).length); // Length includes the score which is twice the map size + assertEquals( + charMap.size() * 2, + ((Object[]) result[resultCollectionIndex]) + .length); // Length includes the score which is twice the map size Arrays.stream((Object[]) result[resultCollectionIndex]) - .forEach(member -> - assertTrue(charMap.containsKey(member) || charMap.containsValue(Double.valueOf(member.toString())))); + .forEach( + member -> + assertTrue( + charMap.containsKey(member) + || charMap.containsValue(Double.valueOf(member.toString())))); result = - client.zscan(key1, initialCursor, ZScanOptions.builder().matchPattern("a").build()).get(); + client.zscan(key1, initialCursor, ZScanOptions.builder().matchPattern("a").build()).get(); assertEquals(String.valueOf(initialCursor), result[resultCursorIndex]); assertDeepEquals(new String[] {"a", "0"}, result[resultCollectionIndex]); @@ -7177,14 +7183,14 @@ public void zscan(BaseClient client) { assertTrue(resultCursor != newResultCursor); resultCursor = newResultCursor; assertFalse( - Arrays.deepEquals( - ArrayUtils.toArray(result[resultCollectionIndex]), - ArrayUtils.toArray(secondResult[resultCollectionIndex]))); + Arrays.deepEquals( + ArrayUtils.toArray(result[resultCollectionIndex]), + ArrayUtils.toArray(secondResult[resultCollectionIndex]))); } while (resultCursor != 0); // 0 is returned for the cursor of the last iteration. // Test match pattern result = - client.zscan(key1, initialCursor, ZScanOptions.builder().matchPattern("*").build()).get(); + client.zscan(key1, initialCursor, ZScanOptions.builder().matchPattern("*").build()).get(); assertTrue(Long.valueOf(result[resultCursorIndex].toString()) > 0); assertTrue(ArrayUtils.getLength(result[resultCollectionIndex]) >= defaultCount); @@ -7195,10 +7201,10 @@ public void zscan(BaseClient client) { // Test count with match returns a non-empty list result = - client - .zscan( - key1, initialCursor, ZScanOptions.builder().matchPattern("1*").count(20L).build()) - .get(); + client + .zscan( + key1, initialCursor, ZScanOptions.builder().matchPattern("1*").count(20L).build()) + .get(); assertTrue(Long.valueOf(result[resultCursorIndex].toString()) > 0); assertTrue(ArrayUtils.getLength(result[resultCollectionIndex]) > 0); @@ -7206,26 +7212,26 @@ public void zscan(BaseClient client) { // Non-set key assertEquals(OK, client.set(key2, "test").get()); ExecutionException executionException = - assertThrows(ExecutionException.class, () -> client.zscan(key2, initialCursor).get()); + assertThrows(ExecutionException.class, () -> client.zscan(key2, initialCursor).get()); assertInstanceOf(RequestException.class, executionException.getCause()); executionException = - assertThrows( - ExecutionException.class, - () -> - client - .zscan( - key2, - initialCursor, - ZScanOptions.builder().matchPattern("test").count(1L).build()) - .get()); + assertThrows( + ExecutionException.class, + () -> + client + .zscan( + key2, + initialCursor, + ZScanOptions.builder().matchPattern("test").count(1L).build()) + .get()); assertInstanceOf(RequestException.class, executionException.getCause()); // Negative count executionException = - assertThrows( - ExecutionException.class, - () -> client.zscan(key1, -1, ZScanOptions.builder().count(-1L).build()).get()); + assertThrows( + ExecutionException.class, + () -> client.zscan(key1, -1, ZScanOptions.builder().count(-1L).build()).get()); assertInstanceOf(RequestException.class, executionException.getCause()); } } diff --git a/java/integTest/src/test/java/glide/TransactionTestUtilities.java b/java/integTest/src/test/java/glide/TransactionTestUtilities.java index 0416cc1092..e7d447fbc8 100644 --- a/java/integTest/src/test/java/glide/TransactionTestUtilities.java +++ b/java/integTest/src/test/java/glide/TransactionTestUtilities.java @@ -687,7 +687,9 @@ private static Object[] sortedSetCommands(BaseTransaction transaction) { new String[] {"one"}, // .zrandmemberWithCount(zSetKey2, 1) new Object[][] {{"one", 1.0}}, // .zrandmemberWithCountWithScores(zSetKey2, 1); new Object[] {"0", new Object[] {"one", "1"}}, // zscan(zSetKey2, 0) - new Object[] {"0", new Object[] {"one", "1"}}, // zscan(zSetKey2, 0, ZScanOptions.builder().count(20L).build()) + new Object[] { + "0", new Object[] {"one", "1"} + }, // zscan(zSetKey2, 0, ZScanOptions.builder().count(20L).build()) new Object[] {zSetKey2, "one", 1.0}, // bzpopmin(new String[] { zsetKey2 }, .1) };