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--bpmn/MSOCommonBPMN/pom.xml13
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn29
-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
11 files changed, 295 insertions, 64 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/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/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn
index b681e2f3b4..d6dbf58594 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn
+++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateE2EServiceInstance.bpmn
@@ -180,10 +180,6 @@ dcsi.prepareDecomposeService(execution)]]></bpmn2:script>
<bpmn2:linkEventDefinition name="StartService" />
</bpmn2:intermediateCatchEvent>
<bpmn2:sequenceFlow id="SequenceFlow_1i7t9hq" sourceRef="IntermediateCatchEvent_0jrb3xu" targetRef="CustomE2EGetService" />
- <bpmn2:intermediateThrowEvent id="IntermediateThrowEvent_0f2w7aj" name="GoTo ResourceLoop">
- <bpmn2:incoming>SequenceFlow_032s0yi</bpmn2:incoming>
- <bpmn2:linkEventDefinition name="ResourceLoop" />
- </bpmn2:intermediateThrowEvent>
<bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_05dus9b" name="StartPrepareResource">
<bpmn2:outgoing>SequenceFlow_1hbesp9</bpmn2:outgoing>
<bpmn2:linkEventDefinition name="StartPrepareResource" />
@@ -222,7 +218,7 @@ csi.preProcessForAddResource(execution)]]></bpmn2:script>
</bpmn2:scriptTask>
<bpmn2:scriptTask id="ScriptTask_1y7jr4t" name="PostProcess for Add Resource" scriptFormat="groovy">
<bpmn2:incoming>SequenceFlow_0d0c20n</bpmn2:incoming>
- <bpmn2:outgoing>SequenceFlow_032s0yi</bpmn2:outgoing>
+ <bpmn2:outgoing>SequenceFlow_0a6vgsu</bpmn2:outgoing>
<bpmn2:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
def csi = new DoCreateE2EServiceInstance()
csi.postProcessForAddResource(execution)]]></bpmn2:script>
@@ -230,7 +226,10 @@ csi.postProcessForAddResource(execution)]]></bpmn2:script>
<bpmn2:sequenceFlow id="SequenceFlow_13xfsff" sourceRef="Task_0raqlqc" targetRef="ScriptTask_04b21gb" />
<bpmn2:sequenceFlow id="SequenceFlow_0bf6bzp" sourceRef="ScriptTask_04b21gb" targetRef="CallActivity_1ojtwas" />
<bpmn2:sequenceFlow id="SequenceFlow_0d0c20n" sourceRef="CallActivity_1ojtwas" targetRef="ScriptTask_1y7jr4t" />
- <bpmn2:sequenceFlow id="SequenceFlow_032s0yi" sourceRef="ScriptTask_1y7jr4t" targetRef="IntermediateThrowEvent_0f2w7aj" />
+ <bpmn2:endEvent id="EndEvent_0hzmoug">
+ <bpmn2:incoming>SequenceFlow_0a6vgsu</bpmn2:incoming>
+ </bpmn2:endEvent>
+ <bpmn2:sequenceFlow id="SequenceFlow_0a6vgsu" sourceRef="ScriptTask_1y7jr4t" targetRef="EndEvent_0hzmoug" />
</bpmn2:process>
<bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" />
<bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" />
@@ -450,12 +449,6 @@ csi.postProcessForAddResource(execution)]]></bpmn2:script>
<dc:Bounds x="125" y="76" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
- <bpmndi:BPMNShape id="IntermediateThrowEvent_0f2w7aj_di" bpmnElement="IntermediateThrowEvent_0f2w7aj">
- <dc:Bounds x="1315" y="282" width="36" height="36" />
- <bpmndi:BPMNLabel>
- <dc:Bounds x="1299" y="323" width="73" height="24" />
- </bpmndi:BPMNLabel>
- </bpmndi:BPMNShape>
<bpmndi:BPMNShape id="IntermediateCatchEvent_05dus9b_di" bpmnElement="IntermediateCatchEvent_05dus9b">
<dc:Bounds x="18" y="282" width="36" height="36" />
<bpmndi:BPMNLabel>
@@ -513,11 +506,19 @@ csi.postProcessForAddResource(execution)]]></bpmn2:script>
<dc:Bounds x="1024" y="294" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
- <bpmndi:BPMNEdge id="SequenceFlow_032s0yi_di" bpmnElement="SequenceFlow_032s0yi">
+ <bpmndi:BPMNShape id="EndEvent_0hzmoug_di" bpmnElement="EndEvent_0hzmoug">
+ <dc:Bounds x="1315" y="282.4076655052265" width="36" height="36" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="1333" y="322.4076655052265" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0a6vgsu_di" bpmnElement="SequenceFlow_0a6vgsu">
<di:waypoint xsi:type="dc:Point" x="1168" y="300" />
+ <di:waypoint xsi:type="dc:Point" x="1242" y="300" />
+ <di:waypoint xsi:type="dc:Point" x="1242" y="300" />
<di:waypoint xsi:type="dc:Point" x="1315" y="300" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="1241.5" y="279" width="0" height="12" />
+ <dc:Bounds x="1257" y="294" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
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");
+ }
}