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