DATAREDIS-972 - Polishing.

Add author tags. Reformat code. Split test for exceptions into two methods.

Original pull request: #448.
This commit is contained in:
Mark Paluch
2019-04-29 12:18:27 +02:00
parent 051b1ee820
commit e0a059f96b
2 changed files with 25 additions and 9 deletions

View File

@@ -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);
}
}