34
34
import org .springframework .data .redis .connection .jedis .extension .JedisConnectionFactoryExtension ;
35
35
import org .springframework .data .redis .connection .lettuce .LettuceConnectionFactory ;
36
36
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 ;
37
+ import org .springframework .data .redis .connection .stream .*;
47
38
import org .springframework .data .redis .test .condition .EnabledOnCommand ;
48
39
import org .springframework .data .redis .test .condition .EnabledOnRedisDriver ;
40
+ import org .springframework .data .redis .test .condition .EnabledOnRedisVersion ;
49
41
import org .springframework .data .redis .test .condition .RedisDetector ;
50
42
import org .springframework .data .redis .test .extension .RedisCluster ;
51
43
import org .springframework .data .redis .test .extension .RedisStanalone ;
@@ -198,6 +190,28 @@ void rangeShouldReportMessages() {
198
190
assertThat (message .getId ()).isEqualTo (messageId1 );
199
191
}
200
192
193
+ @ ParameterizedRedisTest // GH-2044
194
+ @ EnabledOnRedisVersion ("6.2" )
195
+ void exclusiveRangeShouldReportMessages () {
196
+
197
+ K key = keyFactory .instance ();
198
+ HK hashKey = hashKeyFactory .instance ();
199
+ HV value = hashValueFactory .instance ();
200
+
201
+ RecordId messageId1 = streamOps .add (key , Collections .singletonMap (hashKey , value ));
202
+ RecordId messageId2 = streamOps .add (key , Collections .singletonMap (hashKey , value ));
203
+
204
+ List <MapRecord <K , HK , HV >> messages = streamOps .range (key ,
205
+ Range .from (Bound .exclusive (messageId1 .getValue ())).to (Bound .inclusive (messageId2 .getValue ())));
206
+
207
+ assertThat (messages ).hasSize (1 ).extracting (Record ::getId ).contains (messageId2 );
208
+
209
+ messages = streamOps .range (key ,
210
+ Range .from (Bound .inclusive (messageId1 .getValue ())).to (Bound .exclusive (messageId2 .getValue ())));
211
+
212
+ assertThat (messages ).hasSize (1 ).extracting (Record ::getId ).contains (messageId1 );
213
+ }
214
+
201
215
@ ParameterizedRedisTest // DATAREDIS-864
202
216
void reverseRangeShouldReportMessages () {
203
217
@@ -213,6 +227,29 @@ void reverseRangeShouldReportMessages() {
213
227
assertThat (messages ).hasSize (2 ).extracting ("id" ).containsSequence (messageId2 , messageId1 );
214
228
}
215
229
230
+ @ ParameterizedRedisTest // GH-2044
231
+ @ EnabledOnRedisVersion ("6.2" )
232
+ void exclusiveReverseRangeShouldReportMessages () {
233
+
234
+ K key = keyFactory .instance ();
235
+ HK hashKey = hashKeyFactory .instance ();
236
+ HV value = hashValueFactory .instance ();
237
+
238
+ RecordId messageId1 = streamOps .add (key , Collections .singletonMap (hashKey , value ));
239
+ RecordId messageId2 = streamOps .add (key , Collections .singletonMap (hashKey , value ));
240
+ RecordId messageId3 = streamOps .add (key , Collections .singletonMap (hashKey , value ));
241
+
242
+ List <MapRecord <K , HK , HV >> messages = streamOps .reverseRange (key ,
243
+ Range .from (Bound .exclusive (messageId1 .getValue ())).to (Bound .inclusive (messageId3 .getValue ())));
244
+
245
+ assertThat (messages ).hasSize (2 ).extracting (Record ::getId ).containsSequence (messageId3 , messageId2 );
246
+
247
+ messages = streamOps .reverseRange (key ,
248
+ Range .from (Bound .inclusive (messageId1 .getValue ())).to (Bound .exclusive (messageId3 .getValue ())));
249
+
250
+ assertThat (messages ).hasSize (2 ).extracting (Record ::getId ).containsSequence (messageId2 , messageId1 );
251
+ }
252
+
216
253
@ ParameterizedRedisTest // DATAREDIS-864
217
254
void reverseRangeShouldConvertSimpleMessages () {
218
255
0 commit comments