-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
XAddOptions
maxlen handling and XPendingOptions
validation.
- Loading branch information
1 parent
b68dd6e
commit c16c840
Showing
5 changed files
with
104 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/test/java/org/springframework/data/redis/connection/ReactiveStreamCommandsUnitTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.springframework.data.redis.connection; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.data.domain.Range; | ||
import org.springframework.data.redis.connection.ReactiveStreamCommands.PendingRecordsCommand; | ||
|
||
/** | ||
* Unit tests for {@link ReactiveStreamCommands}. | ||
* | ||
* @author jinkshower | ||
*/ | ||
class ReactiveStreamCommandsUnitTests { | ||
|
||
@Test // GH-2982 | ||
void pendingRecordsCommandRangeShouldThrowExceptionWhenRangeIsNull() { | ||
|
||
ByteBuffer key = ByteBuffer.wrap("my-stream".getBytes()); | ||
String groupName = "my-group"; | ||
|
||
PendingRecordsCommand command = PendingRecordsCommand.pending(key, groupName); | ||
|
||
assertThatThrownBy(() -> command.range(null, 10L)).isInstanceOf(IllegalArgumentException.class); | ||
} | ||
|
||
@Test // GH-2982 | ||
void pendingRecordsCommandRangeShouldThrowExceptionWhenCountIsNegative() { | ||
|
||
ByteBuffer key = ByteBuffer.wrap("my-stream".getBytes()); | ||
String groupName = "my-group"; | ||
|
||
PendingRecordsCommand command = PendingRecordsCommand.pending(key, groupName); | ||
Range<?> range = Range.closed("0", "10"); | ||
|
||
assertThatThrownBy(() -> command.range(range, -1L)).isInstanceOf(IllegalArgumentException.class); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/java/org/springframework/data/redis/connection/RedisStreamCommandsUnitTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.springframework.data.redis.connection; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.data.domain.Range; | ||
import org.springframework.data.redis.connection.RedisStreamCommands.XPendingOptions; | ||
|
||
/** | ||
* Unit tests for {@link RedisStreamCommands}. | ||
* | ||
* @author jinkshower | ||
*/ | ||
class RedisStreamCommandsUnitTests { | ||
|
||
@Test // GH-2982 | ||
void xPendingOptionsUnboundedShouldThrowExceptionWhenCountIsNegative() { | ||
|
||
assertThatThrownBy(() -> XPendingOptions.unbounded(-1L)).isInstanceOf(IllegalArgumentException.class); | ||
} | ||
|
||
@Test // GH-2982 | ||
void xPendingOptionsRangeShouldThrowExceptionWhenRangeIsNull() { | ||
|
||
assertThatThrownBy(() -> XPendingOptions.range(null, 10L)).isInstanceOf(IllegalArgumentException.class); | ||
} | ||
|
||
@Test // GH-2982 | ||
void xPendingOptionsRangeShouldThrowExceptionWhenCountIsNegative() { | ||
|
||
Range<?> range = Range.closed("0", "10"); | ||
|
||
assertThatThrownBy(() -> XPendingOptions.range(range, -1L)).isInstanceOf(IllegalArgumentException.class); | ||
} | ||
} |