|
17 | 17 |
|
18 | 18 | import static org.assertj.core.api.Assertions.*;
|
19 | 19 |
|
20 | | -import java.util.Arrays; |
21 | | - |
22 | 20 | import org.junit.jupiter.api.Test;
|
| 21 | +import org.junit.jupiter.params.ParameterizedTest; |
| 22 | +import org.junit.jupiter.params.provider.EnumSource; |
| 23 | + |
23 | 24 | import org.springframework.test.util.ReflectionTestUtils;
|
24 | 25 |
|
25 | 26 | /**
|
@@ -106,37 +107,34 @@ void shouldThrowExceptionOnInvalidArgumentCountForZaddWhenExpectedMinimalMatch()
|
106 | 107 | .withMessageContaining("ZADD command requires at least 3 arguments");
|
107 | 108 | }
|
108 | 109 |
|
109 | | - @Test // GH-2644 |
110 | | - void isRepresentedByIsCorrectForAllCommandsAndTheirAliases() { |
111 | | - |
112 | | - for (RedisCommand command : RedisCommand.values()) { |
| 110 | + @ParameterizedTest(name = "{0}") // GH-2644 |
| 111 | + @EnumSource(RedisCommand.class) |
| 112 | + void isRepresentedByIsCorrectForAllCommandsAndTheirAliases(RedisCommand command) { |
113 | 113 |
|
114 | | - assertThat(command.isRepresentedBy(command.name())).isTrue(); |
115 | | - assertThat(command.isRepresentedBy(command.name().toLowerCase())).isTrue(); |
| 114 | + assertThat(command.isRepresentedBy(command.name())).isTrue(); |
| 115 | + assertThat(command.isRepresentedBy(command.name().toLowerCase())).isTrue(); |
116 | 116 |
|
117 | | - for (String alias : command.getAliases()) { |
118 | | - assertThat(command.isRepresentedBy(alias)).isTrue(); |
119 | | - assertThat(command.isRepresentedBy(alias.toUpperCase())).isTrue(); |
120 | | - } |
| 117 | + for (String alias : command.getAliases()) { |
| 118 | + assertThat(command.isRepresentedBy(alias)).isTrue(); |
| 119 | + assertThat(command.isRepresentedBy(alias.toUpperCase())).isTrue(); |
121 | 120 | }
|
122 | 121 | }
|
123 | 122 |
|
124 | | - @Test // GH-2646 |
125 | | - void commandRequiresArgumentsIsCorrect() { |
| 123 | + @ParameterizedTest(name = "{0}") // GH-2646 |
| 124 | + @EnumSource(RedisCommand.class) |
| 125 | + void commandRequiresArgumentsIsCorrect(RedisCommand command) { |
126 | 126 |
|
127 | | - Arrays.stream(RedisCommand.values()) |
128 | | - .forEach(command -> assertThat(command.requiresArguments()) |
129 | | - .describedAs("Redis command [%s] failed required arguments check", command) |
130 | | - .isEqualTo((int) ReflectionTestUtils.getField(command, "minArgs") > 0)); |
| 127 | + assertThat(command.requiresArguments()).describedAs("Redis command [%s] failed required arguments check", command) |
| 128 | + .isEqualTo((int) ReflectionTestUtils.getField(command, "minArgs") > 0); |
131 | 129 | }
|
132 | 130 |
|
133 | | - @Test // GH-2646 |
134 | | - void commandRequiresExactNumberOfArgumentsIsCorrect() { |
| 131 | + @ParameterizedTest(name = "{0}") // GH-2646 |
| 132 | + @EnumSource(RedisCommand.class) |
| 133 | + void commandRequiresExactNumberOfArgumentsIsCorrect(RedisCommand command) { |
135 | 134 |
|
136 | | - Arrays.stream(RedisCommand.values()) |
137 | | - .forEach(command -> assertThat(command.requiresExactNumberOfArguments()) |
138 | | - .describedAs("Redis command [%s] failed requires exact arguments check".formatted(command.name())).isEqualTo( |
139 | | - ReflectionTestUtils.getField(command, "minArgs") == ReflectionTestUtils.getField(command, "maxArgs"))); |
| 135 | + assertThat(command.requiresExactNumberOfArguments()) |
| 136 | + .describedAs("Redis command [%s] failed requires exact arguments check".formatted(command.name())).isEqualTo( |
| 137 | + ReflectionTestUtils.getField(command, "minArgs") == ReflectionTestUtils.getField(command, "maxArgs")); |
140 | 138 | }
|
141 | 139 |
|
142 | 140 | }
|
0 commit comments