DATAREDIS-972 - Polishing.
Add author tags. Reformat code. Split test for exceptions into two methods. Original pull request: #448.
This commit is contained in:
@@ -29,9 +29,11 @@ import org.springframework.util.StringUtils;
|
||||
* @author Thomas Darimont
|
||||
* @author Ninad Divadkar
|
||||
* @author Mark Paluch
|
||||
* @author Oscar Cai
|
||||
* @since 1.3
|
||||
* @see Redis command list:
|
||||
* https://github.com/antirez/redis/blob/93e7a130fc9594e41ccfc996b5eca7626ae5356a/src/redis.c#L119
|
||||
* @link <a href=
|
||||
* "https://github.com/antirez/redis/blob/843de8b786562d8d77c78d83a971060adc61f77a/src/server.c#L180">Redis
|
||||
* command list</a>
|
||||
*/
|
||||
public enum RedisCommand {
|
||||
// -- A
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.junit.rules.ExpectedException;
|
||||
* @author Christoph Strobl
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
* @author Oscar Cai
|
||||
*/
|
||||
public class RedisCommandUnitTests {
|
||||
|
||||
@@ -63,17 +64,19 @@ public class RedisCommandUnitTests {
|
||||
assertThat(RedisCommand.failsafeCommandLookup("strangecommand"), is(RedisCommand.UNKNOWN));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-73
|
||||
@Test // DATAREDIS-73, DATAREDIS-972
|
||||
public void shouldNotThrowExceptionOnValidArgumentCount() {
|
||||
|
||||
RedisCommand.AUTH.validateArgumentCount(1);
|
||||
RedisCommand.ZADD.validateArgumentCount(3); // DATAREDIS-972
|
||||
RedisCommand.ZADD.validateArgumentCount(4); // DATAREDIS-972
|
||||
RedisCommand.ZADD.validateArgumentCount(5); // DATAREDIS-972
|
||||
RedisCommand.ZADD.validateArgumentCount(100); // DATAREDIS-972
|
||||
RedisCommand.ZADD.validateArgumentCount(3);
|
||||
RedisCommand.ZADD.validateArgumentCount(4);
|
||||
RedisCommand.ZADD.validateArgumentCount(5);
|
||||
RedisCommand.ZADD.validateArgumentCount(100);
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-822
|
||||
public void shouldConsiderMinMaxArguments() {
|
||||
|
||||
RedisCommand.BITPOS.validateArgumentCount(2);
|
||||
RedisCommand.BITPOS.validateArgumentCount(3);
|
||||
RedisCommand.BITPOS.validateArgumentCount(4);
|
||||
@@ -81,26 +84,37 @@ public class RedisCommandUnitTests {
|
||||
|
||||
@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 shouldThrowExceptionOnInvalidArgumentCountWhenExpectedExactMatch() {
|
||||
|
||||
expectedException.expect(IllegalArgumentException.class);
|
||||
expectedException.expectMessage("AUTH command requires 1 arguments");
|
||||
|
||||
RedisCommand.AUTH.validateArgumentCount(2);
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-73
|
||||
public void shouldThrowExceptionOnInvalidArgumentCountWhenExpectedMinimalMatch() {
|
||||
public void shouldThrowExceptionOnInvalidArgumentCountForDelWhenExpectedMinimalMatch() {
|
||||
|
||||
expectedException.expect(IllegalArgumentException.class);
|
||||
expectedException.expectMessage("DEL command requires at least 1 arguments");
|
||||
|
||||
RedisCommand.DEL.validateArgumentCount(0);
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-972
|
||||
public void shouldThrowExceptionOnInvalidArgumentCountForZaddWhenExpectedMinimalMatch() {
|
||||
|
||||
expectedException.expect(IllegalArgumentException.class);
|
||||
expectedException.expectMessage("ZADD command requires at least 3 arguments");
|
||||
RedisCommand.ZADD.validateArgumentCount(2); // DATAREDIS-972
|
||||
|
||||
RedisCommand.ZADD.validateArgumentCount(2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user