3434import org .springframework .data .redis .connection .jedis .extension .JedisConnectionFactoryExtension ;
3535import org .springframework .data .redis .connection .lettuce .LettuceConnectionFactory ;
3636import 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 .*;
4738import org .springframework .data .redis .test .condition .EnabledOnCommand ;
4839import org .springframework .data .redis .test .condition .EnabledOnRedisDriver ;
40+ import org .springframework .data .redis .test .condition .EnabledOnRedisVersion ;
4941import org .springframework .data .redis .test .condition .RedisDetector ;
5042import org .springframework .data .redis .test .extension .RedisCluster ;
5143import org .springframework .data .redis .test .extension .RedisStanalone ;
@@ -198,6 +190,28 @@ void rangeShouldReportMessages() {
198190 assertThat (message .getId ()).isEqualTo (messageId1 );
199191 }
200192
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+
201215 @ ParameterizedRedisTest // DATAREDIS-864
202216 void reverseRangeShouldReportMessages () {
203217
@@ -213,6 +227,29 @@ void reverseRangeShouldReportMessages() {
213227 assertThat (messages ).hasSize (2 ).extracting ("id" ).containsSequence (messageId2 , messageId1 );
214228 }
215229
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+
216253 @ ParameterizedRedisTest // DATAREDIS-864
217254 void reverseRangeShouldConvertSimpleMessages () {
218255
0 commit comments