|
2 | 2 |
|
3 | 3 | import static java.util.stream.Collectors.toList;
|
4 | 4 | import static org.assertj.core.api.Assertions.assertThat;
|
| 5 | +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
6 | 7 | import static org.junit.jupiter.api.Assertions.assertNull;
|
7 | 8 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
@@ -188,6 +189,34 @@ void trimmedAnnotationPostProcessorAnnotatedInputParams(@Autowired TrimmedServic
|
188 | 189 | assertEquals(inputArgs.trim(), actual);
|
189 | 190 | }
|
190 | 191 |
|
| 192 | + @Test |
| 193 | + @DisplayName("TrimmedAnnotationBeanPostProcessor trims String input params marked with @Trimmed and ignore not annotated") |
| 194 | + void trimmedAnnotationPostProcessorAnnotatedAndNotAnnotatedInputParams(@Autowired TrimmedService service) { |
| 195 | + String inputArgs = " Simba Bimba "; |
| 196 | + String inputArgs2 = " Timon Dimon "; |
| 197 | + String actual = service.getTheTrimmedStringWithTwoArgs(inputArgs, inputArgs2); |
| 198 | + |
| 199 | + assertEquals(inputArgs.trim().concat(inputArgs2), actual); |
| 200 | + } |
| 201 | + |
| 202 | + @Test |
| 203 | + @DisplayName("TrimmedAnnotationBeanPostProcessor trims several String input params marked with @Trimmed and ignore not annotated") |
| 204 | + void trimmedAnnotationPostProcessorSeveralAnnotatedAndNotAnnotatedInputParams(@Autowired TrimmedService service) { |
| 205 | + String inputArgs = " Simba Bimba "; |
| 206 | + String inputArgs2 = " Timon Lemon "; |
| 207 | + String inputArgs3 = " Pumba Lumba "; |
| 208 | + String actual = service.getTheTrimmedStringWithThreeArgs(inputArgs, inputArgs2, inputArgs3); |
| 209 | + |
| 210 | + assertEquals(inputArgs.trim().concat(inputArgs2).concat(inputArgs3.trim()), actual); |
| 211 | + } |
| 212 | + |
| 213 | + @Test |
| 214 | + @DisplayName("TrimmedAnnotationBeanPostProcessor not trims non-String input params marked with @Trimmed") |
| 215 | + void trimmedAnnotationPostProcessorAnnotatedNonStringInputParams(@Autowired TrimmedService service) { |
| 216 | + Integer inputArg = 1; |
| 217 | + assertDoesNotThrow(() -> service.getTheTrimmedInteger(inputArg), "Annotated parameter must ignore non-String types"); |
| 218 | + } |
| 219 | + |
191 | 220 | @Test
|
192 | 221 | @DisplayName("TrimmedAnnotationBeanPostProcessor not trims String input params that not marked by @Trimmed")
|
193 | 222 | void trimmedAnnotationPostProcessorNotAnnotatedInputParams(@Autowired TrimmedService service) {
|
|
0 commit comments