use of org.onap.so.serviceinstancebeans.RequestProcessingData in project so by onap.
the class OrchestrationRequestsTest method testGetOrchestrationRequestWithOpenstackDetails.
@Test
public void testGetOrchestrationRequestWithOpenstackDetails() throws Exception {
setupTestGetOrchestrationRequestOpenstackDetails("00032ab7-3fb3-42e5-965d-8ea592502017", "COMPLETED");
// Test request with modelInfo request body
GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
Request request = ORCHESTRATION_LIST.getRequestList().get(0).getRequest();
List<CloudRequestData> cloudRequestData = new ArrayList<>();
CloudRequestData cloudData = new CloudRequestData();
cloudData.setCloudIdentifier("heatstackName/123123");
ObjectMapper mapper = new ObjectMapper();
Object reqData = mapper.readValue("{\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}", Object.class);
cloudData.setCloudRequest(reqData);
cloudRequestData.add(cloudData);
request.setCloudRequestData(cloudRequestData);
testResponse.setRequest(request);
String testRequestId = request.getRequestId();
testResponse.getRequest().setRequestProcessingData(new ArrayList<RequestProcessingData>());
RequestProcessingData e = new RequestProcessingData();
e.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
HashMap<String, String> data1 = new HashMap<String, String>();
data1.put("requestAction", "assign");
data.add(data1);
e.setDataPairs(data);
testResponse.getRequest().getRequestProcessingData().add(e);
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type", MediaType.APPLICATION_JSON);
headers.set(ONAPLogConstants.Headers.REQUEST_ID, "0321e28d-3dde-4b31-9b28-1e0f07231b93");
HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId + "?includeCloudRequest=true"));
ResponseEntity<GetOrchestrationResponse> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
System.out.println("Response :" + response.getBody().toString());
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime").ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
assertEquals("0321e28d-3dde-4b31-9b28-1e0f07231b93", response.getHeaders().get("X-TransactionID").get(0));
}
use of org.onap.so.serviceinstancebeans.RequestProcessingData in project so by onap.
the class OrchestrationRequestsTest method testGetOrchestrationRequestInstanceGroup.
@Test
public void testGetOrchestrationRequestInstanceGroup() throws Exception {
setupTestGetOrchestrationRequestInstanceGroup();
// TEST VALID REQUEST
GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
Request request = ORCHESTRATION_LIST.getRequestList().get(8).getRequest();
testResponse.setRequest(request);
testResponse.getRequest().setRequestProcessingData(new ArrayList<RequestProcessingData>());
RequestProcessingData e = new RequestProcessingData();
e.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
HashMap<String, String> data1 = new HashMap<String, String>();
data1.put("requestAction", "assign");
data.add(data1);
e.setDataPairs(data);
testResponse.getRequest().getRequestProcessingData().add(e);
String testRequestId = request.getRequestId();
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type", MediaType.APPLICATION_JSON);
HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
ResponseEntity<GetOrchestrationResponse> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime").ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
}
use of org.onap.so.serviceinstancebeans.RequestProcessingData in project so by onap.
the class OrchestrationRequestsTest method testGetOrchestrationRequest.
@Test
public void testGetOrchestrationRequest() throws Exception {
setupTestGetOrchestrationRequest();
// TEST VALID REQUEST
GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
Request request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
testResponse.setRequest(request);
testResponse.getRequest().setRequestProcessingData(new ArrayList<RequestProcessingData>());
RequestProcessingData e = new RequestProcessingData();
e.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
List<HashMap<String, String>> data = new ArrayList<HashMap<String, String>>();
HashMap<String, String> data1 = new HashMap<String, String>();
data1.put("requestAction", "assign");
data.add(data1);
e.setDataPairs(data);
testResponse.getRequest().getRequestProcessingData().add(e);
String testRequestId = request.getRequestId();
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON);
headers.set("Content-Type", MediaType.APPLICATION_JSON);
headers.set(ONAPLogConstants.Headers.REQUEST_ID, "1e45215d-b7b3-4c5a-9316-65bdddaf649f");
HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId));
ResponseEntity<GetOrchestrationResponse> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationResponse.class);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("request.startTime").ignoring("request.finishTime").ignoring("request.requestStatus.timeStamp"));
assertNull(response.getBody().getRequest().getInstanceReferences().getRequestorId());
assertEquals("application/json", response.getHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
assertEquals("0", response.getHeaders().get("X-MinorVersion").get(0));
assertEquals("0", response.getHeaders().get("X-PatchVersion").get(0));
assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
assertEquals("1e45215d-b7b3-4c5a-9316-65bdddaf649f", response.getHeaders().get("X-TransactionID").get(0));
assertNotNull(response.getBody().getRequest().getFinishTime());
}
use of org.onap.so.serviceinstancebeans.RequestProcessingData in project so by onap.
the class OrchestrationRequestsTest method mapRequestProcessingDataTest.
@Test
public void mapRequestProcessingDataTest() throws JsonParseException, JsonMappingException, IOException {
RequestProcessingData entry = new RequestProcessingData();
RequestProcessingData secondEntry = new RequestProcessingData();
List<HashMap<String, String>> expectedList = new ArrayList<>();
HashMap<String, String> expectedMap = new HashMap<>();
List<HashMap<String, String>> secondExpectedList = new ArrayList<>();
HashMap<String, String> secondExpectedMap = new HashMap<>();
List<RequestProcessingData> expectedDataList = new ArrayList<>();
entry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca714");
expectedMap.put("requestAction", "assign");
expectedMap.put("fabricId", "testId");
expectedList.add(expectedMap);
entry.setDataPairs(expectedList);
secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715");
secondExpectedMap.put("requestAction", "unassign");
secondExpectedList.add(secondExpectedMap);
secondEntry.setDataPairs(secondExpectedList);
expectedDataList.add(entry);
expectedDataList.add(secondEntry);
List<org.onap.so.db.request.beans.RequestProcessingData> processingData = new ArrayList<>();
List<RequestProcessingData> actualProcessingData = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
processingData = mapper.readValue(new File("src/test/resources/OrchestrationRequest/RequestProcessingData.json"), new TypeReference<List<org.onap.so.db.request.beans.RequestProcessingData>>() {
});
actualProcessingData = orchReq.mapRequestProcessingData(processingData);
assertThat(actualProcessingData, sameBeanAs(expectedDataList));
}
Aggregations