DATAREDIS-1207 - Fix LettuceStreamCommands.xPending Range conversion..

Original Pull Request: #556
This commit is contained in:
Christoph Strobl
2020-09-01 13:00:22 +02:00
parent df2b8b175c
commit ac16d4bb3f
2 changed files with 24 additions and 1 deletions

View File

@@ -441,7 +441,7 @@ class LettuceStreamCommands implements RedisStreamCommands {
public PendingMessages xPending(byte[] key, String groupName, XPendingOptions options) {
byte[] group = LettuceConverters.toBytes(groupName);
io.lettuce.core.Range<String> range = RangeConverter.toRangeWithDefault(options.getRange(), "-", "+");
io.lettuce.core.Range<String> range = RangeConverter.toRangeWithDefault(options.getRange(), "-", "+", Function.identity());
io.lettuce.core.Limit limit = options.isLimited() ? io.lettuce.core.Limit.from(options.getCount())
: io.lettuce.core.Limit.unlimited();

View File

@@ -3212,6 +3212,29 @@ public abstract class AbstractConnectionIntegrationTests {
assertThat(pending.get(0).getIdAsString()).isNotNull();
}
@Test // DATAREDIS-1207
@IfProfileValue(name = "redisVersion", value = "5.0")
@WithRedisDriver({ RedisDriver.LETTUCE })
public void xPendingShouldWorkWithBoundedRange() {
actual.add(connection.xAdd(KEY_1, Collections.singletonMap(KEY_2, VALUE_2)));
actual.add(connection.xGroupCreate(KEY_1, ReadOffset.from("0"), "my-group"));
actual.add(connection.xReadGroupAsString(Consumer.from("my-group", "my-consumer"),
StreamOffset.create(KEY_1, ReadOffset.lastConsumed())));
actual.add(connection.xPending(KEY_1, "my-group", org.springframework.data.domain.Range.open("0-0", "+"), 10L));
List<Object> results = getResults();
assertThat(results).hasSize(4);
PendingMessages pending = (PendingMessages) results.get(3);
assertThat(pending.size()).isOne();
assertThat(pending.get(0).getConsumerName()).isEqualTo("my-consumer");
assertThat(pending.get(0).getGroupName()).isEqualTo("my-group");
assertThat(pending.get(0).getTotalDeliveryCount()).isOne();
assertThat(pending.get(0).getIdAsString()).isNotNull();
}
@Test // DATAREDIS-1084
@IfProfileValue(name = "redisVersion", value = "5.0")
@WithRedisDriver({ RedisDriver.LETTUCE })