Skip to content

Commit

Permalink
Fix JedisConnectionPipelineIntegrationTests and JedisConnectionTransa…
Browse files Browse the repository at this point in the history
…ctionIntegrationTests.

Closes spring-projects#2612
  • Loading branch information
jxblum committed Sep 19, 2023
1 parent 8255358 commit c639531
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2036,7 +2036,7 @@ void testZDiff() {
actual.add(connection.zAdd("otherset", 4, "James"));
actual.add(connection.zDiff("myset", "otherset"));
actual.add(connection.zDiffWithScores("myset", "otherset"));
verifyResults(Arrays.asList(new Object[] { true, true, true, true, true, Collections.singleton("Joe"),
verifyResults(Arrays.asList(new Object[] { true, true, true, true, true, Collections.singletonList("Joe"),
Collections.singleton(new DefaultStringTuple("Joe", 4)) }));
}

Expand Down Expand Up @@ -2065,9 +2065,10 @@ void testZInter() {
actual.add(connection.zAdd("otherset", 4, "James"));
actual.add(connection.zInter("myset", "otherset"));
actual.add(connection.zInterWithScores("myset", "otherset"));
verifyResults(Arrays.asList(new Object[] { true, true, true, true, true,
new LinkedHashSet<>(Arrays.asList("Bob", "James")),
new LinkedHashSet<>(Arrays.asList(new DefaultStringTuple("Bob", 3d), new DefaultStringTuple("James", 5))) }));

verifyResults(Arrays.asList(new Object[] { true, true, true, true, true, Arrays.asList("Bob", "James"),
new LinkedHashSet<>(Arrays.asList(new DefaultStringTuple("Bob", 3d),
new DefaultStringTuple("James", 5))) }));
}

@Test // GH-2042
Expand All @@ -2082,9 +2083,9 @@ void testZInterAggWeights() {
actual.add(connection.zInter("myset", "otherset"));
actual.add(connection.zInterWithScores(Aggregate.MAX, new int[] { 2, 3 }, "myset", "otherset"));

verifyResults(Arrays.asList(new Object[] { true, true, true, true, true,
new LinkedHashSet<>(Arrays.asList("Bob", "James")),
new LinkedHashSet<>(Arrays.asList(new DefaultStringTuple("Bob", 4d), new DefaultStringTuple("James", 12d))) }));
verifyResults(Arrays.asList(new Object[] { true, true, true, true, true, Arrays.asList("Bob", "James"),
new LinkedHashSet<>(Arrays.asList(new DefaultStringTuple("Bob", 4d),
new DefaultStringTuple("James", 12d))) }));
}

@Test
Expand Down Expand Up @@ -2374,15 +2375,16 @@ void testZUnion() {
actual.add(connection.zAdd("otherset", 4, "James"));
actual.add(connection.zUnion("myset", "otherset"));
actual.add(connection.zUnionWithScores("myset", "otherset"));
verifyResults(Arrays
.asList(new Object[] { true, true, true, true, true, new LinkedHashSet<>(Arrays.asList("Bob", "James", "Joe")),
new LinkedHashSet<>(Arrays.asList(new DefaultStringTuple("Bob", 3d), new DefaultStringTuple("James", 5),
new DefaultStringTuple("Joe", 4))) }));

verifyResults(Arrays.asList(new Object[] { true, true, true, true, true, Arrays.asList("Bob", "Joe", "James"),
new LinkedHashSet<>(Arrays.asList(new DefaultStringTuple("Bob", 3d),
new DefaultStringTuple("Joe", 4), new DefaultStringTuple("James", 5))) }));
}

@Test // GH-2042
@EnabledOnCommand("ZUNION")
void testZUnionAggWeights() {

actual.add(connection.zAdd("myset", 2, "Bob"));
actual.add(connection.zAdd("myset", 1, "James"));
actual.add(connection.zAdd("myset", 4, "Joe"));
Expand All @@ -2391,9 +2393,9 @@ void testZUnionAggWeights() {
actual.add(connection.zUnion("myset", "otherset"));
actual.add(connection.zUnionWithScores(Aggregate.MAX, new int[] { 2, 3 }, "myset", "otherset"));

verifyResults(Arrays
.asList(new Object[] { true, true, true, true, true, new LinkedHashSet<>(Arrays.asList("Bob", "James", "Joe")),
new LinkedHashSet<>(Arrays.asList(new DefaultStringTuple("Bob", 4d), new DefaultStringTuple("Joe", 8d),
verifyResults(Arrays.asList(new Object[] { true, true, true, true, true, Arrays.asList("Bob", "Joe", "James"),
new LinkedHashSet<>(Arrays.asList(new DefaultStringTuple("Bob", 4d),
new DefaultStringTuple("Joe", 8d),
new DefaultStringTuple("James", 12d))) }));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -167,12 +168,17 @@ protected void initConnection() {

@Override
protected void verifyResults(List<Object> expected) {

List<Object> expectedPipeline = new ArrayList<>();
for (int i = 0; i < actual.size(); i++) {

for (int index = 0; index < actual.size(); index++) {
expectedPipeline.add(null);
}

assertThat(actual).isEqualTo(expectedPipeline);

List<Object> results = getResults();

assertThat(results).isEqualTo(expected);
}

Expand Down

0 comments on commit c639531

Please sign in to comment.