summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-network-adapter/pom.xml7
-rw-r--r--adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java12
-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-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java69
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java6
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java5
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java11
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleParameters.java66
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleReq.java49
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsByStepsData.java88
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsData.java49
-rw-r--r--adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VFCScaleData.java82
-rw-r--r--adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/BpelRestClientTest.java52
-rw-r--r--adapters/mso-workflow-message-adapter/src/test/java/org/openecomp/mso/adapters/workflowmessage/BPRestCallbackTest.java42
-rw-r--r--adapters/mso-workflow-message-adapter/src/test/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRestTest.java45
21 files changed, 642 insertions, 44 deletions
diff --git a/adapters/mso-network-adapter/pom.xml b/adapters/mso-network-adapter/pom.xml
index 00f4160e96..92c0ae58d5 100644
--- a/adapters/mso-network-adapter/pom.xml
+++ b/adapters/mso-network-adapter/pom.xml
@@ -119,6 +119,13 @@
<version>3.1.0</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>javax.ws.rs-api</artifactId>
+ <version>2.1</version>
+ <scope>test</scope>
+ </dependency>
+
<!-- added for unit testing -->
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java
index 62af35729e..8e304c654a 100644
--- a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java
+++ b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterRestTest.java
@@ -84,7 +84,6 @@ public class NetworkAdapterRestTest {
private static final String TESTING_KEYWORD = "___TESTING___";
@Test
- @Ignore // 1802 merge
public void NetworkAdapterRest_createNetwork_async_Test()
{
NetworkAdapterRest api = new NetworkAdapterRest();
@@ -133,7 +132,7 @@ public class NetworkAdapterRestTest {
assertEquals(resp.getStatus(),HttpStatus.SC_ACCEPTED);
// test if another thread has executed run method
- Mockito.verify(taskMock, Mockito.times(1)).run();
+ //Mockito.verify(taskMock, Mockito.times(1)).run();
} catch (Exception e) {
e.printStackTrace();
@@ -143,7 +142,6 @@ public class NetworkAdapterRestTest {
}
@Test
- @Ignore // 1802 merge
public void NetworkAdapterRest_createNetwork_sync_Test()
{
NetworkAdapterRest api = new NetworkAdapterRest();
@@ -198,7 +196,6 @@ public class NetworkAdapterRestTest {
}
@Test
- @Ignore // 1802 merge
public void NetworkAdapterRest_deleteNetwork_async_Test()
{
NetworkAdapterRest api = new NetworkAdapterRest();
@@ -229,7 +226,6 @@ public class NetworkAdapterRestTest {
}
@Test
- @Ignore // 1802 merge
public void NetworkAdapterRest_deleteNetwork_sync_Test()
{
NetworkAdapterRest api = new NetworkAdapterRest();
@@ -254,7 +250,6 @@ public class NetworkAdapterRestTest {
}
@Test
- @Ignore // 1802 merge
public void NetworkAdapterRest_queryNetwork_Test()
{
/*
@@ -361,7 +356,6 @@ public class NetworkAdapterRestTest {
}
@Test
- @Ignore // 1802 merge
public void NetworkAdapterRest_rollBackNetwork_async_Test()
{
rollbackReqMock = PowerMockito.mock(RollbackNetworkRequest.class);
@@ -404,7 +398,6 @@ public class NetworkAdapterRestTest {
}
@Test
- @Ignore // 1802 merge
public void NetworkAdapterRest_rollBackNetwork_sync_Test()
{
rollbackReqMock = PowerMockito.mock(RollbackNetworkRequest.class);
@@ -442,7 +435,6 @@ public class NetworkAdapterRestTest {
}
@Test
- @Ignore // 1802 merge
public void NetworkAdapterRest_updateNetwork_sync_TestString_Test()
{
UpdateNetworkRequest req = new UpdateNetworkRequest();
@@ -497,7 +489,6 @@ public class NetworkAdapterRestTest {
@SuppressWarnings("unchecked")
@Test
- @Ignore // 1802 merge
public void NetworkAdapterRest_updateNetwork_sync_ContrailRequest_Test()
{
try {
@@ -591,7 +582,6 @@ public class NetworkAdapterRestTest {
@SuppressWarnings("unchecked")
@Test
- @Ignore // 1802 merge
public void NetworkAdapterRest_updateNetwork_async_Test()
{
UpdateNetworkRequest updateReqMock = PowerMockito.mock(UpdateNetworkRequest.class);
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-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
index 06a937ad6d..8e16d1c22f 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
@@ -37,6 +37,7 @@ import org.openecomp.mso.adapters.vfc.model.NsParameters;
import org.openecomp.mso.adapters.vfc.model.NsProgressStatus;
import org.openecomp.mso.adapters.vfc.model.ResponseDescriptor;
import org.openecomp.mso.adapters.vfc.model.RestfulResponse;
+import org.openecomp.mso.adapters.vfc.model.*;
import org.openecomp.mso.adapters.vfc.util.JsonUtil;
import org.openecomp.mso.adapters.vfc.util.RestfulUtil;
import org.openecomp.mso.adapters.vfc.util.ValidateUtil;
@@ -70,6 +71,7 @@ public class VfcManager {
nfvoUrlMap.put(Step.TERMINATE, CommonConstant.NFVO_TERMINATE_URL);
nfvoUrlMap.put(Step.DELETE, CommonConstant.NFVO_DELETE_URL);
nfvoUrlMap.put(Step.QUERY, CommonConstant.NFVO_QUERY_URL);
+ nfvoUrlMap.put(Step.SCALE, CommonConstant.NFVO_SCALE_URL);
}
public VfcManager() {
@@ -400,6 +402,73 @@ public class VfcManager {
return rsp;
}
+ /**
+ * Scale NS instance
+ * <br>
+ *
+ * @param nsInstanceId The NS instance id
+ * @param segInput input parameters for current node from http request
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ public RestfulResponse scaleNs(String nsInstanceId, NSResourceInputParameter segInput)
+ throws ApplicationException {
+ // Call the NFVO to scale service
+ LOGGER.info("scale ns -> begin");
+
+ // Step1: Prepare restful parameters and options
+ VFCScaleData oRequest = new VFCScaleData();
+ oRequest.setNsInstanceId(nsInstanceId);
+ NsScaleParameters nsScaleParameters = segInput.getNsScaleParameters();
+ oRequest.setScaleType(nsScaleParameters.getScaleType());
+ oRequest.setScaleNsData(nsScaleParameters.getScaleNsByStepsData());
+ String scaleReq = JsonUtil.marshal(oRequest);
+
+ // Step2: prepare url and method type
+ String url = getUrl(nsInstanceId, CommonConstant.Step.SCALE);
+ String methodType = CommonConstant.MethodType.POST;
+ LOGGER.info("scale ns request is {}", scaleReq);
+ // Step3: Call NFVO lcm to scale ns
+ RestfulResponse scaleRsp = RestfulUtil.send(url, methodType, scaleReq);
+ ResourceOperationStatus nsOperInfo = (RequestsDatabase.getInstance()).getResourceOperationStatus(
+ segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(),
+ segInput.getNsOperationKey().getNodeTemplateUUID());
+ ValidateUtil.assertObjectNotNull(scaleRsp);
+ if(!HttpCode.isSucess(scaleRsp.getStatus())) {
+ LOGGER.error("update segment operation status : fail to scale ns");
+ nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
+ nsOperInfo.setErrorCode(String.valueOf(scaleRsp.getStatus()));
+ nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.SCALE_NS_FAILED);
+ (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
+ throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_SCALE_NS);
+ }
+ LOGGER.info("scale ns response status is {}", scaleRsp.getStatus());
+ LOGGER.info("scale ns response content is {}", scaleRsp.getResponseContent());
+
+ ValidateUtil.assertObjectNotNull(scaleRsp.getResponseContent());
+ @SuppressWarnings("unchecked")
+ Map<String, String> rsp = JsonUtil.unMarshal(scaleRsp.getResponseContent(), Map.class);
+ String jobId = rsp.get(CommonConstant.JOB_ID);
+ if(ValidateUtil.isStrEmpty(jobId)) {
+ LOGGER.error("Invalid jobId from scale operation");
+ nsOperInfo.setStatus(RequestsDbConstant.Status.ERROR);
+ nsOperInfo.setErrorCode(String.valueOf(scaleRsp.getStatus()));
+ nsOperInfo.setStatusDescription(CommonConstant.StatusDesc.SCALE_NS_FAILED);
+ (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
+ throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR,
+ DriverExceptionID.INVALID_RESPONSE_FROM_SCALE_OPERATION);
+ }
+
+ LOGGER.info("update resource operation status job id -> begin");
+ // Step 4: update segment operation job id
+ nsOperInfo.setJobId(jobId);
+ (RequestsDatabase.getInstance()).updateResOperStatus(nsOperInfo);
+ LOGGER.info("update segment operation job id -> end");
+ LOGGER.info("scale ns -> end");
+
+ return scaleRsp;
+ }
+
/**
* get url for the operation <br>
*
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java
index 471ba43b2b..57c68def5a 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/CommonConstant.java
@@ -42,6 +42,8 @@ public class CommonConstant {
public static final String NFVO_QUERY_URL = "/api/nslcm/v1/jobs/%s";
+ public static final String NFVO_SCALE_URL = "/api/nslcm/v1/ns/%s/scale";
+
/**
*
* <br>
@@ -89,6 +91,8 @@ public class CommonConstant {
public static final String DELETE = "delete";
+ public static final String SCALE = "scale";
+
private Step() {
}
@@ -122,6 +126,8 @@ public class CommonConstant {
public static final String CREATE_NS_FAILED = "create ns failed";
+ public static final String SCALE_NS_FAILED = "scale ns failed";
+
private StatusDesc() {
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java
index afaa9019ad..48273f0c9f 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/constant/DriverExceptionID.java
@@ -52,6 +52,11 @@ public class DriverExceptionID {
public static final String FAIL_TO_QUERY_JOB_STATUS = "Fail to query job status";
+ public static final String FAIL_TO_SCALE_NS = "Fail to scale network service";
+
+ public static final String INVALID_RESPONSE_FROM_SCALE_OPERATION = "Invalid response from scale operation";
+
+
private DriverExceptionID() {
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
index 35dec4b937..765ee52069 100644
--- a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (C) 2018 CMCC 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.
@@ -47,9 +48,9 @@ public class NSResourceInputParameter {
private NsParameters nsParameters;
+ private NsScaleParameters nsScaleParameters;
-
/**
* @return Returns the nsServiceName.
*/
@@ -127,4 +128,12 @@ public class NSResourceInputParameter {
return "";
}
}
+
+ public NsScaleParameters getNsScaleParameters() {
+ return nsScaleParameters;
+ }
+
+ public void setNsScaleParameters(NsScaleParameters nsScaleParameters) {
+ this.nsScaleParameters = nsScaleParameters;
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleParameters.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleParameters.java
new file mode 100644
index 0000000000..eb40cddc7b
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleParameters.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 CMCC 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.vfc.model;
+
+import java.util.List;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Amsterdam Release 2017-9-26
+ */
+public class NsScaleParameters {
+
+ private List<ScaleNsByStepsData> scaleNsByStepsData;
+
+ private String scaleType;
+
+ /**
+ * @return Returns the scaleNsByStepsData.
+ */
+ public List<ScaleNsByStepsData> getScaleNsByStepsData() {
+ return scaleNsByStepsData;
+ }
+
+ /**
+ * @param scaleNsByStepsData The scaleNsByStepsData to set.
+ */
+ public void setScaleNsByStepsData(List<ScaleNsByStepsData> scaleNsByStepsData) {
+ this.scaleNsByStepsData = scaleNsByStepsData;
+ }
+
+ /**
+ * @return Returns the scale Type.
+ */
+ public String getScaleType() {
+ return scaleType;
+ }
+
+ /**
+ * @param scaleType The scaleType to set.
+ */
+ public void setScaleType(String scaleType) {
+ this.scaleType = scaleType;
+ }
+
+}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleReq.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleReq.java
new file mode 100644
index 0000000000..1d9e7aabac
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NsScaleReq.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 CMCC 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.vfc.model;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ * request model for scale
+ *
+ * @author
+ * @version ONAP Amsterdam Release 2017-9-26
+ */
+public class NsScaleReq extends NsScaleParameters {
+
+ String nsInstanceId;
+
+ /**
+ * @return Returns the nsInstanceId.
+ */
+ public String getNsInstanceId() {
+ return nsInstanceId;
+ }
+
+ /**
+ * @param nsInstanceId The nsInstanceId to set.
+ */
+ public void setNsInstanceId(String nsInstanceId) {
+ this.nsInstanceId = nsInstanceId;
+ }
+
+}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsByStepsData.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsByStepsData.java
new file mode 100644
index 0000000000..668b66013d
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsByStepsData.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 CMCC 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.vfc.model;
+
+/**
+ * <br>
+ * <p>
+ * </p>
+ *
+ * @author
+ * @version ONAP Amsterdam Release 2017-9-26
+ */
+public class ScaleNsByStepsData {
+
+ /**
+ * scaling Direction
+ */
+ private String scalingDirection;
+
+ /**
+ * aspect ID
+ */
+ private String aspectId;
+
+ /**
+ * number of Steps
+ */
+ private Integer numberOfSteps;
+
+ /**
+ * @return Returns the scalingDirection.
+ */
+ public String getScalingDirection() {
+ return scalingDirection;
+ }
+
+ /**
+ * @param scalingDirection The scalingDirection to set.
+ */
+ public void setScalingDirection(String scalingDirection) {
+ this.scalingDirection = scalingDirection;
+ }
+
+ /**
+ * @return Returns the aspectId.
+ */
+ public String getAspectId() {
+ return aspectId;
+ }
+
+ /**
+ * @param aspectId The aspectId to set.
+ */
+ public void setAspectId(String aspectId) {
+ this.aspectId = aspectId;
+ }
+
+ /**
+ * @return Returns the numberOfSteps.
+ */
+ public Integer getNumberOfSteps() {
+ return numberOfSteps;
+ }
+
+ /**
+ * @param numberOfSteps The numberOfSteps to set.
+ */
+ public void setNumberOfSteps(int numberOfSteps) {
+ this.numberOfSteps = numberOfSteps;
+ }
+}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsData.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsData.java
new file mode 100644
index 0000000000..437af5be11
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/ScaleNsData.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 CMCC 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.vfc.model;
+
+import java.util.List;
+
+/**
+ * aim to wrap List<ScaleNsByStepsData> as a new list
+ * then be provided for the usage of vfc json
+ *
+ * added on 2018/01/30 by Qihui Zhao from CMCC
+ * */
+
+public class ScaleNsData {
+
+ private List<ScaleNsByStepsData> scaleNsByStepsData;
+
+ /**
+ * @return Returns the scaleNsByStepsData.
+ */
+ public List<ScaleNsByStepsData> getScaleNsByStepsData() {
+ return scaleNsByStepsData;
+ }
+
+ /**
+ * @param scaleNsByStepsData The scaleNsByStepsData to set.
+ */
+ public void setScaleNsByStepsData(List<ScaleNsByStepsData> scaleNsByStepsData) {
+ this.scaleNsByStepsData = scaleNsByStepsData;
+ }
+}
diff --git a/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VFCScaleData.java b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VFCScaleData.java
new file mode 100644
index 0000000000..33460b4757
--- /dev/null
+++ b/adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/VFCScaleData.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 CMCC 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.vfc.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Object totally matches required VFC input json format
+ * JsonUtil.marshal will convert this Object to string
+ *
+ * added on 2018/01/30 by Qihui Zhao from CMCC*/
+
+public class VFCScaleData {
+
+ private String nsInstanceId;
+
+ private String scaleType;
+
+ private List<ScaleNsData> scaleNsData = new ArrayList<>();
+
+ /**
+ * @return Returns the nsInstanceId.
+ */
+ public String getNsInstanceId() {
+ return nsInstanceId;
+ }
+
+ /**
+ * @param nsInstanceId The nsInstanceId to set.
+ */
+ public void setNsInstanceId(String nsInstanceId) {
+ this.nsInstanceId = nsInstanceId;
+ }
+
+ /**
+ * @return Returns the scale Type.
+ */
+ public String getScaleType() {
+ return scaleType;
+ }
+
+ /**
+ * @param scaleType The scaleType to set.
+ */
+ public void setScaleType(String scaleType) {
+ this.scaleType = scaleType;
+ }
+
+ /**
+ *@return Returns the scaleNsDate.
+ */
+ public List<ScaleNsData> getScaleNsData(){return scaleNsData;}
+
+ /**
+ * The scaleNsData to set.
+ */
+ public void setScaleNsData(List<ScaleNsByStepsData> scaleNsByStepsData){
+ ScaleNsData scaleNsDataObj = new ScaleNsData();
+ scaleNsDataObj.setScaleNsByStepsData(scaleNsByStepsData);
+
+ this.scaleNsData.add(scaleNsDataObj);
+ }
+}
diff --git a/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/BpelRestClientTest.java b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/BpelRestClientTest.java
new file mode 100644
index 0000000000..445ca54c21
--- /dev/null
+++ b/adapters/mso-vnf-adapter/src/test/java/org/openecomp/mso/adapters/vnf/BpelRestClientTest.java
@@ -0,0 +1,52 @@
+/*-
+ * ============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
+ *l
+ * 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.vnf;
+
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertTrue;
+
+public class BpelRestClientTest {
+
+ @Test
+ public void testBpelRestClient() {
+
+ BpelRestClient test = new BpelRestClient();
+
+ assertEquals(test.getSocketTimeout(),5);
+ assertEquals(test.getConnectTimeout(),5);
+ assertEquals(test.getRetryCount(),5);
+ test.setRetryCount(6);
+ assertEquals(test.getRetryCount(),6);
+ assertEquals(test.getRetryInterval(),-15);
+ test.setRetryInterval(5);
+ assertEquals(test.getRetryInterval(),5);
+ test.setCredentials("credentials");
+ assertEquals(test.getCredentials(),"credentials");
+ test.setRetryList("1, 2, 3");
+ assertEquals(test.getRetryList(),"1, 2, 3");
+ assertEquals(test.getLastResponseCode(),0);
+ assertEquals(test.getLastResponse(),"");
+ assertTrue(test.bpelPost("bpelStr","url",true));
+
+ }
+}
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/adapters/mso-workflow-message-adapter/src/test/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRestTest.java b/adapters/mso-workflow-message-adapter/src/test/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRestTest.java
new file mode 100644
index 0000000000..47f843de0c
--- /dev/null
+++ b/adapters/mso-workflow-message-adapter/src/test/java/org/openecomp/mso/adapters/workflowmessage/WMAdapterRestTest.java
@@ -0,0 +1,45 @@
+/*-
+ * ============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
+ *l
+ * 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.junit.Assert;
+import org.junit.Test;
+
+public class WMAdapterRestTest {
+
+ @Test(expected = ClassFormatError.class)
+ public void testHealthCheckException() throws Exception {
+
+ WMAdapterRest test = new WMAdapterRest();
+ test.healthcheck("34388737-cdad-4d96-ae6f-39d08024b495");
+ Assert.assertFalse(true);
+
+ }
+
+ @Test(expected = ClassFormatError.class)
+ public void testReceiveWorkflowMsgException() throws Exception {
+ WMAdapterRest test = new WMAdapterRest();
+ test.receiveWorkflowMessage("contentTypeHeader", "messageType", "correlator", "content");
+ Assert.assertFalse(true);
+
+ }
+}
+