Search in sources :

Example 21 with Request

use of org.onap.so.serviceinstancebeans.Request 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"));
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) HashMap(java.util.HashMap) Request(org.onap.so.serviceinstancebeans.Request) ArrayList(java.util.ArrayList) GetOrchestrationResponse(org.onap.so.serviceinstancebeans.GetOrchestrationResponse) RequestProcessingData(org.onap.so.serviceinstancebeans.RequestProcessingData) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) Test(org.junit.Test)

Example 22 with Request

use of org.onap.so.serviceinstancebeans.Request 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());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) HashMap(java.util.HashMap) Request(org.onap.so.serviceinstancebeans.Request) ArrayList(java.util.ArrayList) GetOrchestrationResponse(org.onap.so.serviceinstancebeans.GetOrchestrationResponse) RequestProcessingData(org.onap.so.serviceinstancebeans.RequestProcessingData) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) Test(org.junit.Test)

Example 23 with Request

use of org.onap.so.serviceinstancebeans.Request in project so by onap.

the class OrchestrationRequestsTest method getOrchestrationRequestSimpleTest.

@Test
public void getOrchestrationRequestSimpleTest() throws Exception {
    setupTestGetOrchestrationRequest();
    // TEST VALID REQUEST
    GetOrchestrationResponse testResponse = new GetOrchestrationResponse();
    Request request = ORCHESTRATION_LIST.getRequestList().get(1).getRequest();
    request.setRequestProcessingData(null);
    testResponse.setRequest(request);
    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, "e5e3c007-9fe9-4a20-8691-bdd20e14504d");
    HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v7/" + testRequestId)).queryParam("format", "simple");
    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"));
    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("e5e3c007-9fe9-4a20-8691-bdd20e14504d", response.getHeaders().get("X-TransactionID").get(0));
    assertNotNull(response.getBody().getRequest().getFinishTime());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) Request(org.onap.so.serviceinstancebeans.Request) GetOrchestrationResponse(org.onap.so.serviceinstancebeans.GetOrchestrationResponse) Test(org.junit.Test)

Example 24 with Request

use of org.onap.so.serviceinstancebeans.Request in project so by onap.

the class OrchestrationRequestsTest method testGetOrchestrationRequestFilter.

@Test
public void testGetOrchestrationRequestFilter() throws Exception {
    setupTestGetOrchestrationRequestFilter();
    List<String> values = new ArrayList<>();
    values.add("EQUALS");
    values.add("vfModule");
    ObjectMapper mapper = new ObjectMapper();
    GetOrchestrationListResponse testResponse = mapper.readValue(new File("src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json"), GetOrchestrationListResponse.class);
    Map<String, List<String>> orchestrationMap = new HashMap<>();
    orchestrationMap.put("modelType", values);
    List<InfraActiveRequests> requests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap);
    HttpHeaders headers = new HttpHeaders();
    headers.set("Accept", MediaType.APPLICATION_JSON);
    HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6?filter=modelType:EQUALS:vfModule"));
    ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationListResponse.class);
    assertThat(response.getBody(), sameBeanAs(testResponse).ignoring("requestList.request.startTime").ignoring("requestList.request.finishTime").ignoring("requestList.request.requestStatus.timeStamp"));
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
    assertEquals(requests.size(), response.getBody().getRequestList().size());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) GetOrchestrationListResponse(org.onap.so.serviceinstancebeans.GetOrchestrationListResponse) HttpEntity(org.springframework.http.HttpEntity) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Request(org.onap.so.serviceinstancebeans.Request) InfraActiveRequests(org.onap.so.db.request.beans.InfraActiveRequests) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 25 with Request

use of org.onap.so.serviceinstancebeans.Request in project so by onap.

the class OrchestrationRequestsTest method testGetOrchestrationRequestNoRequestID.

@Test
public void testGetOrchestrationRequestNoRequestID() {
    HttpHeaders headers = new HttpHeaders();
    headers.set("Accept", "application/json; charset=UTF-8");
    headers.set("Content-Type", "application/json; charset=UTF-8");
    HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("/onap/so/infra/orchestrationRequests/v6/"));
    ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, GetOrchestrationListResponse.class);
    assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value());
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) GetOrchestrationListResponse(org.onap.so.serviceinstancebeans.GetOrchestrationListResponse) HttpEntity(org.springframework.http.HttpEntity) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) Request(org.onap.so.serviceinstancebeans.Request) Test(org.junit.Test)

Aggregations

Request (org.onap.so.serviceinstancebeans.Request)25 Test (org.junit.Test)22 InstanceReferences (org.onap.so.serviceinstancebeans.InstanceReferences)15 SimpleDateFormat (java.text.SimpleDateFormat)14 RequestStatus (org.onap.so.serviceinstancebeans.RequestStatus)14 HttpEntity (org.springframework.http.HttpEntity)8 HttpHeaders (org.springframework.http.HttpHeaders)8 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)8 GetOrchestrationResponse (org.onap.so.serviceinstancebeans.GetOrchestrationResponse)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ResponseBuilder (org.onap.so.apihandler.common.ResponseBuilder)3 ValidateException (org.onap.so.apihandlerinfra.exceptions.ValidateException)3 ErrorLoggerInfo (org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo)3 InfraActiveRequests (org.onap.so.db.request.beans.InfraActiveRequests)3 ValidationException (org.onap.so.exceptions.ValidationException)3 GetOrchestrationListResponse (org.onap.so.serviceinstancebeans.GetOrchestrationListResponse)3 RequestProcessingData (org.onap.so.serviceinstancebeans.RequestProcessingData)3 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)3