aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/test/java
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-09-04 11:21:02 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2018-09-08 22:33:28 -0400
commit69455a268648881f4b5a0c4547d769c2e6ecc2c1 (patch)
tree8ea753e5282e91316d842522c8873fd51572344c /mso-api-handlers/mso-api-handler-infra/src/test/java
parent3e9ee0977d0c8643f81e720bbf23e5a40864a0d8 (diff)
added generic fabric support to SO
Fix Autoincrement of ID field in table Fix accidental removal of method Update usage of requestdb client removed unused imports in common tasks and test Fix broken branch, have unit tests pass references the Epic branch Fix broken branch from compiling committing classpath for vfc adapter cause its not going away added in the fail case for when there are no profiles removed second set of adapters in application test yml removed double adapters in request db application test added jpa repo dependency to the so bpmn folder pom add creation timestamp column to the table added in null checks for Config returned from policy switched to string in requestprocess with jenerate switched to string in requestprocess with jenerate updated aai version in common pom to 605 from 591 renamed the db scripts for flyway sync to register added endpoint to application test yml for failing test ... Change-Id: I800f837ea75d7cdff740dc3a387e4d7654cfd085 Issue-ID: SO-972 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java9
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java106
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java8
3 files changed, 93 insertions, 30 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
index 5d6aa43a9b..76d4b48a36 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java
@@ -39,6 +39,7 @@ import javax.ws.rs.core.Response;
import org.apache.http.HttpStatus;
import org.apache.log4j.MDC;
import org.junit.Test;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.apihandlerinfra.tasksbeans.RequestDetails;
import org.onap.so.apihandlerinfra.tasksbeans.RequestInfo;
import org.onap.so.apihandlerinfra.tasksbeans.TaskRequestReference;
@@ -110,8 +111,8 @@ public class ManualTasksTest extends BaseTest{
logEvent.getMarker().getName().equals("ENTRY")
){
Map<String,String> mdc = logEvent.getMDCPropertyMap();
- assertNotNull(mdc.get(MsoLogger.BEGINTIME));
- assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
assertEquals("tasks/v1/55/complete",mdc.get(MsoLogger.SERVICE_NAME));
@@ -119,9 +120,9 @@ public class ManualTasksTest extends BaseTest{
}else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
logEvent.getMarker().getName().equals("EXIT")){
Map<String,String> mdc = logEvent.getMDCPropertyMap();
- assertNotNull(mdc.get(MsoLogger.BEGINTIME));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
assertNotNull(mdc.get(MsoLogger.ENDTIME));
- assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
assertEquals("202",mdc.get(MsoLogger.RESPONSECODE));
assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
index 582bc12077..9df66edc07 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
@@ -20,41 +20,56 @@
package org.onap.so.apihandlerinfra;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.any;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
+import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson;
+import static com.github.tomakehurst.wiremock.client.WireMock.get;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
import org.apache.http.HttpStatus;
import org.junit.Ignore;
import org.junit.Test;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.db.request.beans.InfraActiveRequests;
+import org.onap.so.db.request.client.RequestsDbClient;
import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository;
import org.onap.so.exceptions.ValidationException;
-import org.onap.so.requestsdb.client.RequestsDbClient;
-import org.onap.so.serviceinstancebeans.*;
+import org.onap.so.serviceinstancebeans.GetOrchestrationListResponse;
+import org.onap.so.serviceinstancebeans.GetOrchestrationResponse;
+import org.onap.so.serviceinstancebeans.Request;
+import org.onap.so.serviceinstancebeans.RequestError;
+import org.onap.so.serviceinstancebeans.RequestProcessingData;
+import org.onap.so.serviceinstancebeans.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.util.UriComponentsBuilder;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.*;
-import static com.shazam.shazamcrest.MatcherAssert.assertThat;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-import static org.junit.Assert.assertEquals;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class OrchestrationRequestsTest extends BaseTest {
@Autowired
@@ -62,6 +77,9 @@ public class OrchestrationRequestsTest extends BaseTest {
@Autowired
private RequestsDbClient requestsDbClient;
+
+ @Autowired
+ private OrchestrationRequests orchReq;
private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title></title></head><body></body></html>";
private static final GetOrchestrationListResponse ORCHESTRATION_LIST = generateOrchestrationList();
@@ -162,9 +180,14 @@ public class OrchestrationRequestsTest extends BaseTest {
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<GetOrchestrationResponse> testResponses = new ArrayList<>();
List<InfraActiveRequests> requests = requestsDbClient.getOrchestrationFiltersFromInfraActive(orchestrationMap);
HttpEntity<Request> entity = new HttpEntity<Request>(null, headers);
@@ -175,8 +198,11 @@ public class OrchestrationRequestsTest extends BaseTest {
ResponseEntity<GetOrchestrationListResponse> response = restTemplate.exchange(builder.toUriString(),
HttpMethod.GET, entity, GetOrchestrationListResponse.class);
+ assertThat(response.getBody(),
+ sameBeanAs(testResponse).ignoring("requestList.request.startTime").ignoring("requestList.request.requestStatus.finishTime"));
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
assertEquals(requests.size(), response.getBody().getRequestList().size());
+
}
@Test
@@ -334,12 +360,48 @@ public class OrchestrationRequestsTest extends BaseTest {
assertEquals("7.0.0", response.getHeaders().get("X-LatestVersion").get(0));
assertEquals("requestId", response.getHeaders().get("X-TransactionID").get(0));
}
+ @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");
+ entry.setTag("pincFabricConfigRequest");
+ expectedMap.put("requestAction", "assign");
+ expectedMap.put("pincFabricId", "testId");
+ expectedList.add(expectedMap);
+ entry.setDataPairs(expectedList);
+ secondEntry.setGroupingId("7d2e8c07-4d10-456d-bddc-37abf38ca715");
+ secondEntry.setTag("pincFabricConfig");
+ 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));
+ }
public void setupTestGetOrchestrationRequest() throws Exception{
//For testGetOrchestrationRequest
stubFor(any(urlPathEqualTo("/infraActiveRequests/00032ab7-na18-42e5-965d-8ea592502018")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getOrchestrationRequest.json"))))
.withStatus(HttpStatus.SC_OK)));
+ stubFor(get(urlPathEqualTo("/requestProcessingData/search/findBySoRequestIdOrderByGroupingIdDesc/"))
+ .withQueryParam("SO_REQUEST_ID", equalTo("00032ab7-na18-42e5-965d-8ea592502018"))
+ .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ .withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getRequestProcessingData.json"))))
+ .withStatus(HttpStatus.SC_OK)));
}
private void setupTestGetOrchestrationRequestRequestDetails(String requestId, String status) throws Exception{
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
index 76f4bb08a2..e9e50148ff 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java
@@ -189,8 +189,8 @@ public class ServiceInstancesTest extends BaseTest{
logEvent.getMarker().getName().equals("ENTRY")
){
Map<String,String> mdc = logEvent.getMDCPropertyMap();
- assertNotNull(mdc.get(MsoLogger.BEGINTIME));
- assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));
assertEquals("onap/so/infra/serviceInstantiation/v5/serviceInstances",mdc.get(MsoLogger.SERVICE_NAME));
@@ -198,9 +198,9 @@ public class ServiceInstancesTest extends BaseTest{
}else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") &&
logEvent.getMarker().getName().equals("EXIT")){
Map<String,String> mdc = logEvent.getMDCPropertyMap();
- assertNotNull(mdc.get(MsoLogger.BEGINTIME));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP));
assertNotNull(mdc.get(MsoLogger.ENDTIME));
- assertNotNull(mdc.get(MsoLogger.REQUEST_ID));
+ assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID));
assertNotNull(mdc.get(MsoLogger.INVOCATION_ID));
assertEquals("202",mdc.get(MsoLogger.RESPONSECODE));
assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME));