Merge "Add PUT API for OrchestrationTask"
[so.git] / mso-api-handlers / mso-api-handler-infra / src / test / java / org / onap / so / apihandlerinfra / WorkflowSpecificationsHandlerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (c) 2020 Nordix
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.so.apihandlerinfra;
24
25 import com.fasterxml.jackson.core.JsonParseException;
26 import com.fasterxml.jackson.databind.DeserializationFeature;
27 import com.fasterxml.jackson.databind.JsonMappingException;
28 import com.fasterxml.jackson.databind.ObjectMapper;
29 import org.json.JSONException;
30 import org.junit.Test;
31 import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowInputParameter;
32 import org.onap.so.apihandlerinfra.workflowspecificationbeans.WorkflowSpecifications;
33 import org.onap.so.db.catalog.beans.*;
34 import org.skyscreamer.jsonassert.JSONAssert;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.beans.factory.annotation.Value;
37 import org.springframework.http.HttpEntity;
38 import org.springframework.http.HttpHeaders;
39 import org.springframework.http.HttpMethod;
40 import org.springframework.http.ResponseEntity;
41 import org.springframework.util.ResourceUtils;
42 import org.springframework.web.util.UriComponentsBuilder;
43 import javax.ws.rs.core.MediaType;
44 import javax.ws.rs.core.Response;
45 import java.io.File;
46 import java.io.IOException;
47 import java.nio.file.Files;
48 import java.nio.file.Paths;
49 import java.text.ParseException;
50 import java.util.ArrayList;
51 import java.util.List;
52 import static com.github.tomakehurst.wiremock.client.WireMock.*;
53 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
54 import static org.junit.Assert.assertEquals;
55 import static org.junit.Assert.assertThat;
56
57 public class WorkflowSpecificationsHandlerTest extends BaseTest {
58     @Autowired
59     WorkflowSpecificationsHandler workflowSpecificationsHandler;
60
61     @Value("${wiremock.server.port}")
62     private String wiremockPort;
63
64     private final String basePath = "onap/so/infra/workflowSpecifications";
65
66     @Test
67     public void queryWorkflowSpecificationsByVnfModelUUID_Test_Success()
68             throws ParseException, JSONException, JsonParseException, JsonMappingException, IOException {
69
70         final String urlPath = basePath + "/v1/workflows";
71         HttpHeaders headers = new HttpHeaders();
72         headers.set("Accept", MediaType.APPLICATION_JSON);
73         headers.set("Content-Type", MediaType.APPLICATION_JSON);
74         HttpEntity<String> entity = new HttpEntity<String>(null, headers);
75
76         wireMockServer.stubFor(get(urlMatching(
77                 "/workflow/search/findWorkflowByVnfModelUUID[?]vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52"))
78                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
79                                 .withBody(getWiremockResponseForCatalogdb("WorkflowSpecificationsQuery_Response.json"))
80                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
81
82         wireMockServer.stubFor(get(urlMatching("/workflow/1/workflowActivitySpecSequence"))
83                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
84                         .withBody(getWiremockResponseForCatalogdb("WorkflowActivitySpecSequence_Response.json"))
85                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
86
87         wireMockServer.stubFor(get(urlMatching("/workflowActivitySpecSequence/1/activitySpec"))
88                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
89                         .withBody(getWiremockResponseForCatalogdb("ActivitySpecSequence1_Response.json"))
90                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
91
92         wireMockServer.stubFor(get(urlMatching("/workflowActivitySpecSequence/2/activitySpec"))
93                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
94                         .withBody(getWiremockResponseForCatalogdb("ActivitySpecSequence2_Response.json"))
95                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
96
97         wireMockServer.stubFor(get(urlMatching("/workflowActivitySpecSequence/3/activitySpec"))
98                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
99                         .withBody(getWiremockResponseForCatalogdb("ActivitySpecSequence3_Response.json"))
100                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
101
102         wireMockServer.stubFor(get(urlMatching("/activitySpec/1/activitySpecUserParameters"))
103                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
104                         .withBody(getWiremockResponseForCatalogdb("ActivitySpecUserParameters1_Response.json"))
105                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
106
107         wireMockServer.stubFor(get(urlMatching("/activitySpec/2/activitySpecUserParameters"))
108                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
109                         .withBody(getWiremockResponseForCatalogdb("ActivitySpecUserParameters2_Response.json"))
110                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
111
112         wireMockServer.stubFor(get(urlMatching("/activitySpec/3/activitySpecUserParameters"))
113                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
114                         .withBody(getWiremockResponseForCatalogdb("ActivitySpecUserParameters3_Response.json"))
115                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
116
117         wireMockServer.stubFor(get(urlMatching("/activitySpecUserParameters/1/userParameters"))
118                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
119                         .withBody(getWiremockResponseForCatalogdb("UserParameters1_Response.json"))
120                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
121
122         wireMockServer.stubFor(get(urlMatching("/activitySpecUserParameters/2/userParameters"))
123                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
124                         .withBody(getWiremockResponseForCatalogdb("UserParameters2_Response.json"))
125                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
126
127         wireMockServer.stubFor(get(urlMatching("/activitySpecUserParameters/3/userParameters"))
128                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
129                         .withBody(getWiremockResponseForCatalogdb("UserParameters3_Response.json"))
130                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
131
132         wireMockServer.stubFor(get(urlMatching("/activitySpecUserParameters/4/userParameters"))
133                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
134                         .withBody(getWiremockResponseForCatalogdb("UserParameters4_Response.json"))
135                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
136
137         wireMockServer.stubFor(get(urlMatching("/activitySpecUserParameters/5/userParameters"))
138                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
139                         .withBody(getWiremockResponseForCatalogdb("UserParameters5_Response.json"))
140                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
141
142         wireMockServer.stubFor(get(urlMatching("/activitySpecUserParameters/6/userParameters"))
143                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
144                         .withBody(getWiremockResponseForCatalogdb("UserParameters6_Response.json"))
145                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
146
147         UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(urlPath))
148                 .queryParam("vnfModelVersionId", "b5fa707a-f55a-11e7-a796-005056856d52");
149
150         ResponseEntity<String> response =
151                 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
152
153         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
154
155         ObjectMapper mapper = new ObjectMapper();
156         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
157
158         WorkflowSpecifications expectedResponse = mapper.readValue(
159                 new String(Files
160                         .readAllBytes(Paths.get("src/test/resources/__files/catalogdb/WorkflowSpecifications.json"))),
161                 WorkflowSpecifications.class);
162         WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class);
163
164         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
165         assertThat(expectedResponse, sameBeanAs(realResponse));
166         assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
167         assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
168         assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
169         assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
170     }
171
172     @Test
173     public void mapWorkflowsToWorkflowSpecifications_Test_Success() throws Exception {
174         List<Workflow> workflows = new ArrayList<>();
175         Workflow workflow = new Workflow();
176         workflow.setArtifactUUID("ab6478e4-ea33-3346-ac12-ab121484a333");
177         workflow.setArtifactName("inPlaceSoftwareUpdate-1_0.bpmn");
178         workflow.setVersion(1.0);
179         workflow.setDescription("xyz xyz");
180         workflow.setName("inPlaceSoftwareUpdate");
181         workflow.setOperationName("inPlaceSoftwareUpdate");
182         workflow.setSource("sdc");
183         workflow.setResourceTarget("vnf");
184
185         UserParameters userParameter1 = new UserParameters();
186         userParameter1.setLabel("Operations Timeout");
187         userParameter1.setType("text");
188         userParameter1.setIsRequried(true);
189         userParameter1.setMaxLength(50);
190         userParameter1.setAllowableChars("someRegEx");
191         userParameter1.setName("operations_timeout");
192         userParameter1.setPayloadLocation("userParams");
193
194         UserParameters userParameter2 = new UserParameters();
195         userParameter2.setLabel("Existing Software Version");
196         userParameter2.setType("text");
197         userParameter2.setIsRequried(true);
198         userParameter2.setMaxLength(50);
199         userParameter2.setAllowableChars("someRegEx");
200         userParameter2.setName("existing_software_version");
201         userParameter2.setPayloadLocation("userParams");
202
203         UserParameters userParameter3 = new UserParameters();
204         userParameter3.setLabel("Cloud Owner");
205         userParameter3.setType("text");
206         userParameter3.setIsRequried(true);
207         userParameter3.setMaxLength(7);
208         userParameter3.setAllowableChars("someRegEx");
209         userParameter3.setName("cloudOwner");
210         userParameter3.setPayloadLocation("cloudConfiguration");
211
212         UserParameters userParameter4 = new UserParameters();
213         userParameter4.setLabel("Tenant/Project ID");
214         userParameter4.setType("text");
215         userParameter4.setIsRequried(true);
216         userParameter4.setMaxLength(36);
217         userParameter4.setAllowableChars("someRegEx");
218         userParameter4.setName("tenantId");
219         userParameter4.setPayloadLocation("cloudConfiguration");
220
221         UserParameters userParameter5 = new UserParameters();
222         userParameter5.setLabel("New Software Version");
223         userParameter5.setType("text");
224         userParameter5.setIsRequried(true);
225         userParameter5.setMaxLength(50);
226         userParameter5.setAllowableChars("someRegEx");
227         userParameter5.setName("new_software_version");
228         userParameter5.setPayloadLocation("userParams");
229
230         UserParameters userParameter6 = new UserParameters();
231         userParameter6.setLabel("Cloud Region ID");
232         userParameter6.setType("text");
233         userParameter6.setIsRequried(true);
234         userParameter6.setMaxLength(7);
235         userParameter6.setAllowableChars("someRegEx");
236         userParameter6.setName("lcpCloudRegionId");
237         userParameter6.setPayloadLocation("cloudConfiguration");
238
239
240         List<ActivitySpecUserParameters> activitySpecUserParameters = new ArrayList<ActivitySpecUserParameters>();
241
242         ActivitySpecUserParameters activitySpecUserParameter1 = new ActivitySpecUserParameters();
243         activitySpecUserParameter1.setUserParameters(userParameter1);
244         activitySpecUserParameters.add(activitySpecUserParameter1);
245
246         ActivitySpecUserParameters activitySpecUserParameter2 = new ActivitySpecUserParameters();
247         activitySpecUserParameter2.setUserParameters(userParameter2);
248         activitySpecUserParameters.add(activitySpecUserParameter2);
249
250         ActivitySpecUserParameters activitySpecUserParameter3 = new ActivitySpecUserParameters();
251         activitySpecUserParameter3.setUserParameters(userParameter3);
252         activitySpecUserParameters.add(activitySpecUserParameter3);
253
254
255         ActivitySpecUserParameters activitySpecUserParameter4 = new ActivitySpecUserParameters();
256         activitySpecUserParameter4.setUserParameters(userParameter4);
257         activitySpecUserParameters.add(activitySpecUserParameter4);
258
259         ActivitySpecUserParameters activitySpecUserParameter5 = new ActivitySpecUserParameters();
260         activitySpecUserParameter5.setUserParameters(userParameter5);
261         activitySpecUserParameters.add(activitySpecUserParameter5);
262
263         ActivitySpecUserParameters activitySpecUserParameter6 = new ActivitySpecUserParameters();
264         activitySpecUserParameter6.setUserParameters(userParameter6);
265         activitySpecUserParameters.add(activitySpecUserParameter6);
266
267         List<WorkflowActivitySpecSequence> workflowActivitySpecSequences = new ArrayList<>();
268
269         ActivitySpec activitySpec1 = new ActivitySpec();
270         activitySpec1.setName("VNFQuiesceTrafficActivity");
271         activitySpec1.setDescription("Activity to QuiesceTraffic on VNF");
272         activitySpec1.setActivitySpecUserParameters(activitySpecUserParameters);
273         WorkflowActivitySpecSequence workflowActivitySpecSequence1 = new WorkflowActivitySpecSequence();
274         workflowActivitySpecSequence1.setActivitySpec(activitySpec1);
275         workflowActivitySpecSequences.add(workflowActivitySpecSequence1);
276
277         ActivitySpec activitySpec2 = new ActivitySpec();
278         activitySpec2.setName("VNFHealthCheckActivity");
279         activitySpec2.setDescription("Activity to HealthCheck VNF");
280         activitySpec2.setActivitySpecUserParameters(activitySpecUserParameters);
281         WorkflowActivitySpecSequence workflowActivitySpecSequence2 = new WorkflowActivitySpecSequence();
282         workflowActivitySpecSequence2.setActivitySpec(activitySpec2);
283         workflowActivitySpecSequences.add(workflowActivitySpecSequence2);
284
285         ActivitySpec activitySpec3 = new ActivitySpec();
286         activitySpec3.setName("FlowCompleteActivity");
287         activitySpec3.setDescription("Activity to Complete the BPMN Flow");
288         activitySpec3.setActivitySpecUserParameters(activitySpecUserParameters);
289         WorkflowActivitySpecSequence workflowActivitySpecSequence3 = new WorkflowActivitySpecSequence();
290         workflowActivitySpecSequence3.setActivitySpec(activitySpec3);
291         workflowActivitySpecSequences.add(workflowActivitySpecSequence3);
292
293         workflow.setWorkflowActivitySpecSequence(workflowActivitySpecSequences);
294         workflows.add(workflow);
295
296         Workflow workflowNative = new Workflow();
297         workflowNative.setArtifactUUID("da6478e4-ea33-3346-ac12-ab121284a333");
298         workflowNative.setArtifactName("VnfInPlaceUpdate.bpmn");
299         workflowNative.setVersion(1.0);
300         workflowNative.setDescription("native workflow");
301         workflowNative.setName("VnfInPlaceUpdate");
302         workflowNative.setOperationName("inPlaceSoftwareUpdate");
303         workflowNative.setSource("native");
304         workflowNative.setResourceTarget("vnf");
305         workflows.add(workflowNative);
306
307         WorkflowSpecifications workflowSpecifications =
308                 workflowSpecificationsHandler.mapWorkflowsToWorkflowSpecifications(workflows);
309         ObjectMapper mapper = new ObjectMapper();
310
311         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
312         String workflowSpecificationsJson = mapper.writeValueAsString(workflowSpecifications);
313         WorkflowSpecifications expectedResult = mapper.readValue(
314                 new String(Files
315                         .readAllBytes(Paths.get("src/test/resources/__files/catalogdb/WorkflowSpecifications.json"))),
316                 WorkflowSpecifications.class);
317         String expectedResultJson = mapper.writeValueAsString(expectedResult);
318
319         JSONAssert.assertEquals(expectedResultJson, workflowSpecificationsJson, false);
320         assertThat(expectedResult, sameBeanAs(workflowSpecifications).ignoring(WorkflowInputParameter.class));
321     }
322
323     @Test
324     public void queryWorkflowSpecificationsByPnfModelUUID_Test_Success() throws JSONException, IOException {
325
326         final String urlPath = basePath + "/v1/workflows";
327         HttpHeaders headers = new HttpHeaders();
328         headers.set("Accept", MediaType.APPLICATION_JSON);
329         headers.set("Content-Type", MediaType.APPLICATION_JSON);
330         HttpEntity<String> entity = new HttpEntity<String>(null, headers);
331
332         wireMockServer.stubFor(get(urlMatching(
333                 "/workflow/search/findWorkflowByPnfModelUUID[?]pnfResourceModelUUID=f2d1f2b2-88bb-49da-b716-36ae420ccbff"))
334                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
335                                 .withBody(getWiremockResponseForCatalogdb(
336                                         "WorkflowSpecificationsForPnfQuery_Response.json"))
337                                 .withStatus(org.apache.http.HttpStatus.SC_OK)));
338
339         wireMockServer.stubFor(get(urlMatching("/workflow/4/workflowActivitySpecSequence"))
340                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
341                         .withBody(getWiremockResponseForCatalogdb("Empty_workflowActivitySpecSequence_Response.json"))
342                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
343
344         UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(urlPath))
345                 .queryParam("pnfModelVersionId", "f2d1f2b2-88bb-49da-b716-36ae420ccbff");
346
347         ResponseEntity<String> response =
348                 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
349
350         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
351
352         ObjectMapper mapper = new ObjectMapper();
353         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
354
355         WorkflowSpecifications expectedResponse = mapper.readValue(
356                 new String(Files.readAllBytes(
357                         Paths.get("src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnf.json"))),
358                 WorkflowSpecifications.class);
359         WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class);
360
361         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
362         assertThat(expectedResponse, sameBeanAs(realResponse));
363         assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
364         assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
365         assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
366         assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
367     }
368
369     @Test
370     public void testWorkflowSpecificationsForPnf_Success() throws JSONException, IOException {
371
372         final String urlPath = basePath + "/v1/pnfWorkflows";
373         HttpHeaders headers = new HttpHeaders();
374         headers.set("Accept", MediaType.APPLICATION_JSON);
375         headers.set("Content-Type", MediaType.APPLICATION_JSON);
376         HttpEntity<String> entity = new HttpEntity(null, headers);
377
378         wireMockServer.stubFor(get(urlMatching("/workflow/search/findByResourceTarget[?]resource_target=pnf"))
379                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
380                         .withBody(
381                                 getWiremockResponseForCatalogdb("WorkflowSpecificationsForPnfWorkflows_Response.json"))
382                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
383
384         wireMockServer.stubFor(get(urlMatching("/infraActiveRequests.*"))
385                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
386                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
387
388         wireMockServer.stubFor(get(urlMatching("/workflow/1/workflowActivitySpecSequence"))
389                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
390                         .withBody(getWiremockResponseForCatalogdb("Empty_workflowActivitySpecSequence_Response.json"))
391                         .withStatus(org.apache.http.HttpStatus.SC_OK)));
392
393         UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(urlPath));
394
395         ResponseEntity<String> response =
396                 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class);
397
398         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
399
400         ObjectMapper mapper = new ObjectMapper();
401         mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
402
403         WorkflowSpecifications expectedResponse = mapper.readValue(
404                 new String(Files.readAllBytes(
405                         Paths.get("src/test/resources/__files/catalogdb/WorkflowSpecificationsForPnf.json"))),
406                 WorkflowSpecifications.class);
407         WorkflowSpecifications realResponse = mapper.readValue(response.getBody(), WorkflowSpecifications.class);
408
409         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
410         assertThat(expectedResponse, sameBeanAs(realResponse));
411         assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
412         assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
413         assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
414         assertEquals("1.0.0", response.getHeaders().get("X-LatestVersion").get(0));
415     }
416
417     private String getWiremockResponseForCatalogdb(String file) {
418         try {
419             File resource = ResourceUtils.getFile("classpath:__files/catalogdb/" + file);
420             return new String(Files.readAllBytes(resource.toPath())).replaceAll("localhost:8090",
421                     "localhost:" + wiremockPort);
422         } catch (IOException e) {
423             e.printStackTrace();
424             return null;
425         }
426     }
427 }