aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/ObjectFactoryTest.java23
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java9
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java18
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java14
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunablesTest.java31
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCResponseTest.java2
-rw-r--r--adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtilTest.java6
-rw-r--r--adapters/mso-workflow-message-adapter/src/test/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallbackTest.java42
-rw-r--r--aria/aria-rest-server/VERSION1
-rw-r--r--aria/aria-rest-server/setup.py8
-rw-r--r--aria/aria-rest-server/tox.ini2
-rw-r--r--bpmn/MSOCommonBPMN/pom.xml13
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/NetworkRequestHandlerTest.java131
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/VolumeInfoHandlerTest.java83
14 files changed, 324 insertions, 59 deletions
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/ObjectFactoryTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/ObjectFactoryTest.java
index 5e3f79add6..c3949a6a79 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/ObjectFactoryTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/ObjectFactoryTest.java
@@ -20,6 +20,11 @@
package org.openecomp.mso.adapters.sdnc;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import java.io.ByteArrayInputStream;
@@ -74,14 +79,14 @@ public class ObjectFactoryTest {
fail ();
}
String marshalled = writer.toString ();
- assert(marshalled.contains ("<RequestId>reqid</RequestId>"));
+ assertThat(marshalled, containsString("<RequestId>reqid</RequestId>"));
InputStream inputStream = new ByteArrayInputStream(marshalled.getBytes(Charset.forName("UTF-8")));
try {
RequestHeader res2 = (RequestHeader) jaxbUnmarshaller.unmarshal (inputStream);
- assert(res2.getCallbackUrl ().equals ("callback"));
- assert(res2.getMsoAction ().equals ("action"));
- assert(res2.getSvcOperation ().equals ("op"));
+ assertEquals("callback", res2.getCallbackUrl ());
+ assertEquals("action", res2.getMsoAction ());
+ assertEquals("op", res2.getSvcOperation ());
} catch (JAXBException e) {
e.printStackTrace();
fail();
@@ -95,6 +100,14 @@ public class ObjectFactoryTest {
public final void testCreateSDNCAdapterResponse () {
ObjectFactory of = new ObjectFactory ();
SDNCAdapterResponse ar = of.createSDNCAdapterResponse ();
- assert (ar != null);
+ assertNotNull(ar);
}
+
+ @Test
+ public final void testCreateSDNCAdapterRequest () {
+ ObjectFactory of = new ObjectFactory ();
+ SDNCAdapterRequest ar = of.createSDNCAdapterRequest ();
+ assertNotNull(ar);
+ }
+
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java
index fa96b7983e..b9d88406f9 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/SDNCAdapterRequestTest.java
@@ -21,6 +21,9 @@
package org.openecomp.mso.adapters.sdnc;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import org.junit.BeforeClass;
import org.junit.Test;
import org.openecomp.mso.adapters.sdnc.SDNCAdapterRequest;
@@ -46,9 +49,9 @@ public class SDNCAdapterRequestTest {
public final void testtoString(){
((SDNCAdapterRequest) sd).setRequestData("data");
((SDNCAdapterRequest) sd).setRequestHeader(rh);
- assert (((SDNCAdapterRequest) sd).getRequestData()!= null) ;
- assert(((SDNCAdapterRequest) sd).getRequestData().equals("data"));
- assert(((SDNCAdapterRequest) sd).getRequestHeader().equals(rh));
+ assertNotNull(((SDNCAdapterRequest) sd).getRequestData()) ;
+ assertEquals("data", ((SDNCAdapterRequest) sd).getRequestData());
+ assertEquals(rh, ((SDNCAdapterRequest) sd).getRequestHeader());
}
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java
index 88d2b950b9..39518e2081 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/CallbackHeaderTest.java
@@ -20,8 +20,10 @@
package org.openecomp.mso.adapters.sdnc.client;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import org.junit.Test;
-import org.openecomp.mso.adapters.sdnc.client.CallbackHeader;
public class CallbackHeaderTest {
@@ -32,16 +34,16 @@ public class CallbackHeaderTest {
cb.setRequestId("413658f4-7f42-482e-b834-23a5c15657da-1474471336781");
cb.setResponseCode("200");
cb.setResponseMessage("OK");
- assert (cb.getRequestId() != null);
- assert (cb.getResponseCode() != null);
- assert (cb.getResponseMessage() != null);
- assert (cb.getRequestId().equals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781"));
- assert (cb.getResponseCode().equals("200"));
- assert (cb.getResponseMessage().equals("OK"));
+ assertNotNull(cb.getRequestId());
+ assertNotNull(cb.getResponseCode());
+ assertNotNull(cb.getResponseMessage());
+ assertEquals("413658f4-7f42-482e-b834-23a5c15657da-1474471336781", cb.getRequestId());
+ assertEquals("200", cb.getResponseCode());
+ assertEquals("OK", cb.getResponseMessage());
}
@Test
public void testtoString() {
- assert (cb.toString() != null);
+ assertNotNull(cb.toString());
}
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java
index 63aa49cf54..ecffd1c5ad 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/client/SDNCAdapterCallbackRequestTest.java
@@ -21,6 +21,9 @@
package org.openecomp.mso.adapters.sdnc.client;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import org.junit.Test;
import org.openecomp.mso.adapters.sdnc.client.CallbackHeader;
import org.openecomp.mso.adapters.sdnc.client.SDNCAdapterCallbackRequest;
@@ -35,17 +38,18 @@ public class SDNCAdapterCallbackRequestTest {
{
sdc.setCallbackHeader(ch);
sdc.setRequestData("data");
- assert(sdc.getCallbackHeader()!=null);
- assert(sdc.getRequestData()!=null);
- assert(sdc.getCallbackHeader().equals(ch));
- assert(sdc.getRequestData().equals("data"));
+ assertNotNull(sdc.getCallbackHeader());
+ assertNotNull(sdc.getRequestData());
+ assertEquals(ch, sdc.getCallbackHeader());
+ assertEquals("data", sdc.getRequestData());
}
@Test
public void testtoString()
{
- assert(ch.toString()!=null);
+ assertNotNull(ch.toString());
+ assertNotNull(sdc.toString());
}
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunablesTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunablesTest.java
index 17ba0d22f8..72b11708e6 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunablesTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/RequestTunablesTest.java
@@ -20,6 +20,8 @@
package org.openecomp.mso.adapters.sdnc.impl;
+import static org.junit.Assert.*;
+
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
@@ -54,18 +56,31 @@ public class RequestTunablesTest {
@Test
public final void testRequestTunables () {
RequestTunables rt = new RequestTunables (null, null, "op", null,msoPropertiesFactory);
- assert(rt.getReqId ().length ()==0);
+ assertEquals(0, rt.getReqId ().length ());
rt = new RequestTunables ("reqId", "msoAction", null, "query",msoPropertiesFactory);
rt.setTunables ();
System.out.println(rt.toString ());
// assert (rt.getReqMethod ().equals ("toto"));
- assert (rt.getTimeout () != null);
- assert (rt.getAction ().equals ("query"));
- assert (rt.getMsoAction ().equals ("msoAction"));
- assert (rt.getHeaderName ().equals ("sdnc-request-header"));
- assert (rt.getOperation ().length () == 0);
- assert (rt.getAsyncInd ().equals ("N"));
- assert (rt.getReqId ().equals ("reqId"));
+ assertNotNull(rt.getTimeout ());
+ assertEquals("query", rt.getAction ());
+ assertEquals("msoAction", rt.getMsoAction ());
+ assertEquals("sdnc-request-header", rt.getHeaderName ());
+ assertEquals(0, rt.getOperation ().length ());
+ assertEquals("N", rt.getAsyncInd ());
+ assertEquals("reqId", rt.getReqId ());
+ }
+
+ @Test
+ public final void testRequestTunablesSet() {
+ RequestTunables rt = new RequestTunables("reqId", "gammainternet", "service-configuration-operation", "changeactivate", msoPropertiesFactory);
+ rt.setTunables ();
+ assertNotNull(rt.getTimeout ());
+ assertEquals("changeactivate", rt.getAction ());
+ assertEquals("gammainternet", rt.getMsoAction ());
+ assertEquals("sdnc-request-header", rt.getHeaderName ());
+ assertEquals("service-configuration-operation", rt.getOperation ());
+ assertEquals("N", rt.getAsyncInd ());
+ assertEquals("reqId", rt.getReqId ());
}
}
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCResponseTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCResponseTest.java
index f8867ae4f8..f9c885f0eb 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCResponseTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/impl/SDNCResponseTest.java
@@ -43,7 +43,7 @@ public class SDNCResponseTest {
@Test
public void testtoString()
{
- assert(sdncresponse.toString()!=null);
+ assertNotNull(sdncresponse.toString());
}
}
\ No newline at end of file
diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtilTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtilTest.java
index 275c2acd14..77d22e44df 100644
--- a/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtilTest.java
+++ b/adapters/mso-sdnc-adapter/src/test/java/org/openecomp/mso/adapters/sdnc/util/SDNCRequestIdUtilTest.java
@@ -20,6 +20,8 @@
package org.openecomp.mso.adapters.sdnc.util;
+import static org.junit.Assert.assertEquals;
+
import java.util.UUID;
import org.junit.Test;
@@ -35,8 +37,8 @@ public class SDNCRequestIdUtilTest {
String postfixedRequestId = originalRequestId + "-1466203712068";
String postfixedRequestId2 = originalRequestId + "-1466203712068-2";
- assert(SDNCRequestIdUtil.getSDNCOriginalRequestId(postfixedRequestId).equals(originalRequestId));
- assert(SDNCRequestIdUtil.getSDNCOriginalRequestId(postfixedRequestId2).equals(postfixedRequestId2));
+ assertEquals(originalRequestId, SDNCRequestIdUtil.getSDNCOriginalRequestId(postfixedRequestId));
+ assertEquals(postfixedRequestId2, SDNCRequestIdUtil.getSDNCOriginalRequestId(postfixedRequestId2));
}
diff --git a/adapters/mso-workflow-message-adapter/src/test/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallbackTest.java b/adapters/mso-workflow-message-adapter/src/test/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallbackTest.java
new file mode 100644
index 0000000000..8d2c938c09
--- /dev/null
+++ b/adapters/mso-workflow-message-adapter/src/test/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallbackTest.java
@@ -0,0 +1,42 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.adapters.workflowmessage;
+
+import org.apache.http.entity.ContentType;
+import org.junit.Test;
+import org.mockito.Mock;
+
+import static junit.framework.Assert.assertFalse;
+
+public class BPRestCallbackTest {
+
+ @Mock
+ ContentType contentType;
+
+ @Test
+ public void testSendExceptionCase() {
+
+ BPRestCallback test = new BPRestCallback();
+ test.send("workflowMessageUrl/", "messageType", "correlator", contentType,"message");
+ assertFalse(test.send("workflowMessageUrl/", "messageType", "correlator", contentType,"message"));
+
+ }
+ }
diff --git a/aria/aria-rest-server/VERSION b/aria/aria-rest-server/VERSION
deleted file mode 100644
index 51f7e73a94..0000000000
--- a/aria/aria-rest-server/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-1.0.1-SNAPSHOT
diff --git a/aria/aria-rest-server/setup.py b/aria/aria-rest-server/setup.py
index 799fe46021..eca497c1d4 100644
--- a/aria/aria-rest-server/setup.py
+++ b/aria/aria-rest-server/setup.py
@@ -19,15 +19,9 @@
from setuptools import setup, find_packages
-try:
- with open('VERSION') as v_file:
- version = v_file.read().strip()
-except IOError:
- print "There was a problem parsing the VERSION file."
-
setup(
name='aria-rest-server',
- version=version,
+ version='0.1.0',
packages=find_packages(),
author = '',
author_email = '',
diff --git a/aria/aria-rest-server/tox.ini b/aria/aria-rest-server/tox.ini
index e74b672b26..435de03638 100644
--- a/aria/aria-rest-server/tox.ini
+++ b/aria/aria-rest-server/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py27,py35
+envlist = py27
[testenv]
deps=
pytest
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/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");
+ }
}