summaryrefslogtreecommitdiffstats
path: root/nokiav2
diff options
context:
space:
mode:
Diffstat (limited to 'nokiav2')
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java49
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java11
-rw-r--r--nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java4
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java3
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java53
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSoApi.java160
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java3
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProvider.java16
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestDriverProperties.java22
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Useless.java25
10 files changed, 303 insertions, 43 deletions
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java
index c6e07e83..2d2f0159 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/SoLifecycleManager.java
@@ -31,7 +31,6 @@ import org.onap.vnfmadapter.so.model.*;
import org.onap.vnfmdriver.model.ExtVirtualLinkInfo;
import org.onap.vnfmdriver.model.*;
import org.onap.vnfmdriver.model.VnfInfo;
-import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -42,8 +41,6 @@ import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCM_API_VERSION;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.LifecycleManager.getVnfdIdFromModifyableAttributes;
import static org.onap.vnfmadapter.so.model.SoJobStatus.*;
-import static org.slf4j.LoggerFactory.getLogger;
-import static org.springframework.util.StringUtils.isEmpty;
/**
* Responsible for providing access to AAI APIs.
@@ -52,7 +49,6 @@ import static org.springframework.util.StringUtils.isEmpty;
@Component
public class SoLifecycleManager {
- private static Logger logger = getLogger(SoLifecycleManager.class);
private final LifecycleManager lifecycleManager;
private final VimInfoProvider vimInfoProvider;
private final CbamRestApiProvider cbamRestApiProvider;
@@ -96,9 +92,7 @@ public class SoLifecycleManager {
org.onap.vnfmdriver.model.VimInfo vimInfo = vimInfoProvider.getVimInfo(vimId);
additionalParameters.setVimType(vimTypeHeuristic(vimInfo.getUrl()));
processVdus(soRequest, additionalParameters, vimId);
- if (isEmpty(additionalParameters.getInstantiationLevel())) {
- additionalParameters.setInstantiationLevel("default");
- }
+ additionalParameters.setInstantiationLevel("default");
processNetworks(soRequest, additionalParameters, vimId);
processZones(soRequest, additionalParameters, vimId);
com.nokia.cbam.lcm.v32.model.VnfInfo cbamVnfInfo = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdGet(vnfId, NOKIA_LCM_API_VERSION).blockingFirst();
@@ -158,8 +152,13 @@ public class SoLifecycleManager {
*/
public SoJobHandler deactivate(String vnfmId, String vnfId, SoVnfTerminationRequest soRequest, HttpServletResponse httpResponse) {
VnfTerminateRequest driverRequest = new VnfTerminateRequest();
- driverRequest.setTerminationType(soRequest.getMode() == SoTerminationMode.FORCEFUL ? VnfTerminationType.FORCEFUL : VnfTerminationType.GRACEFUL);
- driverRequest.setGracefulTerminationTimeout(soRequest.getGracefulTerminationTimeoutInMs().toString());
+ if (soRequest.getMode() == SoTerminationMode.FORCEFUL) {
+ driverRequest.setTerminationType(VnfTerminationType.FORCEFUL);
+ } else {
+ driverRequest.setTerminationType(VnfTerminationType.GRACEFUL);
+ driverRequest.setGracefulTerminationTimeout(soRequest.getGracefulTerminationTimeoutInMs().toString());
+
+ }
return buildJobHandler(lifecycleManager.terminateAndDelete(vnfmId, vnfId, driverRequest, httpResponse).getJobId());
}
@@ -256,12 +255,16 @@ public class SoLifecycleManager {
ExtVirtualLinkData extVirtualLinkData = createExtVirtualLinkData(additionalParameters, networkMapping.getVldId());
extVirtualLinkData.setVimId(vimId);
extVirtualLinkData.setResourceId(networkMapping.getNetworkProviderId());
- if (networkMapping.getAssignedAddresses() != null) {
- for (SoAssignedAddresses assignedAddresses : networkMapping.getAssignedAddresses()) {
- VnfExtCpData extCpData = createExtVirtualLinkData(extVirtualLinkData.getExtCps(), assignedAddresses.getCpdId());
- addMissing(extCpData, assignedAddresses.getIpAddress());
- }
- }
+ processAssingedAddress(networkMapping, extVirtualLinkData);
+ }
+ }
+ }
+
+ private void processAssingedAddress(SoNetworkMapping networkMapping, ExtVirtualLinkData extVirtualLinkData) {
+ if (networkMapping.getAssignedAddresses() != null) {
+ for (SoAssignedAddresses assignedAddresses : networkMapping.getAssignedAddresses()) {
+ VnfExtCpData extCpData = createExtVirtualLinkData(extVirtualLinkData.getExtCps(), assignedAddresses.getCpdId());
+ addMissing(extCpData, assignedAddresses.getIpAddress());
}
}
}
@@ -277,11 +280,9 @@ public class SoLifecycleManager {
}
private ZoneInfo locateOrCreateZone(List<ZoneInfo> zones, String vduId) {
- if (zones != null) {
- for (ZoneInfo zone : zones) {
- if (zone.getId().equals(vduId)) {
- return zone;
- }
+ for (ZoneInfo zone : zones) {
+ if (zone.getId().equals(vduId)) {
+ return zone;
}
}
ZoneInfo zoneInfo = new ZoneInfo();
@@ -305,11 +306,9 @@ public class SoLifecycleManager {
}
private VnfExtCpData createExtVirtualLinkData(List<VnfExtCpData> extCps, String cpdId) {
- if (extCps != null) {
- for (VnfExtCpData extCp : extCps) {
- if (extCp.getCpdId().equals(cpdId)) {
- return extCp;
- }
+ for (VnfExtCpData extCp : extCps) {
+ if (extCp.getCpdId().equals(cpdId)) {
+ return extCp;
}
}
VnfExtCpData extCp = new VnfExtCpData();
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java
index b2c833bb..f3b4a1e6 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/SoApi.java
@@ -43,7 +43,6 @@ public class SoApi {
private final SoLifecycleManager soLifecycleManager;
- //private final LifecycleManager d;
@Autowired
SoApi(SoLifecycleManager lifecycleManager) {
this.soLifecycleManager = lifecycleManager;
@@ -77,7 +76,7 @@ public class SoApi {
@RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
@ResponseBody
public SoJobHandler activateVnf(@RequestBody SoVnfActivationRequest request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
- logger.info("REST: Create the VNF");
+ logger.info("REST: Activate the VNF");
return soLifecycleManager.activate(vnfmId, vnfId, request, httpResponse);
}
@@ -92,7 +91,7 @@ public class SoApi {
@RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}/customOperation", method = POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
@ResponseBody
public SoJobHandler executeCustomOperation(@RequestBody SoVnfCustomOperation request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
- logger.info("REST: Create the VNF");
+ logger.info("REST: Execute custom operation on the VNF");
return soLifecycleManager.customOperation(vnfmId, vnfId, request, httpResponse);
}
@@ -108,7 +107,7 @@ public class SoApi {
@RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}/terminate", method = POST, produces = APPLICATION_JSON_VALUE)
@ResponseBody
public SoJobHandler deactivateVnf(@RequestBody SoVnfTerminationRequest request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
- logger.info("REST: Deactivate VNF");
+ logger.info("REST: Deactivate the VNF");
return soLifecycleManager.deactivate(vnfmId, vnfId, request, httpResponse);
}
@@ -121,7 +120,7 @@ public class SoApi {
*/
@RequestMapping(value = "/{vnfmId}/vnfs/{vnfId}", method = DELETE)
public void deleteVnf(@PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfId, HttpServletResponse httpResponse) {
- logger.info("REST: Delete VNF");
+ logger.info("REST: Delete the VNF");
soLifecycleManager.delete(vnfmId, vnfId);
httpResponse.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
@@ -137,7 +136,7 @@ public class SoApi {
@RequestMapping(value = "/{vnfmId}/jobs/{jobId}", method = GET, produces = APPLICATION_JSON_VALUE)
@ResponseBody
public SoJobDetail getJob(@PathVariable("vnfmId") String vnfmId, @PathVariable("jobId") String jobId, HttpServletResponse httpResponse) {
- logger.debug("REST: Query the job");
+ logger.trace("REST: Query the job");
return soLifecycleManager.getJobDetails(vnfmId, jobId);
}
diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
index 5cd11058..b7dd7168 100644
--- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
+++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/LifecycleManager.java
@@ -253,7 +253,7 @@ public class LifecycleManager {
return buildOpenStackV2INFO(vimId, vim, vimInfo);
} else if (additionalParameters.getVimType() == OPENSTACK_V3_INFO) {
- return buildOpenStackV3INFO(vimId, additionalParameters, vim, vimInfo);
+ return buildOpenStackV3INFO(vimId, vim, vimInfo);
} else {
//OTHER VIM TYPE is not possible
@@ -329,7 +329,7 @@ public class LifecycleManager {
}
}
- private OPENSTACKV3INFO buildOpenStackV3INFO(String vimId, AdditionalParameters additionalParameters, GrantVNFResponseVim vim, org.onap.vnfmdriver.model.VimInfo vimInfo) {
+ private OPENSTACKV3INFO buildOpenStackV3INFO(String vimId, GrantVNFResponseVim vim, org.onap.vnfmdriver.model.VimInfo vimInfo) {
OPENSTACKV3INFO openstackv3INFO = new OPENSTACKV3INFO();
openstackv3INFO.setVimInfoType(OPENSTACK_V3_INFO);
OpenStackAccessInfoV3 accessInfov3 = new OpenStackAccessInfoV3();
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
index 92e19a3c..444660b1 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/TestNokiaSvnfmApplication.java
@@ -21,6 +21,7 @@ import org.junit.Test;
import org.mockito.*;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.JobManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Useless;
import org.slf4j.Logger;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.ContextClosedEvent;
@@ -149,8 +150,10 @@ public class TestNokiaSvnfmApplication {
/**
* static entry point calling an other static entry point can not be tested
+ * only using powermock
*/
@Test
+ @Useless
public void useless() throws Exception {
try {
NokiaSvnfmApplication.main(null);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java
index ebc2159d..77005f41 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/so/TestSoLifecycleManager.java
@@ -41,7 +41,6 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider.NOKIA_LCM_API_VERSION;
-import static org.springframework.test.util.ReflectionTestUtils.setField;
public class TestSoLifecycleManager extends TestBase {
@@ -56,7 +55,6 @@ public class TestSoLifecycleManager extends TestBase {
@Before
public void init() {
- setField(SoLifecycleManager.class, "logger", logger);
soLifecycleManager = new SoLifecycleManager(lifecycleManager, vimInfoProvider, cbamRestApiProvider, jobManager);
}
@@ -382,10 +380,10 @@ public class TestSoLifecycleManager extends TestBase {
}
/**
- * test VNF scale
+ * test VNF scale in
*/
@Test
- public void testScaling() throws Exception {
+ public void testScaleIn() throws Exception {
SoVnfScaleRequest soRequest = new SoVnfScaleRequest();
ArgumentCaptor<org.onap.vnfmdriver.model.VnfScaleRequest> driverRequest = ArgumentCaptor.forClass(org.onap.vnfmdriver.model.VnfScaleRequest.class);
JobInfo jobInfo = new JobInfo();
@@ -408,6 +406,32 @@ public class TestSoLifecycleManager extends TestBase {
}
/**
+ * test VNF scale out
+ */
+ @Test
+ public void testScaleOut() throws Exception {
+ SoVnfScaleRequest soRequest = new SoVnfScaleRequest();
+ ArgumentCaptor<org.onap.vnfmdriver.model.VnfScaleRequest> driverRequest = ArgumentCaptor.forClass(org.onap.vnfmdriver.model.VnfScaleRequest.class);
+ JobInfo jobInfo = new JobInfo();
+ jobInfo.setJobId(JOB_ID);
+
+ soRequest.setAspectId("aspectId");
+ soRequest.setDirection(SoScaleDirection.OUT);
+ soRequest.setSteps(2);
+ JsonObject additionalParams = new JsonObject();
+ soRequest.setAdditionalParams(additionalParams);
+ when(lifecycleManager.scaleVnf(eq(VNFM_ID), eq(VNF_ID), driverRequest.capture(), eq(httpResponse))).thenReturn(jobInfo);
+ //when
+ SoJobHandler jobHandler = soLifecycleManager.scale(VNFM_ID, VNF_ID, soRequest, httpResponse);
+ //verify
+ assertEquals(JOB_ID, jobHandler.getJobId());
+ assertEquals(2, Integer.parseInt(driverRequest.getValue().getNumberOfSteps()));
+ assertEquals("aspectId", driverRequest.getValue().getAspectId());
+ assertEquals(org.onap.vnfmdriver.model.ScaleDirection.OUT, driverRequest.getValue().getType());
+ assertEquals(additionalParams, driverRequest.getValue().getAdditionalParam());
+ }
+
+ /**
* test VNF heal
*/
@Test
@@ -454,6 +478,27 @@ public class TestSoLifecycleManager extends TestBase {
}
/**
+ * test VNF deactivation
+ */
+ @Test
+ public void testDeactivationForceFull() throws Exception {
+ SoVnfTerminationRequest soRequest = new SoVnfTerminationRequest();
+ ArgumentCaptor<org.onap.vnfmdriver.model.VnfTerminateRequest> driverRequest = ArgumentCaptor.forClass(org.onap.vnfmdriver.model.VnfTerminateRequest.class);
+ JobInfo jobInfo = new JobInfo();
+ jobInfo.setJobId(JOB_ID);
+ soRequest.setMode(SoTerminationMode.FORCEFUL);
+ JsonObject additionalParams = new JsonObject();
+ soRequest.setAdditionalParams(additionalParams);
+ when(lifecycleManager.terminateAndDelete(eq(VNFM_ID), eq(VNF_ID), driverRequest.capture(), eq(httpResponse))).thenReturn(jobInfo);
+ //when
+ SoJobHandler jobHandler = soLifecycleManager.deactivate(VNFM_ID, VNF_ID, soRequest, httpResponse);
+ //verify
+ assertEquals(JOB_ID, jobHandler.getJobId());
+ assertEquals(VnfTerminationType.FORCEFUL, driverRequest.getValue().getTerminationType());
+ assertEquals(null, driverRequest.getValue().getGracefulTerminationTimeout());
+ }
+
+ /**
* test VNF deletion
*/
@Test
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSoApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSoApi.java
new file mode 100644
index 00000000..be1ee5a7
--- /dev/null
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestSoApi.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.restapi;
+
+import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.so.SoLifecycleManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.TestBase;
+import org.onap.vnfmadapter.so.model.*;
+
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.springframework.test.util.ReflectionTestUtils.setField;
+
+
+public class TestSoApi extends TestBase {
+
+ @Mock
+ private SoLifecycleManager soLifecycleManager;
+ @InjectMocks
+ private SoApi soApi;
+ @Mock
+ private SoJobHandler jobHandler;
+
+ @Before
+ public void initMocks() throws Exception {
+ setField(SoApi.class, "logger", logger);
+ }
+
+ /**
+ * test create
+ */
+ @Test
+ public void testCreate() {
+ SoVnfCreationRequest soRequest = Mockito.mock(SoVnfCreationRequest.class);
+ SoVnfCreationResponse vnf = new SoVnfCreationResponse();
+ when(soLifecycleManager.create(VNFM_ID, soRequest)).thenReturn(vnf);
+ //when
+ SoVnfCreationResponse actual = soApi.createVnf(soRequest, VNFM_ID, httpResponse);
+ //verify
+ verify(logger).info("REST: Create the VNF");
+ TestCase.assertEquals(vnf, actual);
+ }
+
+ /**
+ * test activation
+ */
+ @Test
+ public void testActivate() {
+ SoVnfActivationRequest soRequest = Mockito.mock(SoVnfActivationRequest.class);
+ when(soLifecycleManager.activate(VNFM_ID, VNF_ID, soRequest, httpResponse)).thenReturn(jobHandler);
+ //when
+ SoJobHandler soJobHandler = soApi.activateVnf(soRequest, VNFM_ID, VNF_ID, httpResponse);
+ //verify
+ verify(logger).info("REST: Activate the VNF");
+ TestCase.assertEquals(jobHandler, soJobHandler);
+ }
+
+ /**
+ * test scale
+ */
+ @Test
+ public void testScale() {
+ SoVnfScaleRequest soRequest = Mockito.mock(SoVnfScaleRequest.class);
+ when(soLifecycleManager.scale(VNFM_ID, VNF_ID, soRequest, httpResponse)).thenReturn(jobHandler);
+ //when
+ SoJobHandler soJobHandler = soApi.scaleVnf(soRequest, VNFM_ID, VNF_ID, httpResponse);
+ //verify
+ verify(logger).info("REST: Scale the VNF");
+ TestCase.assertEquals(jobHandler, soJobHandler);
+ }
+
+ /**
+ * test heal
+ */
+ @Test
+ public void testHeal() {
+ SoVnfHealRequest soRequest = Mockito.mock(SoVnfHealRequest.class);
+ when(soLifecycleManager.heal(VNFM_ID, VNF_ID, soRequest, httpResponse)).thenReturn(jobHandler);
+ //when
+ SoJobHandler soJobHandler = soApi.healVnf(soRequest, VNFM_ID, VNF_ID, httpResponse);
+ //verify
+ verify(logger).info("REST: Heal the VNF");
+ TestCase.assertEquals(jobHandler, soJobHandler);
+ }
+
+
+ /**
+ * test custom
+ */
+ @Test
+ public void testCustom() {
+ SoVnfCustomOperation soRequest = Mockito.mock(SoVnfCustomOperation.class);
+ when(soLifecycleManager.customOperation(VNFM_ID, VNF_ID, soRequest, httpResponse)).thenReturn(jobHandler);
+ //when
+ SoJobHandler soJobHandler = soApi.executeCustomOperation(soRequest, VNFM_ID, VNF_ID, httpResponse);
+ //verify
+ verify(logger).info("REST: Execute custom operation on the VNF");
+ TestCase.assertEquals(jobHandler, soJobHandler);
+ }
+
+ /**
+ * test deactivation
+ */
+ @Test
+ public void testDeactivation() {
+ SoVnfTerminationRequest soRequest = Mockito.mock(SoVnfTerminationRequest.class);
+ when(soLifecycleManager.deactivate(VNFM_ID, VNF_ID, soRequest, httpResponse)).thenReturn(jobHandler);
+ //when
+ SoJobHandler soJobHandler = soApi.deactivateVnf(soRequest, VNFM_ID, VNF_ID, httpResponse);
+ //verify
+ verify(logger).info("REST: Deactivate the VNF");
+ TestCase.assertEquals(jobHandler, soJobHandler);
+ }
+
+ /**
+ * test delete
+ */
+ @Test
+ public void testDelete() {
+ //when
+ soApi.deleteVnf(VNFM_ID, VNF_ID, httpResponse);
+ //verify
+ verify(logger).info("REST: Delete the VNF");
+ verify(soLifecycleManager).delete(VNFM_ID, VNF_ID);
+ }
+
+ /**
+ * test deactivation
+ */
+ @Test
+ public void testGetJob() {
+ SoJobDetail jobDetail = new SoJobDetail();
+ when(soLifecycleManager.getJobDetails(VNFM_ID, JOB_ID)).thenReturn(jobDetail);
+ //when
+ SoJobDetail actial = soApi.getJob(VNFM_ID, JOB_ID, httpResponse);
+ //verify
+ verify(logger).trace("REST: Query the job");
+ TestCase.assertEquals(jobDetail, actial);
+ }
+
+}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java
index df97d4a4..0b31fef5 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestSystemFunctions.java
@@ -20,6 +20,7 @@ import java.util.Base64;
import java.util.HashSet;
import java.util.Set;
import org.junit.Test;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.Useless;
import static org.junit.Assert.*;
@@ -108,9 +109,9 @@ public class TestSystemFunctions {
/**
* Test HTTP client wrapping
- * (semi useless test)
*/
@Test
+ @Useless //more less already ensured by Java type safety
public void testHttp() {
assertNotNull(SystemFunctions.systemFunctions().getHttpClient());
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProvider.java
index e21e638a..7817edfd 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestCbamRestApiProvider.java
@@ -72,13 +72,15 @@ public class TestCbamRestApiProvider extends TestBase {
private java.util.List<NodeInfo> nodes = new ArrayList<>();
private CbamRestApiProvider cbamRestApiProvider;
- private CbamSecurityProvider cbamSecurityProvider = spy(new CbamSecurityProvider());
+ private CbamSecurityProvider cbamSecurityProvider ;
@Before
public void init() {
+ CbamSecurityProvider real = new CbamSecurityProvider();
+ setFieldWithPropertyAnnotation(real, "${skipCertificateVerification}", true);
+ setFieldWithPropertyAnnotation(real, "${skipHostnameVerification}", true);
+ cbamSecurityProvider = spy(real);
microServiceInfo.setNodes(nodes);
- setField(cbamSecurityProvider, "skipCertificateVerification", true);
- setField(cbamSecurityProvider, "skipHostnameVerification", true);
cbamRestApiProvider = new CbamRestApiProvider(driverProperties, cbamTokenProvider, vnfmInfoProvider, cbamSecurityProvider);
when(environment.getProperty(IpMappingProvider.IP_MAP, String.class, "")).thenReturn("");
when(environment.getProperty(GenericExternalSystemInfoProvider.VNFM_INFO_CACHE_EVICTION_IN_MS, Long.class, Long.valueOf(10 * 60 * 1000))).thenReturn(10 * 60 * 1000L);
@@ -156,6 +158,7 @@ public class TestCbamRestApiProvider extends TestBase {
* (questionable benefit [ this is more less ensured by Java type safety) ]
*/
@Test
+ @Useless
public void testCatalogAPiWrapping() {
com.nokia.cbam.catalog.v1.ApiClient c = Mockito.mock(com.nokia.cbam.catalog.v1.ApiClient.class);
class TestClasss extends CbamRestApiProvider {
@@ -169,6 +172,7 @@ public class TestCbamRestApiProvider extends TestBase {
}
}
DefaultApi defaultApi = Mockito.mock(DefaultApi.class);
+ //when
when(c.createService(DefaultApi.class)).thenReturn(defaultApi);
//verify
TestClasss testInstnace = new TestClasss();
@@ -181,6 +185,7 @@ public class TestCbamRestApiProvider extends TestBase {
* (questionable benefit [ this is more less ensured by Java type safety) ]
*/
@Test
+ @Useless
public void testLcmAPiWrapping() {
com.nokia.cbam.lcn.v32.ApiClient c = Mockito.mock(com.nokia.cbam.lcn.v32.ApiClient.class);
class TestClasss extends CbamRestApiProvider {
@@ -194,6 +199,7 @@ public class TestCbamRestApiProvider extends TestBase {
}
}
SubscriptionsApi defaultApi = Mockito.mock(SubscriptionsApi.class);
+ //when
when(c.createService(SubscriptionsApi.class)).thenReturn(defaultApi);
//verify
TestClasss testInstnace = new TestClasss();
@@ -206,6 +212,7 @@ public class TestCbamRestApiProvider extends TestBase {
* (questionable benefit [ this is more less ensured by Java type safety) ]
*/
@Test
+ @Useless
public void testLcnAPiWrapping() {
com.nokia.cbam.lcm.v32.ApiClient c = Mockito.mock(com.nokia.cbam.lcm.v32.ApiClient.class);
class TestClasss extends CbamRestApiProvider {
@@ -219,6 +226,7 @@ public class TestCbamRestApiProvider extends TestBase {
}
}
VnfsApi defaultApi = Mockito.mock(VnfsApi.class);
+ //when
when(c.createService(VnfsApi.class)).thenReturn(defaultApi);
//verify
TestClasss testInstnace = new TestClasss();
@@ -231,6 +239,7 @@ public class TestCbamRestApiProvider extends TestBase {
* (questionable benefit [ this is more less ensured by Java type safety) ]
*/
@Test
+ @Useless
public void testOperationExecutionsApiAPiWrapping() {
com.nokia.cbam.lcm.v32.ApiClient c = Mockito.mock(com.nokia.cbam.lcm.v32.ApiClient.class);
class TestClasss extends CbamRestApiProvider {
@@ -244,6 +253,7 @@ public class TestCbamRestApiProvider extends TestBase {
}
}
OperationExecutionsApi defaultApi = Mockito.mock(OperationExecutionsApi.class);
+ //when
when(c.createService(OperationExecutionsApi.class)).thenReturn(defaultApi);
//verify
TestClasss testInstnace = new TestClasss();
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestDriverProperties.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestDriverProperties.java
index 22db05b2..6a98e9e0 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestDriverProperties.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestDriverProperties.java
@@ -18,18 +18,36 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
import org.junit.Test;
+import static junit.framework.TestCase.assertEquals;
import static pl.pojo.tester.api.assertion.Assertions.assertPojoMethodsFor;
-public class TestDriverProperties {
+public class TestDriverProperties extends TestBase{
/**
* Test basic POJO behaviour
*/
@Test
public void test() {
+ assertPojoMethodsFor(DriverProperties.class).areWellImplemented();
+ }
+ /**
+ * Test parameter initialization by Spring
+ * - changes in this constants should be also altered in
+ * - application*.properties
+ * - in deployment configuration file
+ * - documentation
+ */
+ @Test
+ public void testSpringParameterLoading(){
+ DriverProperties driverProperties = new DriverProperties();
+ setFieldWithPropertyAnnotation(driverProperties, "${cbamCatalogUrl}", "cbamCatalogUrl");
+ setFieldWithPropertyAnnotation(driverProperties, "${cbamLcnUrl}", "cbamLcnUrl");
+ setFieldWithPropertyAnnotation(driverProperties, "${vnfmId}", "vnfmId");
+ assertEquals("cbamCatalogUrl", driverProperties.getCbamCatalogUrl());
+ assertEquals("cbamLcnUrl", driverProperties.getCbamLcnUrl());
+ assertEquals("vnfmId", driverProperties.getVnfmId());
- assertPojoMethodsFor(DriverProperties.class).areWellImplemented();
}
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Useless.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Useless.java
new file mode 100644
index 00000000..e13a5fd0
--- /dev/null
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/Useless.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2016-2017, Nokia Corporation
+ *
+ * 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.
+ */
+
+package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm;
+
+
+/**
+ * Used to note nearly useless tests
+ */
+public @interface Useless {
+
+} \ No newline at end of file