Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand committed Jan 11, 2025
1 parent 5c0f57e commit ee90fca
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 21 deletions.
38 changes: 29 additions & 9 deletions java/integTest/src/test/java/glide/SharedCommandTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -12719,9 +12719,15 @@ public void sort_with_pattern_binary(BaseClient client) {
assumeTrue(SERVER_VERSION.isGreaterThanOrEqualTo("8.0.0"), "This feature added in version 8");
}

String prefix = "{" + UUID.randomUUID() + "}-";
GlideString listKey = gs(prefix + "listKey");
GlideString storeKey = gs(prefix + "storeKey");
var prefix = UUID.randomUUID();
GlideString setKey1 = gs("{" + prefix + "}1");
GlideString setKey2 = gs("{" + prefix + "}2");
GlideString setKey3 = gs("{" + prefix + "}3");
GlideString setKey4 = gs("{" + prefix + "}4");
GlideString setKey5 = gs("{" + prefix + "}5");
GlideString[] setKeys = new GlideString[] {setKey1, setKey2, setKey3, setKey4, setKey5};
GlideString listKey = gs("{" + prefix + "}listKey");
GlideString storeKey = gs("{" + prefix + "}storeKey");
GlideString nameField = gs("name");
GlideString ageField = gs("age");
GlideString[] names =
Expand All @@ -12731,14 +12737,22 @@ public void sort_with_pattern_binary(BaseClient client) {
new GlideString[] {gs("Dave"), gs("Bob"), gs("Alice"), gs("Charlie"), gs("Eve")};
GlideString[] ages = new GlideString[] {gs("30"), gs("25"), gs("35"), gs("20"), gs("40")};
GlideString[] userIDs = new GlideString[] {gs("3"), gs("1"), gs("5"), gs("4"), gs("2")};
GlideString namePattern = gs(prefix + "*->name");
GlideString agePattern = gs(prefix + "*->age");
GlideString namePattern = gs("{" + prefix + "}*->name");
GlideString agePattern = gs("{" + prefix + "}*->age");
GlideString missingListKey = gs("100000");

for (int i = 0; i < names.length; i++) {
for (int i = 0; i < setKeys.length; i++) {
assertEquals(
2,
client.hset(gs(prefix + (i + 1)), Map.of(nameField, names[i], ageField, ages[i])).get());
client
.hset(
setKeys[i].toString(),
Map.of(
nameField.toString(),
names[i].toString(),
ageField.toString(),
ages[i].toString()))
.get());
}

assertEquals(5, client.rpush(listKey, userIDs).get());
Expand Down Expand Up @@ -12788,7 +12802,10 @@ public void sort_with_pattern_binary(BaseClient client) {
client
.sort(
listKey,
SortOptionsBinary.builder().alpha().getPattern(gs("{setKeyGs}missing")).build())
SortOptionsBinary.builder()
.alpha()
.getPattern(gs("{" + prefix + "}missing"))
.build())
.get());

// Missing key in the set
Expand Down Expand Up @@ -12851,7 +12868,10 @@ public void sort_with_pattern_binary(BaseClient client) {
client
.sortReadOnly(
listKey,
SortOptionsBinary.builder().alpha().getPattern(gs("{setKeyGs}missing")).build())
SortOptionsBinary.builder()
.alpha()
.getPattern(gs("{" + prefix + "}missing"))
.build())
.get());

assertArrayEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,13 @@ public void spublish(GlideClusterClient clusterClient) {
@MethodSource("getClients")
@SneakyThrows
public void sort(GlideClusterClient clusterClient) {
String key1 = "{key}:1" + UUID.randomUUID();
String key2 = "{key}:2" + UUID.randomUUID();
String key3 = "{key}:3" + UUID.randomUUID();
String key4 = "{key}:4" + UUID.randomUUID();
String key5 = "{key}:5" + UUID.randomUUID();
String key6 = "{key}:6" + UUID.randomUUID();
var prefix = "{" + UUID.randomUUID() + "}:";
String key1 = prefix + "1";
String key2 = prefix + "2";
String key3 = prefix + "3";
String key4 = prefix + "4";
String key5 = prefix + "5";
String key6 = prefix + "6";
String[] descendingList = new String[] {"3", "2", "1"};
ClusterTransaction transaction = new ClusterTransaction();
String[] ascendingListByAge = new String[] {"Bob", "Alice"};
Expand All @@ -348,26 +349,32 @@ public void sort(GlideClusterClient clusterClient) {
.lpush(key5, new String[] {"4", "3"})
.sort(
key5,
SortOptions.builder().byPattern("{key}:*->age").getPattern("{key}:*->name").build())
SortOptions.builder()
.byPattern(prefix + "*->age")
.getPattern(prefix + "*->name")
.build())
.sort(
key5,
SortOptions.builder()
.orderBy(DESC)
.byPattern("{key}:*->age")
.getPattern("{key}:*->name")
.byPattern(prefix + "*->age")
.getPattern(prefix + "*->name")
.build())
.sortStore(
key5,
key6,
SortOptions.builder().byPattern("{key}:*->age").getPattern("{key}:*->name").build())
SortOptions.builder()
.byPattern(prefix + "*->age")
.getPattern(prefix + "*->name")
.build())
.lrange(key6, 0, -1)
.sortStore(
key5,
key6,
SortOptions.builder()
.orderBy(DESC)
.byPattern("{key}:*->age")
.getPattern("{key}:*->name")
.byPattern(prefix + "*->age")
.getPattern(prefix + "*->name")
.build())
.lrange(key6, 0, -1);
}
Expand Down

0 comments on commit ee90fca

Please sign in to comment.