c678fab03ecd1d6903af5b48a7e78f9c798a6071
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.apihandlerinfra;
22
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
24 import static com.github.tomakehurst.wiremock.client.WireMock.any;
25 import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
26 import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
27 import static com.github.tomakehurst.wiremock.client.WireMock.get;
28 import static com.github.tomakehurst.wiremock.client.WireMock.post;
29 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
30 import static com.shazam.shazamcrest.MatcherAssert.assertThat;
31 import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
32 import static org.junit.Assert.assertEquals;
33 import static org.junit.Assert.assertNotNull;
34 import java.io.File;
35 import java.io.IOException;
36 import java.nio.file.Files;
37 import java.nio.file.Paths;
38 import java.util.ArrayList;
39 import java.util.HashMap;
40 import java.util.List;
41 import java.util.Map;
42 import javax.ws.rs.core.MediaType;
43 import javax.ws.rs.core.Response;
44 import org.apache.http.HttpStatus;
45 import org.junit.Ignore;
46 import org.junit.Test;
47 import org.onap.so.apihandler.common.ErrorNumbers;
48 import org.onap.so.db.request.beans.InfraActiveRequests;
49 import org.onap.so.db.request.client.RequestsDbClient;
50 import org.onap.so.exceptions.ValidationException;
51 import org.onap.so.serviceinstancebeans.CloudRequestData;
52 import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse;
53 import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
54 import org.onap.so.serviceinstancebeans.Request;
55 import org.onap.so.serviceinstancebeans.RequestError;
56 import org.onap.so.serviceinstancebeans.RequestProcessingData;
57 import org.onap.so.serviceinstancebeans.ServiceException;
58 import org.springframework.beans.factory.annotation.Autowired;
59 import org.springframework.http.HttpEntity;
60 import org.springframework.http.HttpHeaders;
61 import org.springframework.http.HttpMethod;
62 import org.springframework.http.ResponseEntity;
63 import org.springframework.web.util.UriComponentsBuilder;
64 import com.fasterxml.jackson.core.JsonParseException;
65 import com.fasterxml.jackson.core.type.TypeReference;
66 import com.fasterxml.jackson.databind.DeserializationFeature;
67 import com.fasterxml.jackson.databind.JsonMappingException;
68 import com.fasterxml.jackson.databind.JsonNode;
69 import com.fasterxml.jackson.databind.ObjectMapper;
70
71 public class OrchestrationRequestsTest extends BaseTest {
72     @Autowired
73     private RequestsDbClient requestsDbClient;
74
75     @Autowired
76     private OrchestrationRequests orchReq;
77
78     private static final GetOrchestrationListResponse ORCHESTRATION_LIST = generateOrchestrationList();
79     private static final String INVALID_REQUEST_ID = "invalid-request-id";
80
81     private static GetOrchestrationListResponse generateOrchestrationList() {
82         GetOrchestrationListResponse list = null;
83         try {
84             ObjectMapper mapper = new ObjectMapper();
85             list = mapper.readValue(new File("src/test/resources/OrchestrationRequest/OrchestrationList.json"),
86                     GetOrchestrationListResponse.class);
87         } catch (JsonParseException jpe) {
88             jpe.printStackTrace();
89         } catch (JsonMappingException jme) {
90             jme.printStackTrace();
91         } catch (IOException ioe) {
92             ioe.printStackTrace();
93         }
94         return list;
95     }
96
97     @Test
98     public void testGetOrchestrationRequest() throws Exception {
99         setupTestGetOrchestrationRequest();
100         // TEST VALID REQUEST
101         GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
102
103         Request request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
104         testResponse.setRequest(request);
105         String testRequestId = request.getRequestId();
106         HttpHeaders headers = new HttpHeaders();
107         headers.set("Accept", MediaType.APPLICATION_JSON);
108         headers.set("Content-Type", MediaType.APPLICATION_JSON);
109         HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
110
111         UriComponentsBuilder builder = UriComponentsBuilder
112                 .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
113
114         ResponseEntity<GetOrchestrationResponse> response =
115                 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
116
117         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
118         assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
119                 .ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
120         assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
121         assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
122         assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
123         assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
124         assertEquals("00032ab7-na18-42e5-965d-8ea592502018", response.getHeaders().get("X-TransactionID").get(0));
125         assertNotNull(response.getBody().getRequest().getFinishTime());
126     }
127
128     @Test
129     public void testGetOrchestrationRequestInstanceGroup() throws Exception {
130         setupTestGetOrchestrationRequestInstanceGroup();
131         // TEST VALID REQUEST
132         GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
133
134         Request request = ORCHESTRATION_LIST.getRequestList().get(8).getRequest();
135         testResponse.setRequest(request);
136         String testRequestId = request.getRequestId();
137         HttpHeaders headers = new HttpHeaders();
138         headers.set("Accept", MediaType.APPLICATION_JSON);
139         headers.set("Content-Type", MediaType.APPLICATION_JSON);
140         HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
141
142         UriComponentsBuilder builder = UriComponentsBuilder
143                 .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
144
145         ResponseEntity<GetOrchestrationResponse> response =
146                 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
147
148         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
149         assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
150                 .ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
151     }
152
153     @Test
154     public void testGetOrchestrationRequestWithOpenstackDetails() throws Exception {
155         setupTestGetOrchestrationRequestOpenstackDetails("00032ab7-3fb3-42e5-965d-8ea592502017", "COMPLETED");
156         // Test request with modelInfo request body
157         GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
158
159         Request request = ORCHESTRATION_LIST.getRequestList().get(0).getRequest();
160         List<CloudRequestData> cloudRequestData = new ArrayList<>();
161         CloudRequestData cloudData = new CloudRequestData();
162         cloudData.setCloudIdentifier("heatstackName/123123");
163         ObjectMapper mapper = new ObjectMapper();
164         Object reqData = mapper.readValue(
165                 "{\r\n  \"test\": \"00032ab7-3fb3-42e5-965d-8ea592502016\",\r\n  \"test2\": \"deleteInstance\",\r\n  \"test3\": \"COMPLETE\",\r\n  \"test4\": \"Vf Module has been deleted successfully.\",\r\n  \"test5\": 100\r\n}",
166                 Object.class);
167         cloudData.setCloudRequest(reqData);
168         cloudRequestData.add(cloudData);
169         request.setCloudRequestData(cloudRequestData);
170         testResponse.setRequest(request);
171
172         String testRequestId = request.getRequestId();
173
174         HttpHeaders headers = new HttpHeaders();
175         headers.set("Accept", MediaType.APPLICATION_JSON);
176         headers.set("Content-Type", MediaType.APPLICATION_JSON);
177         HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
178
179         UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
180                 "/onap/so/infra/orchestrationRequests/v7/" + testRequestId + "?includeCloudRequest=true"));
181
182         ResponseEntity<GetOrchestrationResponse> response =
183                 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
184         System.out.println("Response :" + response.getBody().toString());
185         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
186
187         assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
188                 .ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
189
190         assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
191         assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
192         assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
193         assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
194         assertEquals("00032ab7-3fb3-42e5-965d-8ea592502017", response.getHeaders().get("X-TransactionID").get(0));
195     }
196
197     @Test
198     public void testGetOrchestrationRequestNoRequestID() {
199         HttpHeaders headers = new HttpHeaders();
200         headers.set("Accept", "application/json; charset=UTF-8");
201         headers.set("Content-Type", "application/json; charset=UTF-8");
202         HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
203         UriComponentsBuilder builder =
204                 UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6/"));
205
206         ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(),
207                 HttpMethod.GET, entity, GetOrchestrationListResponse.class);
208         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
209     }
210
211     @Test
212     public void testGetOrchestrationRequestFilter() throws Exception {
213         setupTestGetOrchestrationRequestFilter();
214         List<String> values = new ArrayList<>();
215         values.add("EQUALS");
216         values.add("vfModule");
217
218         ObjectMapper mapper = new ObjectMapper();
219         GetOrchestrationListResponse testResponse =
220                 mapper.readValue(new File("src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json"),
221                         GetOrchestrationListResponse.class);
222
223         Map<String, List<String>> orchestrationMap = new HashMap<>();
224         orchestrationMap.put("modelType", values);
225         List<GetOrchestrationResponse> testResponses = new ArrayList<>();
226
227         List<InfraActiveRequests> requests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap);
228         HttpHeaders headers = new HttpHeaders();
229         headers.set("Accept", MediaType.APPLICATION_JSON);
230         HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
231
232         UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
233                 createURLWithPort("/onap/so/infra/orchestrationRequests/v6?filter=modelType:EQUALS:vfModule"));
234
235         ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(),
236                 HttpMethod.GET, entity, GetOrchestrationListResponse.class);
237         assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("requestList.request.startTime")
238                 .ignoring("requestList.request.finishTime").ignoring("requestList.request.requestStatus.timeStamp"));
239         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
240         assertEquals(requests.size(), response.getBody().getRequestList().size());
241
242     }
243
244     @Test
245     public void testUnlockOrchestrationRequest() throws Exception {
246         setupTestUnlockOrchestrationRequest("0017f68c-eb2d-45bb-b7c7-ec31b37dc349", "UNLOCKED");
247         ObjectMapper mapper = new ObjectMapper();
248         mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
249         String requestJSON =
250                 new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
251         HttpHeaders headers = new HttpHeaders();
252         headers.set("Accept", MediaType.APPLICATION_JSON);
253         headers.set("Content-Type", MediaType.APPLICATION_JSON);
254         HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
255
256         UriComponentsBuilder builder;
257         ResponseEntity<String> response;
258         RequestError expectedRequestError;
259         RequestError actualRequestError;
260         ServiceException se;
261
262         // Test invalid JSON
263         expectedRequestError = new RequestError();
264         se = new ServiceException();
265         se.setMessageId(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
266         se.setText(
267                 "Orchestration RequestId 0017f68c-eb2d-45bb-b7c7-ec31b37dc349 has a status of UNLOCKED and can not be unlocked");
268         expectedRequestError.setServiceException(se);
269
270         builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
271                 "/onap/so/infra/orchestrationRequests/v6/0017f68c-eb2d-45bb-b7c7-ec31b37dc349/unlock"));
272
273         response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
274         actualRequestError = mapper.readValue(response.getBody(), RequestError.class);
275
276         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
277         assertThat(actualRequestError, sameBeanAs(expectedRequestError));
278     }
279
280     @Test
281     public void testUnlockOrchestrationRequest_invalid_Json() throws Exception {
282         setupTestUnlockOrchestrationRequest_invalid_Json();
283         ObjectMapper mapper = new ObjectMapper();
284         mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
285         String requestJSON =
286                 new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
287         HttpHeaders headers = new HttpHeaders();
288         headers.set("Accept", MediaType.APPLICATION_JSON);
289         headers.set("Content-Type", MediaType.APPLICATION_JSON);
290         HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
291
292         UriComponentsBuilder builder;
293         ResponseEntity<String> response;
294         RequestError expectedRequestError;
295         RequestError actualRequestError;
296         ServiceException se;
297
298         // Test invalid requestId
299         expectedRequestError = new RequestError();
300         se = new ServiceException();
301         se.setMessageId(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
302         se.setText("Null response from RequestDB when searching by RequestId");
303         expectedRequestError.setServiceException(se);
304
305         builder = UriComponentsBuilder.fromHttpUrl(
306                 createURLWithPort("/onap/so/infra/orchestrationRequests/v6/" + INVALID_REQUEST_ID + "/unlock"));
307
308         response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
309         actualRequestError = mapper.readValue(response.getBody(), RequestError.class);
310
311         assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
312         assertThat(actualRequestError, sameBeanAs(expectedRequestError));
313     }
314
315     @Test
316     public void testUnlockOrchestrationRequest_Valid_Status()
317             throws JsonParseException, JsonMappingException, IOException, ValidationException {
318         setupTestUnlockOrchestrationRequest_Valid_Status("5ffbabd6-b793-4377-a1ab-082670fbc7ac", "PENDING");
319         ObjectMapper mapper = new ObjectMapper();
320         String requestJSON =
321                 new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
322         HttpHeaders headers = new HttpHeaders();
323         headers.set("Accept", MediaType.APPLICATION_JSON);
324         headers.set("Content-Type", MediaType.APPLICATION_JSON);
325         HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
326
327         UriComponentsBuilder builder;
328         ResponseEntity<String> response;
329         Request request;
330
331         // Test valid status
332         request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
333         builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
334                 "/onap/so/infra/orchestrationRequests/v7/" + "5ffbabd6-b793-4377-a1ab-082670fbc7ac" + "/unlock"));
335
336         response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
337         // Cannot assert anything further here, already have a wiremock in place which ensures that the post was
338         // properly called to update.
339     }
340
341
342
343     @Test
344     public void mapRequestProcessingDataTest() throws JsonParseException, JsonMappingException, IOException {
345         RequestProcessingData entry = new RequestProcessingData();
346         RequestProcessingData secondEntry = new RequestProcessingData();
347         List<HashMap<String, String>> expectedList = new ArrayList<>();
348         HashMap<String, String> expectedMap = new HashMap<>();
349         List<HashMap<String, String>> secondExpectedList = new ArrayList<>();
350         HashMap<String, String> secondExpectedMap = new HashMap<>();
351         List<RequestProcessingData> expectedDataList = new ArrayList<>();
352         entry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
353         entry.setTag("pincFabricConfigRequest");
354         expectedMap.put("requestAction", "assign");
355         expectedMap.put("pincFabricId", "testId");
356         expectedList.add(expectedMap);
357         entry.setDataPairs(expectedList);
358         secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715");
359         secondEntry.setTag("pincFabricConfig");
360         secondExpectedMap.put("requestAction", "unassign");
361         secondExpectedList.add(secondExpectedMap);
362         secondEntry.setDataPairs(secondExpectedList);
363         expectedDataList.add(entry);
364         expectedDataList.add(secondEntry);
365
366         List<org.onap.so.db.request.beans.RequestProcessingData> processingData = new ArrayList<>();
367         List<RequestProcessingData> actualProcessingData = new ArrayList<>();
368         ObjectMapper mapper = new ObjectMapper();
369         processingData =
370                 mapper.readValue(new File("src/test/resources/OrchestrationRequest/RequestProcessingData.json"),
371                         new TypeReference<List<org.onap.so.db.request.beans.RequestProcessingData>>() {});
372         actualProcessingData = orchReq.mapRequestProcessingData(processingData);
373         assertThat(actualProcessingData, sameBeanAs(expectedDataList));
374     }
375
376     public void setupTestGetOrchestrationRequest() throws Exception {
377         // For testGetOrchestrationRequest
378         wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018"))
379                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
380                         .withBody(new String(Files.readAllBytes(
381                                 Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequest.json"))))
382                         .withStatus(HttpStatus.SC_OK)));
383         wireMockServer
384                 .stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
385                         .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-na18-42e5-965d-8ea592502018"))
386                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
387                                 .withBody(new String(Files.readAllBytes(Paths
388                                         .get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
389                                 .withStatus(HttpStatus.SC_OK)));
390     }
391
392     public void setupTestGetOrchestrationRequestInstanceGroup() throws Exception {
393         // For testGetOrchestrationRequest
394         wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018"))
395                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
396                         .withBody(new String(Files.readAllBytes(Paths.get(
397                                 "src/test/resources/OrchestrationRequest/getOrchestrationRequestInstanceGroup.json"))))
398                         .withStatus(HttpStatus.SC_OK)));
399         wireMockServer
400                 .stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
401                         .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-na18-42e5-965d-8ea592502018"))
402                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
403                                 .withBody(new String(Files.readAllBytes(Paths
404                                         .get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
405                                 .withStatus(HttpStatus.SC_OK)));
406     }
407
408     private void setupTestGetOrchestrationRequestRequestDetails(String requestId, String status) throws Exception {
409         wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse()
410                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
411                 .withBody(new String(Files.readAllBytes(
412                         Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequestDetails.json"))))
413                 .withStatus(HttpStatus.SC_OK)));
414     }
415
416
417     private void setupTestGetOrchestrationRequestOpenstackDetails(String requestId, String status) throws Exception {
418         wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse()
419                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
420                 .withBody(new String(Files.readAllBytes(Paths
421                         .get("src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json"))))
422                 .withStatus(HttpStatus.SC_OK)));
423     }
424
425     private void setupTestUnlockOrchestrationRequest(String requestId, String status) {
426         wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId)))
427                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
428                         .withBody(String.format(getResponseTemplate, requestId, status)).withStatus(HttpStatus.SC_OK)));
429
430     }
431
432
433
434     private void setupTestUnlockOrchestrationRequest_invalid_Json() {
435         wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(INVALID_REQUEST_ID))).willReturn(aResponse()
436                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
437     }
438
439     private void setupTestUnlockOrchestrationRequest_Valid_Status(String requestID, String status) {
440         wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestID)))
441                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
442                         .withBody(String.format(getResponseTemplate, requestID, status)).withStatus(HttpStatus.SC_OK)));
443
444         wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("")))
445                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
446                         .withBody(String.format(infraActivePost, requestID)).withStatus(HttpStatus.SC_OK)));
447     }
448
449     private void setupTestGetOrchestrationRequestFilter() throws Exception {
450         // for testGetOrchestrationRequestFilter();
451         wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/getOrchestrationFiltersFromInfraActive/"))
452                 .withRequestBody(equalToJson("{\"modelType\":[\"EQUALS\",\"vfModule\"]}"))
453                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
454                         .withBody(new String(Files.readAllBytes(
455                                 Paths.get("src/test/resources/OrchestrationRequest/getRequestDetailsFilter.json"))))
456                         .withStatus(HttpStatus.SC_OK)));
457     }
458 }