Skip to content

Commit 5d4866a

Browse files
viktoriya-kutsarovamp911de
authored andcommitted
Fix HGETDEL, HGETEX and HSETEX pipeline and transaction integration tests.
Signed-off-by: viktoriya.kutsarova <viktoriya.kutsarova@redis.com> Closes #3246
1 parent 43b9370 commit 5d4866a

File tree

1 file changed

+29
-34
lines changed

1 file changed

+29
-34
lines changed

src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3729,62 +3729,57 @@ public void hTtlReturnsMinusTwoWhenFieldOrKeyMissing() {
37293729
@EnabledOnCommand("HGETDEL")
37303730
public void hGetDelWorksAsExpected() {
37313731

3732-
connection.hSet("hash-hgetdel", "field-1", "value-1");
3733-
connection.hSet("hash-hgetdel", "field-2", "value-2");
3734-
connection.hSet("hash-hgetdel", "field-3", "value-3");
3732+
actual.add(connection.hSet("hash-hgetdel", "field-1", "value-1"));
3733+
actual.add(connection.hSet("hash-hgetdel", "field-2", "value-2"));
3734+
actual.add(connection.hSet("hash-hgetdel", "field-3", "value-3"));
37353735

3736-
// hgetdel first 2 fields
3737-
assertThat(connection.hGetDel("hash-hgetdel", "field-1", "field-2")).containsExactly("value-1", "value-2");
3738-
assertThat(connection.hExists("hash-hgetdel", "field-1")).isFalse();
3739-
assertThat(connection.hExists("hash-hgetdel", "field-2")).isFalse();
3736+
actual.add(connection.hGetDel("hash-hgetdel", "field-1", "field-2"));
3737+
actual.add(connection.hExists("hash-hgetdel", "field-1"));
3738+
actual.add(connection.hExists("hash-hgetdel", "field-2"));
37403739

3741-
// hgetdel non-existent field returns null
3742-
assertThat(connection.hGetDel("hash-hgetdel", "field-1")).containsExactly(null);
3740+
actual.add(connection.hGetDel("hash-hgetdel", "field-1"));
37433741

3744-
// hgetdel last field
3745-
assertThat(connection.hGetDel("hash-hgetdel", "field-3")).containsExactly("value-3");
3746-
assertThat(connection.hExists("hash-hgetdel", "field-3")).isFalse();
3747-
assertThat(connection.exists("hash-hgetdel")).isFalse();
3742+
actual.add(connection.hGetDel("hash-hgetdel", "field-3"));
3743+
actual.add(connection.hExists("hash-hgetdel", "field-3"));
3744+
actual.add(connection.exists("hash-hgetdel"));
37483745

3749-
// hgetdel non-existent hash returns null
3750-
assertThat(connection.hGetDel("hash-hgetdel", "field-1")).containsExactly(null);
3746+
actual.add(connection.hGetDel("hash-hgetdel", "field-1"));
3747+
3748+
verifyResults(Arrays.asList(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE,
3749+
Arrays.asList("value-1", "value-2"), Boolean.FALSE, Boolean.FALSE,
3750+
Collections.singletonList(null), Arrays.asList("value-3"), Boolean.FALSE, Boolean.FALSE,
3751+
Collections.singletonList(null)));
37513752
}
37523753

37533754
@Test // GH-3211
37543755
@EnabledOnCommand("HGETEX")
3755-
@LongRunningTest
37563756
public void hGetExWorksAsExpected() {
37573757

3758-
connection.hSet("hash-hgetex", "field-1", "value-1");
3759-
connection.hSet("hash-hgetex", "field-2", "value-2");
3760-
connection.hSet("hash-hgetex", "field-3", "value-3");
3758+
actual.add(connection.hSet("hash-hgetex", "field-1", "value-1"));
3759+
actual.add(connection.hSet("hash-hgetex", "field-2", "value-2"));
3760+
actual.add(connection.hSet("hash-hgetex", "field-3", "value-3"));
37613761

3762-
assertThat(connection.hGetEx("hash-hgetex", Expiration.seconds(2), "field-1", "field-2")).containsExactly("value-1",
3763-
"value-2");
3762+
actual.add(connection.hGetEx("hash-hgetex", Expiration.seconds(2), "field-1", "field-2"));
37643763

3765-
// non-existent field returns null
3766-
assertThat(connection.hGetEx("hash-hgetex", null, "no-such-field")).containsExactly(null);
3764+
actual.add(connection.hGetEx("hash-hgetex", null, "no-such-field"));
37673765

3768-
// non-existent hash returns null
3769-
assertThat(connection.hGetEx("no-such-key", null, "field-1")).containsExactly(null);
3766+
actual.add(connection.hGetEx("no-such-key", null, "field-1"));
37703767

3771-
await().atMost(Duration.ofMillis(3000L))
3772-
.until(() -> !connection.hExists("hash-getex", "field-1") && !connection.hExists("hash-getex", "field-2"));
3768+
verifyResults(Arrays.asList(Boolean.TRUE, "value-1", "value-2"));
37733769
}
37743770

37753771
@Test // GH-3211
37763772
@EnabledOnCommand("HSETEX")
3777-
@LongRunningTest
37783773
public void hSetExWorksAsExpected() {
37793774

37803775
Map<String, String> fieldMap = Map.of("field-1", "value-1", "field-2", "value-2");
3781-
assertThat(connection.hSetEx("hash-hsetex", fieldMap, RedisHashCommands.HashFieldSetOption.upsert(),
3782-
Expiration.seconds(2))).isTrue();
3783-
assertThat(connection.hGet("hash-hsetex", "field-1")).isEqualTo("value-1");
3784-
assertThat(connection.hGet("hash-hsetex", "field-2")).isEqualTo("value-2");
3776+
actual.add(connection.hSetEx("hash-hsetex", fieldMap, RedisHashCommands.HashFieldSetOption.upsert(),
3777+
Expiration.seconds(30)));
3778+
actual.add(connection.hGet("hash-hsetex", "field-1"));
3779+
actual.add(connection.hGet("hash-hsetex", "field-2"));
37853780

3786-
await().atMost(Duration.ofMillis(3000L))
3787-
.until(() -> !connection.hExists("hash-getex", "field-1") && !connection.hExists("hash-getex", "field-2"));
3781+
verifyResults(Arrays.asList(Boolean.TRUE, Boolean.TRUE, Boolean.TRUE,
3782+
Arrays.asList("value-1", "value-2"), Collections.singletonList(null), Collections.singletonList(null)));
37883783
}
37893784

37903785
@Test // GH-3211

0 commit comments

Comments
 (0)