2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.apihandlerinfra;
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.urlMatching;
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 import static org.junit.Assert.assertNotNull;
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;
43 import javax.ws.rs.core.MediaType;
44 import javax.ws.rs.core.Response;
45 import org.apache.http.HttpStatus;
46 import org.junit.Before;
47 import org.junit.Test;
48 import org.onap.so.apihandler.common.ErrorNumbers;
49 import org.onap.so.db.request.beans.InfraActiveRequests;
50 import org.onap.so.db.request.client.RequestsDbClient;
51 import org.onap.so.exceptions.ValidationException;
52 import org.onap.so.serviceinstancebeans.CloudRequestData;
53 import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse;
54 import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
55 import org.onap.so.serviceinstancebeans.Request;
56 import org.onap.so.serviceinstancebeans.RequestError;
57 import org.onap.so.serviceinstancebeans.RequestProcessingData;
58 import org.onap.so.serviceinstancebeans.ServiceException;
59 import org.springframework.beans.factory.annotation.Autowired;
60 import org.springframework.http.HttpEntity;
61 import org.springframework.http.HttpHeaders;
62 import org.springframework.http.HttpMethod;
63 import org.springframework.http.ResponseEntity;
64 import org.springframework.web.util.UriComponentsBuilder;
65 import com.fasterxml.jackson.core.JsonParseException;
66 import com.fasterxml.jackson.core.type.TypeReference;
67 import com.fasterxml.jackson.databind.DeserializationFeature;
68 import com.fasterxml.jackson.databind.JsonMappingException;
69 import com.fasterxml.jackson.databind.ObjectMapper;
71 public class OrchestrationRequestsTest extends BaseTest {
73 private RequestsDbClient requestsDbClient;
76 private OrchestrationRequests orchReq;
78 private static final GetOrchestrationListResponse ORCHESTRATION_LIST = generateOrchestrationList();
79 private static final String INVALID_REQUEST_ID = "invalid-request-id";
81 private static GetOrchestrationListResponse generateOrchestrationList() {
82 GetOrchestrationListResponse list = null;
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();
98 public void setup() throws IOException {
99 wireMockServer.stubFor(get(urlMatching("/sobpmnengine/history/process-instance.*")).willReturn(aResponse()
100 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
101 .withBody(new String(Files.readAllBytes(
102 Paths.get("src/test/resources/OrchestrationRequest/ProcessInstanceHistoryResponse.json"))))
103 .withStatus(org.apache.http.HttpStatus.SC_OK)));
104 wireMockServer.stubFor(
105 get(("/sobpmnengine/history/activity-instance?processInstanceId=c4c6b647-a26e-11e9-b144-0242ac14000b"))
106 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
107 .withBody(new String(Files.readAllBytes(Paths.get(
108 "src/test/resources/OrchestrationRequest/ActivityInstanceHistoryResponse.json"))))
109 .withStatus(HttpStatus.SC_OK)));
113 public void testGetOrchestrationRequest() throws Exception {
114 setupTestGetOrchestrationRequest();
115 // TEST VALID REQUEST
116 GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
118 Request request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
119 testResponse.setRequest(request);
120 String testRequestId = request.getRequestId();
121 HttpHeaders headers = new HttpHeaders();
122 headers.set("Accept", MediaType.APPLICATION_JSON);
123 headers.set("Content-Type", MediaType.APPLICATION_JSON);
124 HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
126 UriComponentsBuilder builder = UriComponentsBuilder
127 .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
129 ResponseEntity<GetOrchestrationResponse> response =
130 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
132 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
133 assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
134 .ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
135 assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
136 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
137 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
138 assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
139 assertEquals("00032ab7-1a18-42e5-965d-8ea592502018", response.getHeaders().get("X-TransactionID").get(0));
140 assertNotNull(response.getBody().getRequest().getFinishTime());
144 public void testGetOrchestrationRequestInstanceGroup() throws Exception {
145 setupTestGetOrchestrationRequestInstanceGroup();
146 // TEST VALID REQUEST
147 GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
149 Request request = ORCHESTRATION_LIST.getRequestList().get(8).getRequest();
150 testResponse.setRequest(request);
151 String testRequestId = request.getRequestId();
152 HttpHeaders headers = new HttpHeaders();
153 headers.set("Accept", MediaType.APPLICATION_JSON);
154 headers.set("Content-Type", MediaType.APPLICATION_JSON);
155 HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
157 UriComponentsBuilder builder = UriComponentsBuilder
158 .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
160 ResponseEntity<GetOrchestrationResponse> response =
161 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
163 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
164 assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
165 .ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
169 public void testGetOrchestrationRequestWithOpenstackDetails() throws Exception {
170 setupTestGetOrchestrationRequestOpenstackDetails("00032ab7-3fb3-42e5-965d-8ea592502017", "COMPLETED");
171 // Test request with modelInfo request body
172 GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
174 Request request = ORCHESTRATION_LIST.getRequestList().get(0).getRequest();
175 List<CloudRequestData> cloudRequestData = new ArrayList<>();
176 CloudRequestData cloudData = new CloudRequestData();
177 cloudData.setCloudIdentifier("heatstackName/123123");
178 ObjectMapper mapper = new ObjectMapper();
179 Object reqData = mapper.readValue(
180 "{\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}",
182 cloudData.setCloudRequest(reqData);
183 cloudRequestData.add(cloudData);
184 request.setCloudRequestData(cloudRequestData);
185 testResponse.setRequest(request);
186 String testRequestId = request.getRequestId();
188 HttpHeaders headers = new HttpHeaders();
189 headers.set("Accept", MediaType.APPLICATION_JSON);
190 headers.set("Content-Type", MediaType.APPLICATION_JSON);
191 HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
193 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
194 "/onap/so/infra/orchestrationRequests/v7/" + testRequestId + "?includeCloudRequest=true"));
196 ResponseEntity<GetOrchestrationResponse> response =
197 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
198 System.out.println("Response :" + response.getBody().toString());
199 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
201 assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime")
202 .ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
203 assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
204 assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
205 assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
206 assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
207 assertEquals("00032ab7-3fb3-42e5-965d-8ea592502017", response.getHeaders().get("X-TransactionID").get(0));
211 public void testGetOrchestrationRequestNoRequestID() {
212 HttpHeaders headers = new HttpHeaders();
213 headers.set("Accept", "application/json; charset=UTF-8");
214 headers.set("Content-Type", "application/json; charset=UTF-8");
215 HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
216 UriComponentsBuilder builder =
217 UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6/"));
219 ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(),
220 HttpMethod.GET, entity, GetOrchestrationListResponse.class);
221 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
225 public void testGetOrchestrationRequestInvalidRequestID() throws Exception {
226 setupTestGetOrchestrationRequest();
227 // TEST INVALID REQUESTID
228 GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
230 Request request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
231 testResponse.setRequest(request);
232 String testRequestId = "00032ab7-pfb3-42e5-965d-8ea592502016";
233 HttpHeaders headers = new HttpHeaders();
234 headers.set("Accept", MediaType.APPLICATION_JSON);
235 headers.set("Content-Type", MediaType.APPLICATION_JSON);
236 HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
238 UriComponentsBuilder builder = UriComponentsBuilder
239 .fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
241 ResponseEntity<GetOrchestrationResponse> response =
242 restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
244 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
248 public void testGetOrchestrationRequestFilter() throws Exception {
249 setupTestGetOrchestrationRequestFilter();
250 List<String> values = new ArrayList<>();
251 values.add("EQUALS");
252 values.add("vfModule");
254 ObjectMapper mapper = new ObjectMapper();
255 GetOrchestrationListResponse testResponse =
256 mapper.readValue(new File("src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json"),
257 GetOrchestrationListResponse.class);
259 Map<String, List<String>> orchestrationMap = new HashMap<>();
260 orchestrationMap.put("modelType", values);
261 List<GetOrchestrationResponse> testResponses = new ArrayList<>();
263 List<InfraActiveRequests> requests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap);
264 HttpHeaders headers = new HttpHeaders();
265 headers.set("Accept", MediaType.APPLICATION_JSON);
266 HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
268 UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(
269 createURLWithPort("/onap/so/infra/orchestrationRequests/v6?filter=modelType:EQUALS:vfModule"));
271 ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(),
272 HttpMethod.GET, entity, GetOrchestrationListResponse.class);
273 assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("requestList.request.startTime")
274 .ignoring("requestList.request.finishTime").ignoring("requestList.request.requestStatus.timeStamp"));
275 assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
276 assertEquals(requests.size(), response.getBody().getRequestList().size());
281 public void testUnlockOrchestrationRequest() throws Exception {
282 setupTestUnlockOrchestrationRequest("0017f68c-eb2d-45bb-b7c7-ec31b37dc349", "UNLOCKED");
283 ObjectMapper mapper = new ObjectMapper();
284 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
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);
292 UriComponentsBuilder builder;
293 ResponseEntity<String> response;
294 RequestError expectedRequestError;
295 RequestError actualRequestError;
299 expectedRequestError = new RequestError();
300 se = new ServiceException();
301 se.setMessageId(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
303 "Orchestration RequestId 0017f68c-eb2d-45bb-b7c7-ec31b37dc349 has a status of UNLOCKED and can not be unlocked");
304 expectedRequestError.setServiceException(se);
306 builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
307 "/onap/so/infra/orchestrationRequests/v6/0017f68c-eb2d-45bb-b7c7-ec31b37dc349/unlock"));
309 response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
310 actualRequestError = mapper.readValue(response.getBody(), RequestError.class);
312 assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
313 assertThat(actualRequestError, sameBeanAs(expectedRequestError));
317 public void testUnlockOrchestrationRequest_invalid_Json() throws Exception {
318 setupTestUnlockOrchestrationRequest_invalid_Json();
319 ObjectMapper mapper = new ObjectMapper();
320 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
322 new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
323 HttpHeaders headers = new HttpHeaders();
324 headers.set("Accept", MediaType.APPLICATION_JSON);
325 headers.set("Content-Type", MediaType.APPLICATION_JSON);
326 HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
328 UriComponentsBuilder builder;
329 ResponseEntity<String> response;
330 RequestError expectedRequestError;
331 RequestError actualRequestError;
334 // Test invalid requestId
335 expectedRequestError = new RequestError();
336 se = new ServiceException();
337 se.setMessageId(ErrorNumbers.SVC_DETAILED_SERVICE_ERROR);
338 se.setText("Null response from RequestDB when searching by RequestId");
339 expectedRequestError.setServiceException(se);
341 builder = UriComponentsBuilder.fromHttpUrl(
342 createURLWithPort("/onap/so/infra/orchestrationRequests/v6/" + INVALID_REQUEST_ID + "/unlock"));
344 response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
345 actualRequestError = mapper.readValue(response.getBody(), RequestError.class);
347 assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value());
348 assertThat(actualRequestError, sameBeanAs(expectedRequestError));
352 public void testUnlockOrchestrationRequest_Valid_Status()
353 throws JsonParseException, JsonMappingException, IOException, ValidationException {
354 setupTestUnlockOrchestrationRequest_Valid_Status("5ffbabd6-b793-4377-a1ab-082670fbc7ac", "PENDING");
355 ObjectMapper mapper = new ObjectMapper();
357 new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/Request.json")));
358 HttpHeaders headers = new HttpHeaders();
359 headers.set("Accept", MediaType.APPLICATION_JSON);
360 headers.set("Content-Type", MediaType.APPLICATION_JSON);
361 HttpEntity<String> entity = new HttpEntity<String>(requestJSON, headers);
363 UriComponentsBuilder builder;
364 ResponseEntity<String> response;
368 request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
369 builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(
370 "/onap/so/infra/orchestrationRequests/v7/" + "5ffbabd6-b793-4377-a1ab-082670fbc7ac" + "/unlock"));
372 response = restTemplate.exchange(builder.toUriString(), HttpMethod.POST, entity, String.class);
373 // Cannot assert anything further here, already have a wiremock in place
374 // which ensures that the post was
375 // properly called to update.
379 public void mapRequestProcessingDataTest() throws JsonParseException, JsonMappingException, IOException {
380 RequestProcessingData entry = new RequestProcessingData();
381 RequestProcessingData secondEntry = new RequestProcessingData();
382 List<HashMap<String, String>> expectedList = new ArrayList<>();
383 HashMap<String, String> expectedMap = new HashMap<>();
384 List<HashMap<String, String>> secondExpectedList = new ArrayList<>();
385 HashMap<String, String> secondExpectedMap = new HashMap<>();
386 List<RequestProcessingData> expectedDataList = new ArrayList<>();
387 entry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
388 entry.setTag("pincFabricConfigRequest");
389 expectedMap.put("requestAction", "assign");
390 expectedMap.put("pincFabricId", "testId");
391 expectedList.add(expectedMap);
392 entry.setDataPairs(expectedList);
393 secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715");
394 secondEntry.setTag("pincFabricConfig");
395 secondExpectedMap.put("requestAction", "unassign");
396 secondExpectedList.add(secondExpectedMap);
397 secondEntry.setDataPairs(secondExpectedList);
398 expectedDataList.add(entry);
399 expectedDataList.add(secondEntry);
401 List<org.onap.so.db.request.beans.RequestProcessingData> processingData = new ArrayList<>();
402 List<RequestProcessingData> actualProcessingData = new ArrayList<>();
403 ObjectMapper mapper = new ObjectMapper();
405 mapper.readValue(new File("src/test/resources/OrchestrationRequest/RequestProcessingData.json"),
406 new TypeReference<List<org.onap.so.db.request.beans.RequestProcessingData>>() {});
407 actualProcessingData = orchReq.mapRequestProcessingData(processingData);
408 assertThat(actualProcessingData, sameBeanAs(expectedDataList));
411 public void setupTestGetOrchestrationRequest() throws Exception {
412 // For testGetOrchestrationRequest
413 wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-1a18-42e5-965d-8ea592502018"))
414 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
415 .withBody(new String(Files.readAllBytes(
416 Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequest.json"))))
417 .withStatus(HttpStatus.SC_OK)));
419 .stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
420 .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-1a18-42e5-965d-8ea592502018"))
421 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
422 .withBody(new String(Files.readAllBytes(Paths
423 .get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
424 .withStatus(HttpStatus.SC_OK)));
427 public void setupTestGetOrchestrationRequestInstanceGroup() throws Exception {
428 // For testGetOrchestrationRequest
429 wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-1a18-42e5-965d-8ea592502018"))
430 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
431 .withBody(new String(Files.readAllBytes(Paths.get(
432 "src/test/resources/OrchestrationRequest/getOrchestrationRequestInstanceGroup.json"))))
433 .withStatus(HttpStatus.SC_OK)));
435 .stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
436 .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-1a18-42e5-965d-8ea592502018"))
437 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
438 .withBody(new String(Files.readAllBytes(Paths
439 .get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
440 .withStatus(HttpStatus.SC_OK)));
443 private void setupTestGetOrchestrationRequestRequestDetails(String requestId, String status) throws Exception {
444 wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse()
445 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
446 .withBody(new String(Files.readAllBytes(
447 Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequestDetails.json"))))
448 .withStatus(HttpStatus.SC_OK)));
451 private void setupTestGetOrchestrationRequestOpenstackDetails(String requestId, String status) throws Exception {
452 wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId))).willReturn(aResponse()
453 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
454 .withBody(new String(Files.readAllBytes(Paths
455 .get("src/test/resources/OrchestrationRequest/getOrchestrationOpenstackRequestDetails.json"))))
456 .withStatus(HttpStatus.SC_OK)));
459 private void setupTestUnlockOrchestrationRequest(String requestId, String status) {
460 wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestId)))
461 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
462 .withBody(String.format(getResponseTemplate, requestId, status)).withStatus(HttpStatus.SC_OK)));
465 private void setupTestUnlockOrchestrationRequest_invalid_Json() {
466 wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(INVALID_REQUEST_ID))).willReturn(aResponse()
467 .withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).withStatus(HttpStatus.SC_NOT_FOUND)));
471 private void setupTestUnlockOrchestrationRequest_Valid_Status(String requestID, String status) {
472 wireMockServer.stubFor(get(urlPathEqualTo(getTestUrl(requestID)))
473 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
474 .withBody(String.format(getResponseTemplate, requestID, status)).withStatus(HttpStatus.SC_OK)));
476 wireMockServer.stubFor(post(urlPathEqualTo(getTestUrl("")))
477 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
478 .withBody(String.format(infraActivePost, requestID)).withStatus(HttpStatus.SC_OK)));
481 private void setupTestGetOrchestrationRequestFilter() throws Exception {
482 // for testGetOrchestrationRequestFilter();
483 wireMockServer.stubFor(any(urlPathEqualTo("/infraActiveRequests/getOrchestrationFiltersFromInfraActive/"))
484 .withRequestBody(equalToJson("{\"modelType\":[\"EQUALS\",\"vfModule\"]}"))
485 .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
486 .withBody(new String(Files.readAllBytes(
487 Paths.get("src/test/resources/OrchestrationRequest/getRequestDetailsFilter.json"))))
488 .withStatus(HttpStatus.SC_OK)));