DATAREDIS-822 - Consider argument range in RedisCommand min/max arguments specification.

We now consider max argument specifications as upper bound and no longer as the exact number of required arguments.

Original pull request: #335.
This commit is contained in:
Mark Paluch
2018-05-02 11:31:30 +02:00
parent abb7d9f684
commit f8d63f4736
2 changed files with 29 additions and 3 deletions

View File

@@ -23,8 +23,11 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
/**
* Unit tests for {@link RedisCommand}.
*
* @author Christoph Strobl
* @author Thomas Darimont
* @author Mark Paluch
*/
public class RedisCommandUnitTests {
@@ -65,8 +68,25 @@ public class RedisCommandUnitTests {
RedisCommand.AUTH.validateArgumentCount(1);
}
@Test // DATAREDIS-822
public void shouldConsiderMinMaxArguments() {
RedisCommand.BITPOS.validateArgumentCount(2);
RedisCommand.BITPOS.validateArgumentCount(3);
RedisCommand.BITPOS.validateArgumentCount(4);
}
@Test // DATAREDIS-822
public void shouldReportArgumentMismatchIfMaxArgumentsExceeded() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("BITPOS command requires at most 4 arguments");
RedisCommand.BITPOS.validateArgumentCount(5);
}
@Test // DATAREDIS-73
public void shouldThrowExceptionOnInvalidArgumentCountWhenExpectedExcatMatch() {
public void shouldThrowExceptionOnInvalidArgumentCountWhenExpectedExactMatch() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("AUTH command requires 1 arguments");