|
16 | 16 |
|
17 | 17 | package org.springframework.security.oauth2.client.jackson2;
|
18 | 18 |
|
| 19 | +import java.util.stream.Stream; |
| 20 | + |
19 | 21 | import com.fasterxml.jackson.databind.JsonNode;
|
20 | 22 | import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
21 | 23 | import com.fasterxml.jackson.databind.node.ObjectNode;
|
22 | 24 | import com.fasterxml.jackson.databind.util.StdConverter;
|
23 | 25 | import org.junit.jupiter.params.ParameterizedTest;
|
24 | 26 | import org.junit.jupiter.params.provider.Arguments;
|
25 | 27 | import org.junit.jupiter.params.provider.MethodSource;
|
26 |
| -import org.springframework.security.oauth2.core.ClientAuthenticationMethod; |
27 | 28 |
|
28 |
| -import java.util.stream.Stream; |
| 29 | +import org.springframework.security.oauth2.core.ClientAuthenticationMethod; |
29 | 30 |
|
30 |
| -import static org.junit.jupiter.api.Assertions.assertEquals; |
| 31 | +import static org.assertj.core.api.Assertions.assertThat; |
31 | 32 |
|
32 |
| -public class StdConvertersTest { |
| 33 | +public class StdConvertersTests { |
33 | 34 |
|
34 |
| - private final StdConverter<JsonNode, ClientAuthenticationMethod> clientAuthenticationMethodConverter = |
35 |
| - new StdConverters.ClientAuthenticationMethodConverter(); |
| 35 | + private final StdConverter<JsonNode, ClientAuthenticationMethod> clientAuthenticationMethodConverter = new StdConverters.ClientAuthenticationMethodConverter(); |
36 | 36 |
|
37 | 37 | @ParameterizedTest
|
38 |
| - @MethodSource("testClientAuthenticationMethodConverting") |
39 |
| - void testClientAuthenticationMethodConverting(String clientAuthenticationMethod) { |
| 38 | + @MethodSource("convertWhenClientAuthenticationMethodConvertedThenDeserializes") |
| 39 | + void convertWhenClientAuthenticationMethodConvertedThenDeserializes(String clientAuthenticationMethod) { |
40 | 40 | ObjectNode jsonNode = JsonNodeFactory.instance.objectNode();
|
41 | 41 | jsonNode.put("value", clientAuthenticationMethod);
|
42 | 42 | ClientAuthenticationMethod actual = this.clientAuthenticationMethodConverter.convert(jsonNode);
|
43 |
| - assertEquals(clientAuthenticationMethod, actual.getValue()); |
44 |
| - |
| 43 | + assertThat(actual.getValue()).isEqualTo(clientAuthenticationMethod); |
45 | 44 | }
|
46 | 45 |
|
47 |
| - static Stream<Arguments> testClientAuthenticationMethodConverting() { |
48 |
| - return Stream.of( |
49 |
| - Arguments.of(ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue()), |
| 46 | + static Stream<Arguments> convertWhenClientAuthenticationMethodConvertedThenDeserializes() { |
| 47 | + return Stream.of(Arguments.of(ClientAuthenticationMethod.CLIENT_SECRET_BASIC.getValue()), |
50 | 48 | Arguments.of(ClientAuthenticationMethod.CLIENT_SECRET_POST.getValue()),
|
51 | 49 | Arguments.of(ClientAuthenticationMethod.PRIVATE_KEY_JWT.getValue()),
|
52 |
| - Arguments.of(ClientAuthenticationMethod.NONE.getValue()), |
53 |
| - Arguments.of("custom_method") |
54 |
| - ); |
| 50 | + Arguments.of(ClientAuthenticationMethod.NONE.getValue()), Arguments.of("custom_method")); |
55 | 51 | }
|
| 52 | + |
56 | 53 | }
|
0 commit comments