From e0a059f96bd4f3e90bfb07e0bdf8a8e1981637b5 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 29 Apr 2019 12:18:27 +0200 Subject: [PATCH] DATAREDIS-972 - Polishing. Add author tags. Reformat code. Split test for exceptions into two methods. Original pull request: #448. --- .../data/redis/core/RedisCommand.java | 6 ++-- .../redis/core/RedisCommandUnitTests.java | 28 ++++++++++++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/springframework/data/redis/core/RedisCommand.java b/src/main/java/org/springframework/data/redis/core/RedisCommand.java index 1d0e9e283..751c0169b 100644 --- a/src/main/java/org/springframework/data/redis/core/RedisCommand.java +++ b/src/main/java/org/springframework/data/redis/core/RedisCommand.java @@ -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 Redis + * command list */ public enum RedisCommand { // -- A diff --git a/src/test/java/org/springframework/data/redis/core/RedisCommandUnitTests.java b/src/test/java/org/springframework/data/redis/core/RedisCommandUnitTests.java index 48c1edf09..163517ff2 100644 --- a/src/test/java/org/springframework/data/redis/core/RedisCommandUnitTests.java +++ b/src/test/java/org/springframework/data/redis/core/RedisCommandUnitTests.java @@ -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); } }