summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java68
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java38
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java93
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java139
4 files changed, 335 insertions, 3 deletions
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 3feb168f51..3c5c89fc92 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
@@ -24,6 +24,9 @@ import static org.junit.Assert.assertTrue;
import java.lang.reflect.Field;
import java.net.URI;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -35,7 +38,9 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.openecomp.mso.apihandlerinfra.networkbeans.NetworkRequest;
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.InfraRequests;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
public class NetworkRequestHandlerTest {
@@ -61,6 +66,23 @@ UriInfo uriInfo = null;
Response resp = handler.manageNetworkRequest("<name>Test</name>", "v2");
assertTrue(null != resp);
}
+ @Test
+ public void manageVnfRequestTestV1(){
+ Response resp = handler.manageNetworkRequest("<name>Test</name>", "v1");
+ assertTrue(null != resp);
+ }
+
+ @Test
+ public void manageVnfRequestTestV3(){
+ Response resp = handler.manageNetworkRequest("<name>Test</name>", "v3");
+ assertTrue(null != resp);
+ }
+
+ @Test
+ public void manageVnfRequestTestInvalidVersion(){
+ Response resp = handler.manageNetworkRequest("<name>Test</name>", "v249");
+ assertTrue(null != resp);
+ }
@Test
public void manageVnfRequest2Test(){
@@ -150,4 +172,50 @@ UriInfo uriInfo = null;
assertTrue(param.equals("test"));
}
+ @Test
+ public void queryFiltersTest(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName,
+ String queryValue,
+ String requestType) {
+ List <InfraActiveRequests> list = new ArrayList<InfraActiveRequests>();
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ list.add(req);
+ return list;
+ }
+ };
+ Response resp = handler.queryFilters("networkType", "serviceType", "aicNodeClli", "tenantId", "v1");
+ assertTrue(resp.getEntity().toString() != null);
+ }
+
+ @Test
+ public void getRequestTest(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) {
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ return req;
+ }
+ };
+ Response resp = handler.getRequest("388293", "v1");
+ assertTrue(resp.getEntity().toString() != null);
+ }
+
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java
new file mode 100644
index 0000000000..c8ab6b5612
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfMsoInfraRequestTest.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.apihandlerinfra;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.openecomp.mso.apihandler.common.ValidationException;
+import org.openecomp.mso.properties.MsoJavaProperties;
+
+public class VnfMsoInfraRequestTest {
+ VnfMsoInfraRequest request = new VnfMsoInfraRequest("29919020");
+
+ @Test(expected=Exception.class)
+ public void parseTest() throws ValidationException {
+ String reqXML = "<vnf-request><request-info> <request-id>29993</request-id><request-status>COMPLETE</request-status></request-info></vnf-request>";
+ request.parse(reqXML, "v1", new MsoJavaProperties());
+ }
+
+}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java
index 8d06b40074..2d3a2a47a5 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VnfRequestHandlerTest.java
@@ -24,6 +24,9 @@ import static org.junit.Assert.assertTrue;
import java.lang.reflect.Field;
import java.net.URI;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
import mockit.Mock;
import mockit.MockUp;
@@ -32,7 +35,9 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.openecomp.mso.apihandlerinfra.vnfbeans.VnfRequest;
+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 javax.ws.rs.core.UriInfo;
@@ -55,10 +60,25 @@ public class VnfRequestHandlerTest {
}
@Test
- public void manageVnfRequestTest(){
+ public void manageVnfRequestTestV2(){
Response resp = handler.manageVnfRequest("<name>Test</name>", "v2");
assertTrue(null != resp);
}
+ @Test
+ public void manageVnfRequestTestv1(){
+ Response resp = handler.manageVnfRequest("<name>Test</name>", "v1");
+ assertTrue(null != resp);
+ }
+ @Test
+ public void manageVnfRequestTestv3(){
+ Response resp = handler.manageVnfRequest("<name>Test</name>", "v3");
+ assertTrue(null != resp);
+ }
+ @Test
+ public void manageVnfRequestTestInvalidVersion(){
+ Response resp = handler.manageVnfRequest("<name>Test</name>", "v30");
+ assertTrue(null != resp);
+ }
@Test
public void manageVnfRequest2Test(){
@@ -149,5 +169,76 @@ public class VnfRequestHandlerTest {
String param = (String)qr.getVnfParams();
assertTrue(param.equals("test"));
}
+
+ @Test
+ public void queryFiltersTest(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName,
+ String queryValue,
+ String requestType) {
+ List <InfraActiveRequests> list = new ArrayList<InfraActiveRequests>();
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ list.add(req);
+ return list;
+ }
+ };
+ Response resp = handler.queryFilters("vnfType", "serviceType", "aicNodeClli", "tenantId", "volumeGroupId", "volumeGroupName", "vnfName", "v1");
+ assertTrue(resp.getEntity().toString() != null);
+ }
+
+ @Test
+ public void queryFiltersTestNullVnfType(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName,
+ String queryValue,
+ String requestType) {
+ List <InfraActiveRequests> list = new ArrayList<InfraActiveRequests>();
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ list.add(req);
+ return list;
+ }
+ };
+ Response resp = handler.queryFilters(null, null, null, null, null, null, null, "v1");
+ assertTrue(resp.getEntity().toString() != null);
+ }
+
+ @Test
+ public void getRequestTest(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) {
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ return req;
+ }
+ };
+ Response resp = handler.getRequest("388293", "v1");
+ assertTrue(resp.getEntity().toString() != null);
+ }
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java
index be41944b31..bf4d7c4d98 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeRequestHandlerTest.java
@@ -24,6 +24,9 @@ import static org.junit.Assert.assertTrue;
import java.lang.reflect.Field;
import java.net.URI;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
@@ -34,6 +37,10 @@ import mockit.MockUp;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.openecomp.mso.apihandler.common.ValidationException;
+import org.openecomp.mso.properties.MsoJavaProperties;
+import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.RequestsDatabase;
public class VolumeRequestHandlerTest {
VolumeRequestHandler handler = null;
@@ -60,7 +67,7 @@ public class VolumeRequestHandlerTest {
}
@Test
- public void manageVnfRequest2Test(){
+ public void manageVnfRequest2TestV1InvalidRequestData(){
Mockito.when(uriInfo.getRequestUri())
.thenReturn(URI.create("http://localhost:8080/test"));
@@ -70,7 +77,135 @@ public class VolumeRequestHandlerTest {
return false;
}
};
- Response resp = handler.manageVolumeRequest("<name>Test</name>", "v2");
+ String request = "{\"result\":\"success\"}";
+ Response resp = handler.manageVolumeRequest(request, "v1");
+ assertTrue(null != resp);
+ }
+
+ @Test
+ public void manageVnfRequest2TestV1(){
+ Mockito.when(uriInfo.getRequestUri())
+ .thenReturn(URI.create("http://localhost:8080/test"));
+
+ new MockUp<MsoPropertiesUtils>() {
+ @Mock
+ public synchronized final boolean getNoPropertiesState() {
+ return false;
+ }
+ };
+ String request = "<volume-request xmlns=\"http://org.openecomp/mso/infra/volume-request/v1\"><request-info><action>CREATE</action><request-status>COMPLETE</request-status><status-message>message</status-message><progress>10001</progress><start-time>1970-01-01 02:47:00.1</start-time><end-time>1970-01-01 05:33:40.1</end-time><source>test</source></request-info><volume-inputs><service-id>299392</service-id></volume-inputs></volume-request>";
+ Response resp = handler.manageVolumeRequest(request, "v1");
+ assertTrue(null != resp);
+ }
+
+ @Test
+ public void manageVnfRequest2TestV2(){
+ Mockito.when(uriInfo.getRequestUri())
+ .thenReturn(URI.create("http://localhost:8080/test"));
+
+ new MockUp<MsoPropertiesUtils>() {
+ @Mock
+ public synchronized final boolean getNoPropertiesState() {
+ return false;
+ }
+ };
+ String request = "<volume-request xmlns=\"http://org.openecomp/mso/infra/volume-request/v2\"><request-info><action>CREATE</action><request-status>COMPLETE</request-status><status-message>message</status-message><progress>10001</progress><start-time>1970-01-01 02:47:00.1</start-time><end-time>1970-01-01 05:33:40.1</end-time><source>test</source></request-info><volume-inputs><service-id>299392</service-id></volume-inputs></volume-request>";
+ Response resp = handler.manageVolumeRequest(request, "v2");
assertTrue(null != resp);
}
+ @Test
+ public void manageVnfRequest2TestV3(){
+ Mockito.when(uriInfo.getRequestUri())
+ .thenReturn(URI.create("http://localhost:8080/test"));
+
+ new MockUp<MsoPropertiesUtils>() {
+ @Mock
+ public synchronized final boolean getNoPropertiesState() {
+ return false;
+ }
+ };
+ String request = "<volume-request xmlns=\"http://org.openecomp/mso/infra/volume-request/v3\"><request-info><action>CREATE</action><request-status>COMPLETE</request-status><status-message>message</status-message><progress>10001</progress><start-time>1970-01-01 02:47:00.1</start-time><end-time>1970-01-01 05:33:40.1</end-time><source>test</source></request-info><volume-inputs><service-id>299392</service-id></volume-inputs></volume-request>";
+ Response resp = handler.manageVolumeRequest(request, "v3");
+ assertTrue(null != resp);
+ }
+ @Test
+ public void manageVnfRequest2TestInvalidVersion(){
+ Mockito.when(uriInfo.getRequestUri())
+ .thenReturn(URI.create("http://localhost:8080/test"));
+
+ new MockUp<MsoPropertiesUtils>() {
+ @Mock
+ public synchronized final boolean getNoPropertiesState() {
+ return false;
+ }
+ };
+ String request = "<volume-request xmlns=\"http://org.openecomp/mso/infra/volume-request/v1\"><request-info><action>CREATE</action><request-status>COMPLETE</request-status><status-message>message</status-message><progress>10001</progress><start-time>1970-01-01 02:47:00.1</start-time><end-time>1970-01-01 05:33:40.1</end-time><source>test</source></request-info><volume-inputs><service-id>299392</service-id></volume-inputs></volume-request>";
+ Response resp = handler.manageVolumeRequest(request, "v33");
+ assertTrue(null != resp);
+ }
+
+ @Test
+ public void queryFiltersTest(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public List <InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName,
+ String queryValue,
+ String requestType) {
+ List <InfraActiveRequests> list = new ArrayList<InfraActiveRequests>();
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ list.add(req);
+ return list;
+ }
+ };
+ Response resp = handler.queryFilters("vnfType", "serviceType", "aic", "19929293", "288393923", "test", "v1");
+ assertTrue(resp.getEntity().toString() != null);
+ }
+ @Test
+ public void getRequestTestV3(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) {
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ return req;
+ }
+ };
+ Response resp = handler.getRequest("399293", "v3");
+ assertTrue(resp.getEntity().toString() != null);
+ }
+ @Test
+ public void getRequestTestV2(){
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) {
+ InfraActiveRequests req = new InfraActiveRequests();
+ req.setAaiServiceId("299392");
+ req.setAction("CREATE");
+ req.setRequestStatus("COMPLETE");
+ req.setProgress(10001l);
+ req.setSource("test");
+ req.setStartTime(new Timestamp(10020100));
+ req.setEndTime(new Timestamp(20020100));
+ req.setStatusMessage("message");
+ return req;
+ }
+ };
+ Response resp = handler.getRequest("399293", "v2");
+ assertTrue(resp.getEntity().toString() != null);
+ }
}