Skip to content

Commit

Permalink
Move to 2D string array in response
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <andrew.carbonetto@improving.com>
  • Loading branch information
acarbonetto committed Jun 30, 2024
1 parent 9249705 commit 2b9f3a5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions glide-core/src/client/value_conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ pub(crate) fn expected_type_for_cmd(cmd: &Cmd) -> Option<ExpectedReturnType> {
} else {
Some(ExpectedReturnType::Map {
key_type: &Some(ExpectedReturnType::SimpleString),
value_type: &Some(ExpectedReturnType::ArrayOfStrings),
value_type: &Some(ExpectedReturnType::ArrayOfPairs),
})
}
}
Expand Down Expand Up @@ -1205,7 +1205,7 @@ mod tests {
),
Some(ExpectedReturnType::Map {
key_type: &Some(ExpectedReturnType::SimpleString),
value_type: &Some(ExpectedReturnType::ArrayOfStrings),
value_type: &Some(ExpectedReturnType::ArrayOfPairs),
})
));
assert!(matches!(
Expand Down
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 @@ -2005,7 +2005,7 @@ public CompletableFuture<Object[][]> xpending(
}

@Override
public CompletableFuture<Map<String, String[]>> xclaim(
public CompletableFuture<Map<String, String[][]>> xclaim(
@NonNull String key,
@NonNull String group,
@NonNull String consumer,
Expand All @@ -2017,7 +2017,7 @@ public CompletableFuture<Map<String, String[]>> xclaim(
}

@Override
public CompletableFuture<Map<String, String[]>> xclaim(
public CompletableFuture<Map<String, String[][]>> xclaim(
@NonNull String key,
@NonNull String group,
@NonNull String consumer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ CompletableFuture<Object[][]> xpending(
* }
* </pre>
*/
CompletableFuture<Map<String, String[]>> xclaim(
CompletableFuture<Map<String, String[][]>> xclaim(
String key, String group, String consumer, long minIdleTime, String[] ids);

/**
Expand Down Expand Up @@ -727,7 +727,7 @@ CompletableFuture<Map<String, String[]>> xclaim(
* }
* </pre>
*/
CompletableFuture<Map<String, String[]>> xclaim(
CompletableFuture<Map<String, String[][]>> xclaim(
String key,
String group,
String consumer,
Expand Down
20 changes: 10 additions & 10 deletions java/client/src/test/java/glide/api/RedisClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5805,19 +5805,19 @@ public void xclaim_returns_success() {
Long minIdleTime = 18L;
String[] ids = new String[] {"testId"};
String[] arguments = concatenateArrays(new String[] {key, groupName, consumer, "18"}, ids);
Map<String, String[]> mockResult = Map.of("1234-0", new String[] {"message", "log"});
Map<String, String[][]> mockResult = Map.of("1234-0", new String[][] {{"message", "log"}});

CompletableFuture<Map<String, String[]>> testResponse = new CompletableFuture<>();
CompletableFuture<Map<String, String[][]>> testResponse = new CompletableFuture<>();
testResponse.complete(mockResult);

// match on protobuf request
when(commandManager.<Map<String, String[]>>submitNewCommand(eq(XClaim), eq(arguments), any()))
when(commandManager.<Map<String, String[][]>>submitNewCommand(eq(XClaim), eq(arguments), any()))
.thenReturn(testResponse);

// exercise
CompletableFuture<Map<String, String[]>> response =
CompletableFuture<Map<String, String[][]>> response =
service.xclaim(key, groupName, consumer, minIdleTime, ids);
Map<String, String[]> payload = response.get();
Map<String, String[][]> payload = response.get();

// verify
assertEquals(testResponse, response);
Expand Down Expand Up @@ -5850,19 +5850,19 @@ public void xclaim_with_options_returns_success() {
"5",
FORCE_REDIS_API
};
Map<String, String[]> mockResult = Map.of("1234-0", new String[] {"message", "log"});
Map<String, String[][]> mockResult = Map.of("1234-0", new String[][] {{"message", "log"}});

CompletableFuture<Map<String, String[]>> testResponse = new CompletableFuture<>();
CompletableFuture<Map<String, String[][]>> testResponse = new CompletableFuture<>();
testResponse.complete(mockResult);

// match on protobuf request
when(commandManager.<Map<String, String[]>>submitNewCommand(eq(XClaim), eq(arguments), any()))
when(commandManager.<Map<String, String[][]>>submitNewCommand(eq(XClaim), eq(arguments), any()))
.thenReturn(testResponse);

// exercise
CompletableFuture<Map<String, String[]>> response =
CompletableFuture<Map<String, String[][]>> response =
service.xclaim(key, groupName, consumer, minIdleTime, ids, options);
Map<String, String[]> payload = response.get();
Map<String, String[][]> payload = response.get();

// verify
assertEquals(testResponse, response);
Expand Down
6 changes: 3 additions & 3 deletions java/integTest/src/test/java/glide/SharedCommandTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -4399,9 +4399,9 @@ public void xpending_xclaim(BaseClient client) {
assertDeepEquals(
Map.of(
streamid_3,
new String[] {"field3", "value3"},
new String[][] {{"field3", "value3"}},
streamid_5,
new String[] {"field5", "value5"}),
new String[][] {{"field5", "value5"}}),
claimResults);

var claimResultsJustId =
Expand All @@ -4425,7 +4425,7 @@ public void xpending_xclaim(BaseClient client) {
new String[] {streamid_6},
StreamClaimOptions.builder().force().retryCount(99L).build())
.get();
assertDeepEquals(Map.of(streamid_6, new String[] {"field6", "value6"}), claimForceResults);
assertDeepEquals(Map.of(streamid_6, new String[][] {{"field6", "value6"}}), claimForceResults);

Object[][] forcePendingResults =
client.xpending(key, groupName, IdBound.of(streamid_6), IdBound.of(streamid_6), 1L).get();
Expand Down

0 comments on commit 2b9f3a5

Please sign in to comment.