|
2 | 2 |
|
3 | 3 | import static org.assertj.core.api.Assertions.assertThat; |
4 | 4 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 5 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
5 | 6 | import static org.junit.jupiter.api.Assertions.assertTrue; |
6 | 7 |
|
7 | 8 | import java.math.BigInteger; |
@@ -67,6 +68,43 @@ public List<RegisteredRestClient> getRestClients() { |
67 | 68 | verifyConfig(restClientsConfig.getClient(ConfigKeyRestClient.class)); |
68 | 69 | } |
69 | 70 |
|
| 71 | + @Test |
| 72 | + void restClientConfigKeyMatchName() { |
| 73 | + SmallRyeConfig config = ConfigUtils.emptyConfigBuilder() |
| 74 | + .withMapping(RestClientsConfig.class) |
| 75 | + .withCustomizers(new SmallRyeConfigBuilderCustomizer() { |
| 76 | + @Override |
| 77 | + public void configBuilder(final SmallRyeConfigBuilder builder) { |
| 78 | + new AbstractRestClientConfigBuilder() { |
| 79 | + @Override |
| 80 | + public List<RegisteredRestClient> getRestClients() { |
| 81 | + return List.of(new RegisteredRestClient(ConfigKeyRestClient.class, |
| 82 | + ConfigKeyRestClient.class.getName())); |
| 83 | + } |
| 84 | + }.configBuilder(builder); |
| 85 | + } |
| 86 | + }) |
| 87 | + .build(); |
| 88 | + assertNotNull(config); |
| 89 | + |
| 90 | + config = ConfigUtils.emptyConfigBuilder() |
| 91 | + .withMapping(RestClientsConfig.class) |
| 92 | + .withCustomizers(new SmallRyeConfigBuilderCustomizer() { |
| 93 | + @Override |
| 94 | + public void configBuilder(final SmallRyeConfigBuilder builder) { |
| 95 | + new AbstractRestClientConfigBuilder() { |
| 96 | + @Override |
| 97 | + public List<RegisteredRestClient> getRestClients() { |
| 98 | + return List.of(new RegisteredRestClient(ConfigKeyRestClient.class, |
| 99 | + ConfigKeyRestClient.class.getSimpleName())); |
| 100 | + } |
| 101 | + }.configBuilder(builder); |
| 102 | + } |
| 103 | + }) |
| 104 | + .build(); |
| 105 | + assertNotNull(config); |
| 106 | + } |
| 107 | + |
70 | 108 | @Test |
71 | 109 | void restClientMicroProfile() { |
72 | 110 | RegisteredRestClient registeredRestClient = new RegisteredRestClient(MPRestClient.class, null); |
@@ -149,6 +187,43 @@ public List<RegisteredRestClient> getRestClients() { |
149 | 187 | assertThat(clientConfig.queryParamStyle().get()).isEqualTo(QueryParamStyle.COMMA_SEPARATED); |
150 | 188 | } |
151 | 189 |
|
| 190 | + @Test |
| 191 | + void restClientMicroProfileConfigKeyMatchName() { |
| 192 | + SmallRyeConfig config = ConfigUtils.emptyConfigBuilder() |
| 193 | + .withMapping(RestClientsConfig.class) |
| 194 | + .withCustomizers(new SmallRyeConfigBuilderCustomizer() { |
| 195 | + @Override |
| 196 | + public void configBuilder(final SmallRyeConfigBuilder builder) { |
| 197 | + new AbstractRestClientConfigBuilder() { |
| 198 | + @Override |
| 199 | + public List<RegisteredRestClient> getRestClients() { |
| 200 | + return List.of(new RegisteredRestClient(MPConfigKeyRestClient.class, |
| 201 | + MPConfigKeyRestClient.class.getName())); |
| 202 | + } |
| 203 | + }.configBuilder(builder); |
| 204 | + } |
| 205 | + }) |
| 206 | + .build(); |
| 207 | + assertNotNull(config); |
| 208 | + |
| 209 | + config = ConfigUtils.emptyConfigBuilder() |
| 210 | + .withMapping(RestClientsConfig.class) |
| 211 | + .withCustomizers(new SmallRyeConfigBuilderCustomizer() { |
| 212 | + @Override |
| 213 | + public void configBuilder(final SmallRyeConfigBuilder builder) { |
| 214 | + new AbstractRestClientConfigBuilder() { |
| 215 | + @Override |
| 216 | + public List<RegisteredRestClient> getRestClients() { |
| 217 | + return List.of(new RegisteredRestClient(MPConfigKeyRestClient.class, |
| 218 | + MPConfigKeyRestClient.class.getSimpleName())); |
| 219 | + } |
| 220 | + }.configBuilder(builder); |
| 221 | + } |
| 222 | + }) |
| 223 | + .build(); |
| 224 | + assertNotNull(config); |
| 225 | + } |
| 226 | + |
152 | 227 | private void verifyConfig(RestClientConfig config) { |
153 | 228 | assertTrue(config.url().isPresent()); |
154 | 229 | assertThat(config.url().get()).isEqualTo("http://localhost:8080"); |
|
0 commit comments