Replaced all tabs with spaces in java and pom.xml
[so.git] / mso-api-handlers / mso-api-handler-infra / src / test / java / org / onap / so / apihandlerinfra / OrchestrationRequestsTest.java
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.GetOrchestrationListResponse;
52 import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
53 import org.onap.so.serviceinstancebeans.Request;
54 import org.onap.so.serviceinstancebeans.RequestError;
55 import org.onap.so.serviceinstancebeans.RequestProcessingData;
56 import org.onap.so.serviceinstancebeans.ServiceException;
57 import org.springframework.beans.factory.annotation.Autowired;
58 import org.springframework.http.HttpEntity;
59 import org.springframework.http.HttpHeaders;
60 import org.springframework.http.HttpMethod;
61 import org.springframework.http.ResponseEntity;
62 import org.springframework.web.util.UriComponentsBuilder;
63 import com.fasterxml.jackson.core.JsonParseException;
64 import com.fasterxml.jackson.core.type.TypeReference;
65 import com.fasterxml.jackson.databind.DeserializationFeature;
66 import com.fasterxml.jackson.databind.JsonMappingException;
67 import com.fasterxml.jackson.databind.ObjectMapper;
68
69 public class OrchestrationRequestsTest extends BaseTest {
70     @Autowired
71     private RequestsDbClient requestsDbClient;
72
73     @Autowired
74     private OrchestrationRequests orchReq;
75
76     private static final GetOrchestrationListResponse ORCHESTRATION_LIST = generateOrchestrationList();
77     private static final String INVALID_REQUEST_ID = "invalid-request-id";
78
79     private static GetOrchestrationListResponse generateOrchestrationList() {
80         GetOrchestrationListResponse list = null;
81         try {
82             ObjectMapper mapper = new ObjectMapper();
83             list = mapper.readValue(new File("src/test/resources/OrchestrationRequest/OrchestrationList.json"),
84                     GetOrchestrationListResponse.class);
85         } catch (JsonParseException jpe) {
86             jpe.printStackTrace();
87         } catch (JsonMappingException jme) {
88             jme.printStackTrace();
89         } catch (IOException ioe) {
90             ioe.printStackTrace();
91         }
92         return list;
93     }
94
95     @Test
96     public void testGetOrchestrationRequest() throws Exception {
97         setupTestGetOrchestrationRequest();
98         // TEST VALID REQUEST
99         GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
100
101         Request request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
102         testResponse.setRequest(request);
103         String testRequestId = request.getRequestId();
104         HttpHeaders headers = new HttpHeaders();
105         headers.set("Accept", MediaType.APPLICATION_JSON);
106         headers.set("Content-Type", MediaType.APPLICATION_JSON);
107         HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
108
109         UriComponentsBuilder builder = UriComponentsBuilder
110                 .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
111
112         ResponseEntity<GetOrchestrationResponse> response =
113                 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
114
115         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
116         assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
117                 .ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
118         assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
119         assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
120         assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
121         assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
122         assertEquals("00032ab7-na18-42e5-965d-8ea592502018", response.getHeaders().get("X-TransactionID").get(0));
123         assertNotNull(response.getBody().getRequest().getFinishTime());
124     }
125
126     @Test
127     public void testGetOrchestrationRequestInstanceGroup() throws Exception {
128         setupTestGetOrchestrationRequestInstanceGroup();
129         // TEST VALID REQUEST
130         GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
131
132         Request request = ORCHESTRATION_LIST.getRequestList().get(8).getRequest();
133         testResponse.setRequest(request);
134         String testRequestId = request.getRequestId();
135         HttpHeaders headers = new HttpHeaders();
136         headers.set("Accept", MediaType.APPLICATION_JSON);
137         headers.set("Content-Type", MediaType.APPLICATION_JSON);
138         HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
139
140         UriComponentsBuilder builder = UriComponentsBuilder
141                 .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
142
143         ResponseEntity<GetOrchestrationResponse> response =
144                 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
145
146         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
147         assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
148                 .ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
149     }
150
151     @Test
152     public void testGetOrchestrationRequestRequestDetails() throws Exception {
153         setupTestGetOrchestrationRequestRequestDetails("00032ab7-3fb3-42e5-965d-8ea592502017", "COMPLETED");
154         // Test request with modelInfo request body
155         GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
156
157         Request request = ORCHESTRATION_LIST.getRequestList().get(0).getRequest();
158         testResponse.setRequest(request);
159         String testRequestId = request.getRequestId();
160
161         HttpHeaders headers = new HttpHeaders();
162         headers.set("Accept", MediaType.APPLICATION_JSON);
163         headers.set("Content-Type", MediaType.APPLICATION_JSON);
164         HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
165
166         UriComponentsBuilder builder = UriComponentsBuilder
167                 .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
168
169         ResponseEntity<GetOrchestrationResponse> response =
170                 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
171
172         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
173         assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
174                 .ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
175         assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
176         assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
177         assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
178         assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
179         assertEquals("00032ab7-3fb3-42e5-965d-8ea592502017", response.getHeaders().get("X-TransactionID").get(0));
180     }
181
182     @Test
183     public void testGetOrchestrationRequestNoRequestID() {
184         HttpHeaders headers = new HttpHeaders();
185         headers.set("Accept", "application/json; charset=UTF-8");
186         headers.set("Content-Type", "application/json; charset=UTF-8");
187         HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
188         UriComponentsBuilder builder =
189                 UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6/"));
190
191         ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(),
192                 HttpMethod.GET, entity, GetOrchestrationListResponse.class);
193         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
194     }
195
196     @Test
197     public void testGetOrchestrationRequestFilter() throws Exception {
198         setupTestGetOrchestrationRequestFilter();
199         List<String> values = new ArrayList<>();
200         values.add("EQUALS");
201         values.add("vfModule");
202
203         ObjectMapper mapper = new ObjectMapper();
204         GetOrchestrationListResponse testResponse =
205                 mapper.readValue(new File("src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json"),
206                         GetOrchestrationListResponse.class);
207
208         Map<String, List<String>> orchestrationMap = new HashMap<>();
209         orchestrationMap.put("modelType", values);
210         List<GetOrchestrationResponse> testResponses = new ArrayList<>();
211
212         List<InfraActiveRequests> requests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap);
213         HttpHeaders headers = new HttpHeaders();
214         headers.set("Accept", MediaType.APPLICATION_JSON);
215         HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
216
217         UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
218                 createURLWithPort("/onap/so/infra/orchestrationRequests/v6?filter=modelType:EQUALS:vfModule"));
219
220         ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(),
221                 HttpMethod.GET, entity, GetOrchestrationListResponse.class);
222         assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("requestList.request.startTime")
223                 .ignoring("requestList.request.finishTime").ignoring("requestList.request.requestStatus.timeStamp"));
224         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
225         assertEquals(requests.size(), response.getBody().getRequestList().size());
226
227     }
228
229     @Test
230     public void testUnlockOrchestrationRequest() throws Exception {
231         setupTestUnlockOrchestrationRequest("0017f68c-eb2d-45bb-b7c7-ec31b37dc349", "UNLOCKED");
232         ObjectMapper mapper = new ObjectMapper();
233         mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
234         String requestJSON =
235                 new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
236         HttpHeaders headers = new HttpHeaders();
237         headers.set("Accept", MediaType.APPLICATION_JSON);
238         headers.set("Content-Type", MediaType.APPLICATION_JSON);
239         HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
240
241         UriComponentsBuilder builder;
242         ResponseEntity<String> response;
243         RequestError expectedRequestError;
244         RequestError actualRequestError;
245         ServiceException se;
246
247         // Test invalid JSON
248         expectedRequestError = new RequestError();
249         se = new ServiceException();
250         se.setMessageId(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
251         se.setText(
252                 "Orchestration RequestId 0017f68c-eb2d-45bb-b7c7-ec31b37dc349 has a status of UNLOCKED and can not be unlocked");
253         expectedRequestError.setServiceException(se);
254
255         builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
256                 "/onap/so/infra/orchestrationRequests/v6/0017f68c-eb2d-45bb-b7c7-ec31b37dc349/unlock"));
257
258         response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
259         actualRequestError = mapper.readValue(response.getBody(), RequestError.class);
260
261         assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
262         assertThat(actualRequestError, sameBeanAs(expectedRequestError));
263     }
264
265     @Test
266     public void testUnlockOrchestrationRequest_invalid_Json() throws Exception {
267         setupTestUnlockOrchestrationRequest_invalid_Json();
268         ObjectMapper mapper = new ObjectMapper();
269         mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
270         String requestJSON =
271                 new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
272         HttpHeaders headers = new HttpHeaders();
273         headers.set("Accept", MediaType.APPLICATION_JSON);
274         headers.set("Content-Type", MediaType.APPLICATION_JSON);
275         HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
276
277         UriComponentsBuilder builder;
278         ResponseEntity<String> response;
279         RequestError expectedRequestError;
280         RequestError actualRequestError;
281         ServiceException se;
282
283         // Test invalid requestId
284         expectedRequestError = new RequestError();
285         se = new ServiceException();
286         se.setMessageId(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
287         se.setText("Null response from RequestDB when searching by RequestId");
288         expectedRequestError.setServiceException(se);
289
290         builder = UriComponentsBuilder.fromHttpUrl(
291                 createURLWithPort("/onap/so/infra/orchestrationRequests/v6/" + INVALID_REQUEST_ID + "/unlock"));
292
293         response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
294         actualRequestError = mapper.readValue(response.getBody(), RequestError.class);
295
296         assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
297         assertThat(actualRequestError, sameBeanAs(expectedRequestError));
298     }
299
300     @Test
301     public void testUnlockOrchestrationRequest_Valid_Status()
302             throws JsonParseException, JsonMappingException, IOException, ValidationException {
303         setupTestUnlockOrchestrationRequest_Valid_Status("5ffbabd6-b793-4377-a1ab-082670fbc7ac", "PENDING");
304         ObjectMapper mapper = new ObjectMapper();
305         String requestJSON =
306                 new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
307         HttpHeaders headers = new HttpHeaders();
308         headers.set("Accept", MediaType.APPLICATION_JSON);
309         headers.set("Content-Type", MediaType.APPLICATION_JSON);
310         HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
311
312         UriComponentsBuilder builder;
313         ResponseEntity<String> response;
314         Request request;
315
316         // Test valid status
317         request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
318         builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
319                 "/onap/so/infra/orchestrationRequests/v7/" + "5ffbabd6-b793-4377-a1ab-082670fbc7ac" + "/unlock"));
320
321         response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
322         // Cannot assert anything further here, already have a wiremock in place which ensures that the post was
323         // properly called to update.
324     }
325
326     @Ignore // What is this testing?
327     @Test
328     public void testGetOrchestrationRequestRequestDetailsWhiteSpace() throws Exception {
329         InfraActiveRequests requests = new InfraActiveRequests();
330         requests.setAction("create");
331         requests.setRequestBody("  ");
332         requests.setRequestId("requestId");
333         requests.setRequestScope("service");
334         requests.setRequestType("createInstance");
335         ObjectMapper mapper = new ObjectMapper();
336         String json = mapper.writeValueAsString(requests);
337
338         requestsDbClient.save(requests);
339         HttpHeaders headers = new HttpHeaders();
340         headers.set("Accept", MediaType.APPLICATION_JSON);
341         headers.set("Content-Type", MediaType.APPLICATION_JSON);
342         HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
343
344         UriComponentsBuilder builder = UriComponentsBuilder
345                 .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/requestId"));
346
347         ResponseEntity<GetOrchestrationResponse> response =
348                 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
349
350         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
351         assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
352         assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
353         assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
354         assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
355         assertEquals("requestId", response.getHeaders().get("X-TransactionID").get(0));
356     }
357
358     @Ignore // What is this testing?
359     @Test
360     public void testGetOrchestrationRequestRequestDetailsAlaCarte() throws IOException {
361         InfraActiveRequests requests = new InfraActiveRequests();
362
363         String requestJSON = new String(
364                 Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/AlaCarteRequest.json")));
365
366         requests.setAction("create");
367         requests.setRequestBody(requestJSON);
368         requests.setRequestId("requestId");
369         requests.setRequestScope("service");
370         requests.setRequestType("createInstance");
371         // iar.save(requests);
372         HttpHeaders headers = new HttpHeaders();
373         headers.set("Accept", MediaType.APPLICATION_JSON);
374         headers.set("Content-Type", MediaType.APPLICATION_JSON);
375         HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
376
377         UriComponentsBuilder builder = UriComponentsBuilder
378                 .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/requestId"));
379
380         ResponseEntity<GetOrchestrationResponse> response =
381                 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
382
383         assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
384         assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
385         assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
386         assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
387         assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
388         assertEquals("requestId", response.getHeaders().get("X-TransactionID").get(0));
389     }
390
391     @Test
392     public void mapRequestProcessingDataTest() throws JsonParseException, JsonMappingException, IOException {
393         RequestProcessingData entry = new RequestProcessingData();
394         RequestProcessingData secondEntry = new RequestProcessingData();
395         List<HashMap<String, String>> expectedList = new ArrayList<>();
396         HashMap<String, String> expectedMap = new HashMap<>();
397         List<HashMap<String, String>> secondExpectedList = new ArrayList<>();
398         HashMap<String, String> secondExpectedMap = new HashMap<>();
399         List<RequestProcessingData> expectedDataList = new ArrayList<>();
400         entry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
401         entry.setTag("pincFabricConfigRequest");
402         expectedMap.put("requestAction", "assign");
403         expectedMap.put("pincFabricId", "testId");
404         expectedList.add(expectedMap);
405         entry.setDataPairs(expectedList);
406         secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715");
407         secondEntry.setTag("pincFabricConfig");
408         secondExpectedMap.put("requestAction", "unassign");
409         secondExpectedList.add(secondExpectedMap);
410         secondEntry.setDataPairs(secondExpectedList);
411         expectedDataList.add(entry);
412         expectedDataList.add(secondEntry);
413
414         List<org.onap.so.db.request.beans.RequestProcessingData> processingData = new ArrayList<>();
415         List<RequestProcessingData> actualProcessingData = new ArrayList<>();
416         ObjectMapper mapper = new ObjectMapper();
417         processingData =
418                 mapper.readValue(new File("src/test/resources/OrchestrationRequest/RequestProcessingData.json"),
419                         new TypeReference<List<org.onap.so.db.request.beans.RequestProcessingData>>() {});
420         actualProcessingData = orchReq.mapRequestProcessingData(processingData);
421         assertThat(actualProcessingData, sameBeanAs(expectedDataList));
422     }
423
424     public void setupTestGetOrchestrationRequest() throws Exception {
425         // For testGetOrchestrationRequest
426         wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018"))
427                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
428                         .withBody(new String(Files.readAllBytes(
429                                 Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequest.json"))))
430                         .withStatus(HttpStatus.SC_OK)));
431         wireMockServer
432                 .stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
433                         .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-na18-42e5-965d-8ea592502018"))
434                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
435                                 .withBody(new String(Files.readAllBytes(Paths
436                                         .get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
437                                 .withStatus(HttpStatus.SC_OK)));
438     }
439
440     public void setupTestGetOrchestrationRequestInstanceGroup() throws Exception {
441         // For testGetOrchestrationRequest
442         wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018"))
443                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
444                         .withBody(new String(Files.readAllBytes(Paths.get(
445                                 "src/test/resources/OrchestrationRequest/getOrchestrationRequestInstanceGroup.json"))))
446                         .withStatus(HttpStatus.SC_OK)));
447         wireMockServer
448                 .stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
449                         .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-na18-42e5-965d-8ea592502018"))
450                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
451                                 .withBody(new String(Files.readAllBytes(Paths
452                                         .get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
453                                 .withStatus(HttpStatus.SC_OK)));
454     }
455
456     private void setupTestGetOrchestrationRequestRequestDetails(String requestId, String status) throws Exception {
457         wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse()
458                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
459                 .withBody(new String(Files.readAllBytes(
460                         Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequestDetails.json"))))
461                 .withStatus(HttpStatus.SC_OK)));
462     }
463
464     private void setupTestUnlockOrchestrationRequest(String requestId, String status) {
465         wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId)))
466                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
467                         .withBody(String.format(getResponseTemplate, requestId, status)).withStatus(HttpStatus.SC_OK)));
468
469     }
470
471
472
473     private void setupTestUnlockOrchestrationRequest_invalid_Json() {
474         wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(INVALID_REQUEST_ID))).willReturn(aResponse()
475                 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
476
477     }
478
479     private void setupTestUnlockOrchestrationRequest_Valid_Status(String requestID, String status) {
480         wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestID)))
481                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
482                         .withBody(String.format(getResponseTemplate, requestID, status)).withStatus(HttpStatus.SC_OK)));
483
484         wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("")))
485                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
486                         .withBody(String.format(infraActivePost, requestID)).withStatus(HttpStatus.SC_OK)));
487     }
488
489     private void setupTestGetOrchestrationRequestFilter() throws Exception {
490         // for testGetOrchestrationRequestFilter();
491         wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/getOrchestrationFiltersFromInfraActive/"))
492                 .withRequestBody(equalToJson("{\"modelType\":[\"EQUALS\",\"vfModule\"]}"))
493                 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
494                         .withBody(new String(Files.readAllBytes(
495                                 Paths.get("src/test/resources/OrchestrationRequest/getRequestDetailsFilter.json"))))
496                         .withStatus(HttpStatus.SC_OK)));
497     }
498 }