|
18 | 18 | import static org.assertj.core.api.Assertions.*;
|
19 | 19 | import static org.assertj.core.api.Assumptions.*;
|
20 | 20 |
|
| 21 | +import java.time.Duration; |
21 | 22 | import java.util.ArrayList;
|
22 | 23 | import java.util.Collection;
|
23 | 24 | import java.util.Collections;
|
|
34 | 35 | import org.springframework.data.redis.connection.jedis.extension.JedisConnectionFactoryExtension;
|
35 | 36 | import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
36 | 37 | import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension;
|
37 |
| -import org.springframework.data.redis.connection.stream.Consumer; |
38 |
| -import org.springframework.data.redis.connection.stream.MapRecord; |
39 |
| -import org.springframework.data.redis.connection.stream.ObjectRecord; |
40 |
| -import org.springframework.data.redis.connection.stream.PendingMessages; |
41 |
| -import org.springframework.data.redis.connection.stream.PendingMessagesSummary; |
42 |
| -import org.springframework.data.redis.connection.stream.ReadOffset; |
43 |
| -import org.springframework.data.redis.connection.stream.RecordId; |
44 |
| -import org.springframework.data.redis.connection.stream.StreamOffset; |
45 |
| -import org.springframework.data.redis.connection.stream.StreamReadOptions; |
46 |
| -import org.springframework.data.redis.connection.stream.StreamRecords; |
| 38 | +import org.springframework.data.redis.connection.stream.*; |
47 | 39 | import org.springframework.data.redis.test.condition.EnabledOnCommand;
|
48 | 40 | import org.springframework.data.redis.test.condition.EnabledOnRedisDriver;
|
49 | 41 | import org.springframework.data.redis.test.condition.EnabledOnRedisVersion;
|
@@ -72,7 +64,7 @@ public class DefaultStreamOperationsIntegrationTests<K, HK, HV> {
|
72 | 64 | private final StreamOperations<K, HK, HV> streamOps;
|
73 | 65 |
|
74 | 66 | public DefaultStreamOperationsIntegrationTests(RedisTemplate<K, ?> redisTemplate, ObjectFactory<K> keyFactory,
|
75 |
| - ObjectFactory<?> objectFactory) { |
| 67 | + ObjectFactory<?> objectFactory) { |
76 | 68 |
|
77 | 69 | this.redisTemplate = redisTemplate;
|
78 | 70 | this.connectionFactory = redisTemplate.getRequiredConnectionFactory();
|
@@ -420,4 +412,29 @@ void pendingShouldReadMessageDetails() {
|
420 | 412 | assertThat(pending.get(0).getConsumerName()).isEqualTo("my-consumer");
|
421 | 413 | assertThat(pending.get(0).getTotalDeliveryCount()).isOne();
|
422 | 414 | }
|
| 415 | + |
| 416 | + @ParameterizedRedisTest // https://github.com/spring-projects/spring-data-redis/issues/2465 |
| 417 | + void claimShouldReadMessageDetails() { |
| 418 | + |
| 419 | + K key = keyFactory.instance(); |
| 420 | + HK hashKey = hashKeyFactory.instance(); |
| 421 | + HV value = hashValueFactory.instance(); |
| 422 | + |
| 423 | + RecordId messageId = streamOps.add(key, Collections.singletonMap(hashKey, value)); |
| 424 | + streamOps.createGroup(key, ReadOffset.from("0-0"), "my-group"); |
| 425 | + streamOps.read(Consumer.from("my-group", "name"), StreamOffset.create(key, ReadOffset.lastConsumed())); |
| 426 | + |
| 427 | + List<MapRecord<K, HK, HV>> messages = streamOps.claim(key, "my-group", "new-owner", Duration.ZERO, messageId); |
| 428 | + |
| 429 | + assertThat(messages).hasSize(1); |
| 430 | + |
| 431 | + MapRecord<K, HK, HV> message = messages.get(0); |
| 432 | + |
| 433 | + assertThat(message.getId()).isEqualTo(messageId); |
| 434 | + assertThat(message.getStream()).isEqualTo(key); |
| 435 | + |
| 436 | + if (!(key instanceof byte[] || value instanceof byte[])) { |
| 437 | + assertThat(message.getValue()).containsEntry(hashKey, value); |
| 438 | + } |
| 439 | + } |
423 | 440 | }
|
0 commit comments