diff options
10 files changed, 218 insertions, 27 deletions
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index 6553e2ba53..32e7d4a6ac 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -15,7 +15,7 @@ <properties> <camunda.version>7.8.0</camunda.version> <spring.version>4.3.2.RELEASE</spring.version> - <httpclient.version>3.1</httpclient.version> + <httpclient.version>4.5.5</httpclient.version> <jax.ws.rs>2.0.1</jax.ws.rs> <jackson.version>1.1.1</jackson.version> <maven.compiler.target>1.8</maven.compiler.target> @@ -386,8 +386,8 @@ <version>1.6.12</version> </dependency> <dependency> - <groupId>commons-httpclient</groupId> - <artifactId>commons-httpclient</artifactId> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> <version>${httpclient.version}</version> </dependency> <dependency> @@ -417,13 +417,6 @@ <version>${spring.version}</version> </dependency> --> - <!-- bwj: duplicated - <dependency> - <groupId>commons-httpclient</groupId> - <artifactId>commons-httpclient</artifactId> - <version>${httpclient.version}</version> - </dependency> - --> <!-- bwj: added --> <dependency> <groupId>com.googlecode.libphonenumber</groupId> diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml index 110c4da4ff..93b6c8fbb5 100644 --- a/mso-api-handlers/mso-api-handler-infra/pom.xml +++ b/mso-api-handlers/mso-api-handler-infra/pom.xml @@ -94,9 +94,9 @@ <version>1.9.13</version> </dependency> <dependency> - <groupId>org.codehaus.jackson</groupId> - <artifactId>jackson-mapper-asl</artifactId> - <version>1.9.13</version> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + <version>2.8.7</version> </dependency> <dependency> diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java index 6d6227af37..2e0b53d5d8 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java @@ -40,7 +40,7 @@ import javax.ws.rs.core.Response; import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
-import org.codehaus.jackson.map.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.hibernate.Session;
import org.json.JSONObject;
import org.openecomp.mso.apihandler.common.ErrorNumbers;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java index 204dd3e773..2c61d6eb6b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/CompareModelsRequest.java @@ -20,7 +20,7 @@ package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans; -import org.codehaus.jackson.map.annotate.JsonSerialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class CompareModelsRequest { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java index c05b0977ba..a88e8f5831 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/DelE2ESvcResp.java @@ -20,7 +20,7 @@ package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans; -import org.codehaus.jackson.map.annotate.JsonSerialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; @JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT) public class DelE2ESvcResp { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java index e7ff2f611d..5b48cbecbc 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/E2ERequest.java @@ -23,7 +23,7 @@ package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans; import java.sql.Timestamp;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_DEFAULT)
public class E2ERequest {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java index 041372356b..18cdd993c6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java @@ -21,7 +21,7 @@ package org.openecomp.mso.apihandlerinfra.e2eserviceinstancebeans;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.openecomp.mso.requestsdb.OperationStatus;
@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java index 4920814e32..590ac7cbed 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java @@ -670,7 +670,7 @@ public class E2EServiceInstancesTest { Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
assertTrue(respStr
- .contains("Mapping of request to JSON object failed. No content to map to Object due to end of input"));
+ .contains("Mapping of request to JSON object failed. No content to map due to end-of-input"));
}
@Ignore // 1802 merge
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java index 3c35fed516..b182192257 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java @@ -22,6 +22,9 @@ package org.openecomp.mso.apihandlerinfra; import static org.junit.Assert.assertTrue; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.Field; import java.net.URI; import java.sql.Timestamp; @@ -34,20 +37,38 @@ import javax.ws.rs.core.UriInfo; import mockit.Mock; import mockit.MockUp; +import org.apache.http.HttpResponse; +import org.apache.http.ProtocolVersion; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.entity.BasicHttpEntity; +import org.apache.http.message.BasicHttpResponse; +import org.junit.AfterClass; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; +import org.openecomp.mso.apihandler.common.CamundaClient; import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.NetworkRecipe; +import org.openecomp.mso.db.catalog.beans.VfModule; +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.properties.MsoPropertiesFactory; import org.openecomp.mso.requestsdb.InfraActiveRequests; import org.openecomp.mso.requestsdb.InfraRequests; import org.openecomp.mso.requestsdb.RequestsDatabase; public class NetworkRequestHandlerTest { + private static final String REQ_XML = "<network-request xmlns=\"http://org.openecomp/mso/infra/network-request/v1\"> <request-info> <request-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</request-id><action>CREATE</action> <source>VID</source> <service-instance-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</service-instance-id></request-info> <network-inputs> <network-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</network-id> <network-name>nwInstanceName</network-name> <network-type>nwModelName</network-type><modelCustomizationId>e1fc3ed3-31e5-48a8-913b-23184c1e9443</modelCustomizationId> <aic-cloud-region>e1fc3ed3-31e5-48a8-913b-23184c1e9443</aic-cloud-region> <tenant-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</tenant-id><service-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</service-id> <backout-on-failure>false</backout-on-failure><sdncVersion>1802</sdncVersion><service-instance-id>e1fc3ed3-31e5-48a8-913b-23184c1e9443</service-instance-id></network-inputs> <network-params></network-params> </network-request>"; + + private static MockUp<RequestsDatabase> mockRDB; + private static MockUp<NetworkMsoInfraRequest> mockMsoRequest; + private static MockUp<CatalogDatabase> mockCDB; + private static MockUp<CamundaClient> mockCamundaClient; NetworkRequestHandler handler = null; - -UriInfo uriInfo = null; + UriInfo uriInfo = null; @Before public void setup() throws Exception{ @@ -63,31 +84,127 @@ UriInfo uriInfo = null; f1.set(handler, uriInfo); } + + @BeforeClass + public static void setUp() throws Exception { + MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + msoPropertiesFactory.removeAllMsoProperties(); + msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties"); + + mockRDB = new MockUp<RequestsDatabase>() { + @Mock + public InfraActiveRequests checkDuplicateByVnfName (String vnfName, String action, String requestType) { + return null; + } + @Mock + public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) { + return 1; + } + + @Mock + public int updateInfraFinalStatus (String requestId, String requestStatus, String statusMessage, long progress, String responseBody, String lastModifiedBy) { + return 1; + } + }; + + mockMsoRequest = new MockUp<NetworkMsoInfraRequest>() { + @Mock + public void createRequestRecord (Status status) { + return; + } + }; + + mockCDB = new MockUp<CatalogDatabase>() { + @Mock + public NetworkRecipe getNetworkRecipe (String networkType, String action, String serviceType) { + final NetworkRecipe networkRecipe = new NetworkRecipe(); + networkRecipe.setOrchestrationUri("test/vnf"); + networkRecipe.setRecipeTimeout(180); + return networkRecipe; + } + + @Mock + public VfModule getVfModuleType(String type, String version) { + final VfModule vfModule = new VfModule(); + return vfModule; + } + + @Mock + public VnfResource getVnfResource (String vnfType, String serviceVersion) { + final VnfResource vnfResource = new VnfResource(); + return vnfResource; + } + }; + + mockCamundaClient = new MockUp<CamundaClient>() { + @Mock + public HttpResponse post(String camundaReqXML, String requestId, + String requestTimeout, String schemaVersion, String serviceInstanceId, String action) + throws ClientProtocolException, IOException { + ProtocolVersion pv = new ProtocolVersion("HTTP",1,1); + HttpResponse resp = new BasicHttpResponse(pv,200, "test response"); + BasicHttpEntity entity = new BasicHttpEntity(); + String body = "{\"response\":\"success\",\"message\":\"success\"}"; + InputStream instream = new ByteArrayInputStream(body.getBytes()); + entity.setContent(instream); + resp.setEntity(entity); + return resp; + } + }; + + } + + @AfterClass + public static void tearDown() { + mockRDB.tearDown(); + mockMsoRequest.tearDown(); + mockCDB.tearDown(); + mockCamundaClient.tearDown(); + } @Test public void manageVnfRequestTest(){ Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageNetworkRequest("<name>Test</name>", "v2"); + Response resp = handler.manageNetworkRequest(REQ_XML, "v2"); assertTrue(null != resp); } @Test public void manageVnfRequestTestV1(){ Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageNetworkRequest("<name>Test</name>", "v1"); + Response resp = handler.manageNetworkRequest(REQ_XML, "v1"); assertTrue(null != resp); } @Test public void manageVnfRequestTestV3(){ Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); - Response resp = handler.manageNetworkRequest("<name>Test</name>", "v3"); + Response resp = handler.manageNetworkRequest(REQ_XML, "v3"); assertTrue(null != resp); } + + /*@Test + public void manageNetworkRequestTestV3Duplicate(){ + + MockUp<RequestsDatabase> mockDuplicate = new MockUp<RequestsDatabase>() { + @Mock + public InfraActiveRequests checkDuplicateByVnfName(String vnfName, String action, String requestType) { + return new InfraActiveRequests(); + } + }; + + try { + Mockito.when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:8080/test")); + Response resp = handler.manageNetworkRequest(REQ_XML, "v3"); + assertTrue(null != resp); + } finally { + mockDuplicate.tearDown(); + } + }*/ @Test public void manageVnfRequestTestInvalidVersion(){ - Response resp = handler.manageNetworkRequest("<name>Test</name>", "v249"); + Response resp = handler.manageNetworkRequest(REQ_XML, "v249"); assertTrue(null != resp); } @@ -102,7 +219,7 @@ UriInfo uriInfo = null; return false; } }; - Response resp = handler.manageNetworkRequest("<name>Test</name>", "v2"); + Response resp = handler.manageNetworkRequest(REQ_XML, "v2"); assertTrue(null != resp); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java index 78ed076b55..ffdf5d40b4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java @@ -22,14 +22,78 @@ package org.openecomp.mso.apihandlerinfra; import static org.junit.Assert.assertTrue; +import mockit.Mock; +import mockit.MockUp; +import org.apache.http.HttpResponse; +import org.apache.http.ProtocolVersion; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.entity.BasicHttpEntity; +import org.apache.http.message.BasicHttpResponse; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; +import org.openecomp.mso.apihandler.common.CamundaClient; +import org.openecomp.mso.apihandlerinfra.volumebeans.ActionType; +import org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType; import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.NetworkRecipe; +import org.openecomp.mso.db.catalog.beans.VfModule; +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import org.openecomp.mso.requestsdb.InfraActiveRequests; import org.openecomp.mso.requestsdb.InfraRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; + +import javax.ws.rs.core.Response; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Timestamp; +import java.time.LocalDateTime; +import java.util.Collections; +import java.util.List; public class VolumeInfoHandlerTest { VolumeInfoHandler handler = new VolumeInfoHandler(); - + + private static MockUp<RequestsDatabase> mockRDB; + + @BeforeClass + public static void setUp() throws Exception { + MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + msoPropertiesFactory.removeAllMsoProperties(); + msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties"); + + mockRDB = new MockUp<RequestsDatabase>() { + @Mock + public List<InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName, + String queryValue, + String requestType) { + final InfraActiveRequests requests = new InfraActiveRequests(); + requests.setAction(ActionType.CREATE.name()); + requests.setRequestStatus(RequestStatusType.IN_PROGRESS.name()); + requests.setStartTime(Timestamp.valueOf(LocalDateTime.now())); + return Collections.singletonList(requests); + } + @Mock + public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) { + final InfraActiveRequests requests = new InfraActiveRequests(); + requests.setAction(ActionType.CREATE.name()); + requests.setRequestStatus(RequestStatusType.IN_PROGRESS.name()); + requests.setStartTime(Timestamp.valueOf(LocalDateTime.now())); + return requests; + } + }; + + } + + @AfterClass + public static void tearDown() { + mockRDB.tearDown(); + } + @Test public void fillVnfRequestTestV3(){ VolumeRequest qr = new VolumeRequest(); @@ -51,4 +115,21 @@ public class VolumeInfoHandlerTest { String vnfid = (String)qr.getVolumeParams(); assertTrue(vnfid.equals("test")); } + + @Test + public void queryFilters() { + final Response response = handler.queryFilters("vnf-type", "svc-type", "aicNode", "tenant-id", + "vg-id", "vg-name", "v3"); + } + + @Test + public void queryFilters2() { + final Response response = handler.queryFilters(null, "svc-type", "aicNode", "tenant-id", + "vg-id", "vg-name", "v3"); + } + + @Test + public void getRequest() { + final Response response = handler.getRequest("request-id", "v3"); + } } |