Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 8bb9f08

Browse files
committed
Fix failing tests
(cherry picked from commit f427fa6)
1 parent f721658 commit 8bb9f08

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

spring-cloud-dataflow-configuration-metadata/src/test/java/org/springframework/cloud/dataflow/configuration/metadata/ApplicationConfigurationMetadataResolverAutoConfigurationTest.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.util.Collections;
2222
import java.util.Map;
2323

24+
import com.fasterxml.jackson.core.JsonProcessingException;
25+
import com.fasterxml.jackson.databind.ObjectMapper;
2426
import org.junit.Test;
2527
import org.junit.runner.RunWith;
2628
import org.mockito.Mockito;
@@ -177,7 +179,7 @@ public void containerImageMetadataResolverWithActiveSSL() throws URISyntaxExcept
177179
eq(HttpMethod.GET), any(), eq(Map.class));
178180
// Get Blobs
179181
verify(containerRestTemplate).exchange(eq(new URI("https://demo.goharbor.io/v2/test/image/blobs/test_digest")),
180-
eq(HttpMethod.GET), any(), eq(String.class));
182+
eq(HttpMethod.GET), any(), eq(Map.class));
181183
}
182184

183185
@Test
@@ -199,7 +201,7 @@ public void containerImageMetadataResolverWithDisabledSSL() throws URISyntaxExce
199201
eq(HttpMethod.GET), any(), eq(Map.class));
200202
// Get Blobs
201203
verify(noSslVerificationContainerRestTemplate).exchange(eq(new URI("https://demo.repository.io/v2/disabledssl/image/blobs/test_digest")),
202-
eq(HttpMethod.GET), any(), eq(String.class));
204+
eq(HttpMethod.GET), any(), eq(Map.class));
203205
}
204206

205207
@ImportAutoConfiguration({ ContainerRegistryAutoConfiguration.class, ApplicationConfigurationMetadataResolverAutoConfiguration.class })
@@ -221,7 +223,7 @@ public ContainerImageRestTemplateFactory containerImageRestTemplateFactory(
221223
}
222224

223225
@Bean(name = "noSslVerificationContainerRestTemplate")
224-
RestTemplate noSslVerificationContainerRestTemplate() throws URISyntaxException {
226+
RestTemplate noSslVerificationContainerRestTemplate() throws URISyntaxException, JsonProcessingException {
225227
RestTemplate restTemplate = Mockito.mock(RestTemplate.class);
226228

227229
// demo.repository.io
@@ -249,8 +251,8 @@ RestTemplate noSslVerificationContainerRestTemplate() throws URISyntaxException
249251
when(restTemplate
250252
.exchange(
251253
eq(new URI("https://demo.repository.io/v2/disabledssl/image/blobs/test_digest")),
252-
eq(HttpMethod.GET), any(), eq(String.class)))
253-
.thenReturn(new ResponseEntity<>("{\"config\": {\"Labels\": {\"foo\": \"bar\"} } }", HttpStatus.OK));
254+
eq(HttpMethod.GET), any(), eq(Map.class)))
255+
.thenReturn(new ResponseEntity<>(blobValue(), HttpStatus.OK));
254256

255257
// demo.goharbor.io
256258
HttpHeaders authenticateHeader2 = new HttpHeaders();
@@ -265,7 +267,7 @@ RestTemplate noSslVerificationContainerRestTemplate() throws URISyntaxException
265267
}
266268

267269
@Bean(name = "containerRestTemplate")
268-
RestTemplate containerRestTemplate() throws URISyntaxException {
270+
RestTemplate containerRestTemplate() throws URISyntaxException, JsonProcessingException {
269271
RestTemplate restTemplate = Mockito.mock(RestTemplate.class);
270272

271273
when(restTemplate
@@ -283,14 +285,14 @@ RestTemplate containerRestTemplate() throws URISyntaxException {
283285
when(restTemplate
284286
.exchange(
285287
eq(new URI("https://demo.goharbor.io/v2/test/image/blobs/test_digest")),
286-
eq(HttpMethod.GET), any(), eq(String.class)))
287-
.thenReturn(new ResponseEntity<>("{\"config\": {\"Labels\": {\"foo\": \"bar\"} } }", HttpStatus.OK));
288+
eq(HttpMethod.GET), any(), eq(Map.class)))
289+
.thenReturn(new ResponseEntity<>(blobValue(), HttpStatus.OK));
288290

289291
return restTemplate;
290292
}
291293

292294
@Bean(name = "containerRestTemplateWithHttpProxy")
293-
RestTemplate containerRestTemplateWithHttpProxy() throws URISyntaxException {
295+
RestTemplate containerRestTemplateWithHttpProxy() throws URISyntaxException, JsonProcessingException {
294296
RestTemplate restTemplate = Mockito.mock(RestTemplate.class);
295297

296298
when(restTemplate
@@ -308,14 +310,14 @@ RestTemplate containerRestTemplateWithHttpProxy() throws URISyntaxException {
308310
when(restTemplate
309311
.exchange(
310312
eq(new URI("https://demo2.goharbor.io/v2/test/image/blobs/test_digest")),
311-
eq(HttpMethod.GET), any(), eq(String.class)))
312-
.thenReturn(new ResponseEntity<>("{\"config\": {\"Labels\": {\"foo\": \"bar\"} } }", HttpStatus.OK));
313+
eq(HttpMethod.GET), any(), eq(Map.class)))
314+
.thenReturn(new ResponseEntity<>(blobValue(), HttpStatus.OK));
313315

314316
return restTemplate;
315317
}
316318

317319
@Bean(name = "noSslVerificationContainerRestTemplateWithHttpProxy")
318-
RestTemplate noSslVerificationContainerRestTemplateWithHttpProxy() throws URISyntaxException {
320+
RestTemplate noSslVerificationContainerRestTemplateWithHttpProxy() throws URISyntaxException, JsonProcessingException {
319321
RestTemplate restTemplate = Mockito.mock(RestTemplate.class);
320322

321323
// demo.repository.io
@@ -343,8 +345,8 @@ RestTemplate noSslVerificationContainerRestTemplateWithHttpProxy() throws URISyn
343345
when(restTemplate
344346
.exchange(
345347
eq(new URI("https://demo2.repository.io/v2/disabledssl/image/blobs/test_digest")),
346-
eq(HttpMethod.GET), any(), eq(String.class)))
347-
.thenReturn(new ResponseEntity<>("{\"config\": {\"Labels\": {\"foo\": \"bar\"} } }", HttpStatus.OK));
348+
eq(HttpMethod.GET), any(), eq(Map.class)))
349+
.thenReturn(new ResponseEntity<>(blobValue(), HttpStatus.OK));
348350

349351
// demo.goharbor.io
350352
HttpHeaders authenticateHeader2 = new HttpHeaders();
@@ -357,5 +359,10 @@ RestTemplate noSslVerificationContainerRestTemplateWithHttpProxy() throws URISyn
357359

358360
return restTemplate;
359361
}
362+
363+
public Map blobValue() throws JsonProcessingException {
364+
return new ObjectMapper().readValue("{\"config\": {\"Labels\": {\"foo\": \"bar\"} } }", Map.class);
365+
}
366+
360367
}
361368
}

0 commit comments

Comments
 (0)