21
21
import java .util .HashMap ;
22
22
import java .util .Map ;
23
23
24
+ import com .fasterxml .jackson .core .JsonProcessingException ;
25
+ import com .fasterxml .jackson .databind .ObjectMapper ;
24
26
import org .junit .Before ;
25
27
import org .junit .Test ;
26
28
import org .mockito .Mock ;
@@ -96,7 +98,7 @@ public void getImageLabelsInvalidImageName() {
96
98
}
97
99
98
100
@ Test
99
- public void getImageLabels () {
101
+ public void getImageLabels () throws JsonProcessingException {
100
102
101
103
DefaultContainerImageMetadataResolver resolver = new MockedDefaultContainerImageMetadataResolver (this .containerRegistryService );
102
104
@@ -112,7 +114,7 @@ public void getImageLabels() {
112
114
}
113
115
114
116
@ Test
115
- public void getImageLabelsFromPrivateRepository () {
117
+ public void getImageLabelsFromPrivateRepository () throws JsonProcessingException {
116
118
117
119
DefaultContainerImageMetadataResolver resolver = new MockedDefaultContainerImageMetadataResolver (this .containerRegistryService );
118
120
@@ -129,10 +131,8 @@ public void getImageLabelsFromPrivateRepository() {
129
131
130
132
@ Test (expected = ContainerRegistryException .class )
131
133
public void getImageLabelsMissingRegistryConfiguration () {
132
-
133
134
DefaultContainerImageMetadataResolver resolver = new MockedDefaultContainerImageMetadataResolver (this .containerRegistryService );
134
-
135
- resolver .getImageLabels ("test/image:latest" );
135
+ resolver .getImageLabels ("somehost:8083/test/image:latest" );
136
136
}
137
137
138
138
@ Test (expected = ContainerRegistryException .class )
@@ -183,7 +183,7 @@ public void getImageLabelsInvalidDigest() {
183
183
}
184
184
185
185
@ Test
186
- public void getImageLabelsWithInvalidLabels () {
186
+ public void getImageLabelsWithInvalidLabels () throws JsonProcessingException {
187
187
188
188
DefaultContainerImageMetadataResolver resolver = new MockedDefaultContainerImageMetadataResolver (this .containerRegistryService );
189
189
@@ -217,7 +217,7 @@ private void mockManifestRestTemplateCall(Map<String, Object> mapToReturn, Strin
217
217
}
218
218
219
219
private void mockBlogRestTemplateCall (String jsonResponse , String registryHost , String registryPort ,
220
- String repository , String digest ) {
220
+ String repository , String digest ) throws JsonProcessingException {
221
221
222
222
UriComponents blobUriComponents = UriComponentsBuilder .newInstance ()
223
223
.scheme ("https" )
@@ -230,8 +230,8 @@ private void mockBlogRestTemplateCall(String jsonResponse, String registryHost,
230
230
eq (blobUriComponents .toUri ()),
231
231
eq (HttpMethod .GET ),
232
232
any (HttpEntity .class ),
233
- eq (String .class )))
234
- .thenReturn (new ResponseEntity <>(jsonResponse , HttpStatus .OK ));
233
+ eq (Map .class )))
234
+ .thenReturn (new ResponseEntity <>(new ObjectMapper (). readValue ( jsonResponse , Map . class ) , HttpStatus .OK ));
235
235
}
236
236
237
237
private class MockedDefaultContainerImageMetadataResolver extends DefaultContainerImageMetadataResolver {
0 commit comments