summaryrefslogtreecommitdiffstats
path: root/nokiav2/driver/src/test/java/org
diff options
context:
space:
mode:
authorDenes Nemeth <denes.nemeth@nokia.com>2018-03-07 12:54:19 +0100
committerDenes Nemeth <denes.nemeth@nokia.com>2018-03-07 21:56:38 +0100
commit817338bc7da3127ff01e6736d284a081461f484b (patch)
tree071d310a8b2a50ab81e3ea07a33dfc2b760cb04a /nokiav2/driver/src/test/java/org
parent45f12914d2ba01cd0b7df7069e2879d4d7d275c6 (diff)
Fix sonar issues
Change-Id: If699a0d8ba39238ff8e559567c8c5d44fb1e1d7c Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com> Issue-ID: VFC-728
Diffstat (limited to 'nokiav2/driver/src/test/java/org')
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java48
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java51
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java9
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java33
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestCbamUtils.java22
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestAdditionalParams.java2
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java11
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java40
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java2
10 files changed, 165 insertions, 55 deletions
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java
index ea1afe5f..17cf8258 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestGenericExternalSystemInfoProvider.java
@@ -27,6 +27,7 @@ import org.springframework.test.util.ReflectionTestUtils;
import static java.lang.Long.valueOf;
import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.fail;
import static org.mockito.Mockito.*;
public class TestGenericExternalSystemInfoProvider extends TestBase {
@@ -52,12 +53,12 @@ public class TestGenericExternalSystemInfoProvider extends TestBase {
//when
VnfmInfo vnfmInfo = genericExternalSystemInfoProvider.getVnfmInfo(VNFM_ID);
//verify
- verify(logger).info("Quering VNFM info from source with " + VNFM_ID + " identifier");
+ verify(logger).info("Querying VNFM info from source with " + VNFM_ID + " identifier");
assertEquals(expectedVnfmInfo, vnfmInfo);
//when
VnfmInfo vnfmInfo2 = genericExternalSystemInfoProvider.getVnfmInfo(VNFM_ID);
//verify source system not called again
- verify(logger).info("Quering VNFM info from source with " + VNFM_ID + " identifier");
+ verify(logger).info("Querying VNFM info from source with " + VNFM_ID + " identifier");
verify(genericExternalSystemInfoProvider, Mockito.times(1)).queryVnfmInfoFromSource(VNFM_ID);
}
@@ -65,24 +66,24 @@ public class TestGenericExternalSystemInfoProvider extends TestBase {
* the VNFM info is retrieved without the cache eviction period
*/
@Test
+ //sleeping is required to make time pass (for cache to notice the change)
+ //cache is configured with 1 ms cache eviction without sleep it is not
+ //deterministic that at least 1 ms time will pass between calls
+ @SuppressWarnings("squid:S2925")
public void testQueryVnfmInfoOutside() throws Exception {
VnfmInfo expectedVnfmInfo = Mockito.mock(VnfmInfo.class);
when(genericExternalSystemInfoProvider.queryVnfmInfoFromSource(VNFM_ID)).thenReturn(expectedVnfmInfo);
when(environment.getProperty(GenericExternalSystemInfoProvider.VNFM_INFO_CACHE_EVICTION_IN_MS, Long.class, valueOf(GenericExternalSystemInfoProvider.DEFAULT_CACHE_EVICTION_TIMEOUT_IN_MS))).thenReturn(Long.valueOf(1));
genericExternalSystemInfoProvider.afterPropertiesSet();
-
//when
VnfmInfo vnfmInfo = genericExternalSystemInfoProvider.getVnfmInfo(VNFM_ID);
//verify
assertEquals(expectedVnfmInfo, vnfmInfo);
//when
- //sleeping is required to make time pass (for cache to notice the change)
- //cache is configured with 1 ms cache eviction without sleep it is not
- //deterministic that at least 1 ms time will pass between calls
- Thread.sleep(10); //NO SONAR
+ Thread.sleep(10);
VnfmInfo vnfmInfo2 = genericExternalSystemInfoProvider.getVnfmInfo(VNFM_ID);
//verify source system called again
- verify(logger, times(2)).info("Quering VNFM info from source with " + VNFM_ID + " identifier");
+ verify(logger, times(2)).info("Querying VNFM info from source with " + VNFM_ID + " identifier");
verify(genericExternalSystemInfoProvider, Mockito.times(2)).queryVnfmInfoFromSource(VNFM_ID);
}
@@ -103,4 +104,35 @@ public class TestGenericExternalSystemInfoProvider extends TestBase {
}
}
+
+ /**
+ * Unable to query VNFM results is propagated
+ */
+ @Test
+ public void testUnableToQueryVnfmInfoProvider() throws Exception{
+ class TestClass extends GenericExternalSystemInfoProvider {
+
+ TestClass(Environment environment) {
+ super(environment);
+ }
+
+ @Override
+ public VnfmInfo queryVnfmInfoFromSource(String vnfmId) {
+ throw new RuntimeException();
+ }
+
+ @Override
+ public VimInfo getVimInfo(String vimId) {
+ return null;
+ }
+ }
+ try {
+ new TestClass(null).getVnfmInfo(VNFM_ID);
+ fail();
+ }
+ catch (Exception e){
+ assertEquals("Unable to query VNFM info for myVnfmId", e.getMessage());
+ verify(logger).error(eq("Unable to query VNFM info for myVnfmId"), any(RuntimeException.class));
+ }
+ }
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java
index e6d8ebb4..aefe63a2 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/core/TestMsbApiProvider.java
@@ -119,6 +119,57 @@ public class TestMsbApiProvider extends TestBase {
assertEquals("http://1.2.3.4:234/lead/nslcm/v1", msbApiProvider.getMicroServiceUrl("serviceName", "v1"));
}
+
+ /**
+ * use HTTPS for known ports (443) should be removed if https://jira.onap.org/browse/MSB-151 is solved
+ */
+ @Test
+ public void testMsb151IssueHack() throws Exception {
+ NodeInfo nonDocker = new NodeInfo();
+ nonDocker.setIp("173.1.2.3");
+ nonDocker.setPort("443");
+ microServiceInfo.setServiceName("serviceName");
+ microServiceInfo.setVersion("v1");
+ microServiceInfo.setUrl("/lead/nslcm/v1");
+ when(environment.getProperty(IpMappingProvider.IP_MAP, String.class, "")).thenReturn("173.1.2.3->1.2.3.4");
+ nodes.add(nonDocker);
+ msbApiProvider = new MsbApiProvider(environment) {
+ @Override
+ public MSBServiceClient getMsbClient() {
+ return msbClient;
+ }
+ };
+ when(msbClient.queryMicroServiceInfo("serviceName", "v1")).thenReturn(microServiceInfo);
+ msbApiProvider.afterPropertiesSet();
+ //when
+ assertEquals("https://1.2.3.4:443/lead/nslcm/v1", msbApiProvider.getMicroServiceUrl("serviceName", "v1"));
+ }
+
+ /**
+ * use HTTPS for known ports (443) should be removed if https://jira.onap.org/browse/MSB-151 is solved
+ */
+ @Test
+ public void testMsb151IssueHack2() throws Exception {
+ NodeInfo nonDocker = new NodeInfo();
+ nonDocker.setIp("173.1.2.3");
+ nonDocker.setPort("8443");
+ microServiceInfo.setServiceName("serviceName");
+ microServiceInfo.setVersion("v1");
+ microServiceInfo.setUrl("/lead/nslcm/v1");
+ when(environment.getProperty(IpMappingProvider.IP_MAP, String.class, "")).thenReturn("173.1.2.3->1.2.3.4");
+ nodes.add(nonDocker);
+ msbApiProvider = new MsbApiProvider(environment) {
+ @Override
+ public MSBServiceClient getMsbClient() {
+ return msbClient;
+ }
+ };
+ when(msbClient.queryMicroServiceInfo("serviceName", "v1")).thenReturn(microServiceInfo);
+ msbApiProvider.afterPropertiesSet();
+ //when
+ assertEquals("https://1.2.3.4:8443/lead/nslcm/v1", msbApiProvider.getMicroServiceUrl("serviceName", "v1"));
+ }
+
/**
* if unable to get micro service info the error is propagated
*/
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java
index 1edf5eca..fd93dce2 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/packagetransformer/TestOnapVnfdBuilder.java
@@ -28,6 +28,15 @@ import static junit.framework.TestCase.fail;
public class TestOnapVnfdBuilder extends TestBase {
private OnapVnfdBuilder packageTransformer = new OnapVnfdBuilder();
+ @Test
+ public void indent() {
+ assertEquals(" x", packageTransformer.indent("x", 2));
+ assertEquals(" x\n", packageTransformer.indent("x\n", 2));
+ assertEquals(" x\n y", packageTransformer.indent("x\ny", 2));
+ assertEquals(" x\n y\n", packageTransformer.indent("x\ny\n", 2));
+ assertEquals(" \n", packageTransformer.indent("\n", 2));
+ }
+
/**
* Test empty VNFD conversion
*/
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
index 9ac38914..95bdc5f4 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestConverterApi.java
@@ -37,9 +37,13 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.Part;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertTrue;
+import static junit.framework.TestCase.fail;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CatalogManager.getFileInZip;
@@ -48,7 +52,6 @@ import static org.springframework.test.util.ReflectionTestUtils.setField;
public class TestConverterApi extends TestBase {
-
@InjectMocks
private ConverterApi converterApi;
@Mock
@@ -60,9 +63,10 @@ public class TestConverterApi extends TestBase {
}
/**
+ * test VNF package conversion success scenario
*/
@Test
- public void test() throws Exception {
+ public void testConversion() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream actualOut = new PrintStream(bos, true);
when(systemFunctions.out()).thenReturn(actualOut);
@@ -97,8 +101,11 @@ public class TestConverterApi extends TestBase {
assertItenticalZips(expectedModifiedCbamPackage, actualModifiedCbamVnfPackage.toByteArray());
}
+ /**
+ * the HTML based converted page works
+ */
@Test
- public void testDownloaderPage() throws Exception {
+ public void testConverterPage() throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintStream actualOut = new PrintStream(bos, true);
when(httpResponse.getOutputStream()).thenReturn(new DelegatingServletOutputStream(actualOut));
@@ -106,9 +113,25 @@ public class TestConverterApi extends TestBase {
//when
converterApi.getUploadPageForConvertingVnfd(httpResponse);
//verify
- TestCase.assertTrue(Arrays.equals(TestUtil.loadFile("upload.html"), bos.toByteArray()));
+ assertTrue(Arrays.equals(TestUtil.loadFile("upload.html"), bos.toByteArray()));
verify(httpResponse).addHeader(HttpHeaders.CONTENT_LENGTH, Integer.toString(bos.toByteArray().length));
-
}
+ /**
+ * error is propagated if unable to extract package from HTTP request
+ */
+ @Test
+ public void testUnableToExtractPackageToBeConverted() throws Exception{
+ IOException expectedException = new IOException();
+ when(httpRequest.getParts()).thenThrow(expectedException);
+ try {
+ converterApi.convert(httpResponse, httpRequest);
+ fail();
+ }
+ catch (Exception e){
+ verify(logger).error("Unable to extract package from REST parameters", expectedException);
+ assertEquals("Unable to extract package from REST parameters", e.getMessage());
+ assertEquals(expectedException, e.getCause());
+ }
+ }
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java
index 1fdeb323..4d10fd52 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/TestLcmApi.java
@@ -56,7 +56,7 @@ public class TestLcmApi extends TestBase {
//when
lcmApi.instantiateVnf(req, VNFM_ID, httpResponse);
//verify
- verify(lifecycleManager).instantiate(VNFM_ID, req, httpResponse);
+ verify(lifecycleManager).createAndInstantiate(VNFM_ID, req, httpResponse);
verify(httpResponse).setStatus(SC_CREATED);
verify(logger).info("REST: Instantiate VNF");
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestCbamUtils.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestCbamUtils.java
index 7f544616..360e1d7c 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestCbamUtils.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/TestCbamUtils.java
@@ -102,14 +102,10 @@ public class TestCbamUtils {
public void testFatalFailure() throws Exception {
Exception expectedException = new Exception();
Logger logger = Mockito.mock(Logger.class);
- try {
- CbamUtils.fatalFailure(logger, "msg", expectedException);
- fail();
- } catch (RuntimeException e) {
- assertEquals("msg", e.getMessage());
- assertEquals(expectedException, e.getCause());
- verify(logger).error("msg", expectedException);
- }
+ RuntimeException e = CbamUtils.buildFatalFailure(logger, "msg", expectedException);
+ assertEquals("msg", e.getMessage());
+ assertEquals(expectedException, e.getCause());
+ verify(logger).error("msg", expectedException);
}
/**
@@ -118,13 +114,9 @@ public class TestCbamUtils {
@Test
public void testFatalFailureWithNoException() throws Exception {
Logger logger = Mockito.mock(Logger.class);
- try {
- CbamUtils.fatalFailure(logger, "msg");
- fail();
- } catch (RuntimeException e) {
- assertEquals("msg", e.getMessage());
- verify(logger).error("msg");
- }
+ RuntimeException e = CbamUtils.buildFatalFailure(logger, "msg");
+ assertEquals("msg", e.getMessage());
+ verify(logger).error("msg");
}
@Test
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestAdditionalParams.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestAdditionalParams.java
index e0e90000..d1afeac4 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestAdditionalParams.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestAdditionalParams.java
@@ -56,6 +56,6 @@ public class TestAdditionalParams {
}
final AbstractFieldValueChanger valueChanger = new MapValueChanger().attachNext(DefaultFieldValueChanger.INSTANCE);
- assertPojoMethodsFor(AdditionalParams.class).using(valueChanger).areWellImplemented();
+ assertPojoMethodsFor(AdditionalParameters.class).using(valueChanger).areWellImplemented();
}
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java
index aa3d63c4..4b59eeb3 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java
@@ -518,17 +518,16 @@ public class TestJobManager extends TestBase {
* Ongoing job are out waited during the the preparation for shutdown
*/
@Test
+ //need to wait for an asynchronous execution to finish
+ //this is the most optimal way to do it
+ @SuppressWarnings("squid:S2925")
public void onGoingJobsAreOutwaitedDuringShutdown() throws Exception {
String firstJobId = jobManager.spawnJob(VNF_ID, httpResponse);
ExecutorService executorService = Executors.newCachedThreadPool();
ArgumentCaptor<Integer> sleeps = ArgumentCaptor.forClass(Integer.class);
doNothing().when(systemFunctions).sleep(sleeps.capture());
- Future<?> shutDown = executorService.submit(new Runnable() {
- @Override
- public void run() {
- jobManager.prepareForShutdown();
- }
- });
+ //when prepare job manager for shutdown
+ Future<?> shutDown = executorService.submit(() -> jobManager.prepareForShutdown());
while (sleeps.getAllValues().size() == 0) {
try {
Thread.sleep(1);
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
index 2c28bfc1..3ff53643 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestLifecycleManager.java
@@ -80,7 +80,7 @@ public class TestLifecycleManager extends TestBase {
private VimInfoProvider vimInfoProvider;
private ArgumentCaptor<CreateVnfRequest> createRequest = ArgumentCaptor.forClass(CreateVnfRequest.class);
- private AdditionalParams additionalParam = new AdditionalParams();
+ private AdditionalParameters additionalParam = new AdditionalParameters();
private String INSTANTIATION_LEVEL = "level1";
private GrantVNFResponseVim grantResponse = new GrantVNFResponseVim();
private String cbamVnfdContent;
@@ -178,7 +178,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
//verify
assertEquals(VNF_ID, response.getVnfInstanceId());
@@ -251,6 +251,8 @@ public class TestLifecycleManager extends TestBase {
//the 3.2 API does not accept empty array
assertNull(actualVnfModifyRequest.getValue().getVnfConfigurableProperties());
verify(jobManager).spawnJob(VNF_ID, restResponse);
+ //verify(logger).info(eq("Additional parameters for instantiation: {}"), anyString());
+ //FIXME
}
/**
@@ -261,15 +263,17 @@ public class TestLifecycleManager extends TestBase {
//given
VnfInstantiateRequest instantiationRequest = prepareInstantiationRequest(VimInfo.VimInfoTypeEnum.OTHER_VIM_INFO);
when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(vnfInfo);
+ when(logger.isDebugEnabled()).thenReturn(false);
//when
try {
- lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
//verify
fail();
} catch (Exception e) {
assertEquals("Only OPENSTACK_V2_INFO, OPENSTACK_V3_INFO and VMWARE_VCLOUD_INFO is the supported VIM types", e.getMessage());
}
verify(vnfApi, never()).vnfsPost(Mockito.any(), Mockito.any());
+ verify(logger, never()).debug(eq("Additional parameters for instantiation: {}"), anyString());
verify(logger).error("Only OPENSTACK_V2_INFO, OPENSTACK_V3_INFO and VMWARE_VCLOUD_INFO is the supported VIM types");
}
@@ -293,7 +297,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -322,7 +326,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -348,7 +352,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -387,7 +391,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -425,7 +429,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -460,7 +464,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -497,7 +501,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -533,7 +537,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(1, actualInstantiationRequest.getValue().getVims().size());
//verify
@@ -567,7 +571,7 @@ public class TestLifecycleManager extends TestBase {
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenThrow(expectedException);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
//verfiy
waitForJobToFinishInJobManager(finished);
assertEquals(VNF_ID, response.getVnfInstanceId());
@@ -595,7 +599,7 @@ public class TestLifecycleManager extends TestBase {
ArgumentCaptor<InstantiateVnfRequest> actualInstantiationRequest = ArgumentCaptor.forClass(InstantiateVnfRequest.class);
when(vnfApi.vnfsVnfInstanceIdInstantiatePost(eq(VNF_ID), actualInstantiationRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenReturn(instantiationOperationExecution);
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
waitForJobToFinishInJobManager(finished);
assertEquals(0, actualInstantiationRequest.getAllValues().size());
//verify
@@ -632,7 +636,7 @@ public class TestLifecycleManager extends TestBase {
}
});
//when
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
//verfiy
waitForJobToFinishInJobManager(finished);
assertEquals(VNF_ID, response.getVnfInstanceId());
@@ -656,7 +660,7 @@ public class TestLifecycleManager extends TestBase {
when(vnfApi.vnfsPost(createRequest.capture(), eq(NOKIA_LCM_API_VERSION))).thenThrow(expectedException);
//when
try {
- lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
//verify
fail();
} catch (RuntimeException e) {
@@ -679,7 +683,7 @@ public class TestLifecycleManager extends TestBase {
//when
try {
- lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
//verify
fail();
} catch (RuntimeException e) {
@@ -704,7 +708,7 @@ public class TestLifecycleManager extends TestBase {
when(vimInfoProvider.getVimInfo(VIM_ID)).thenThrow(new RuntimeException());
//when
- lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
//verify
waitForJobToFinishInJobManager(finished);
verify(vnfApi, never()).vnfsVnfInstanceIdInstantiatePost(Mockito.any(), Mockito.any(), Mockito.any());
@@ -941,7 +945,7 @@ public class TestLifecycleManager extends TestBase {
instantiationRequest.setAdditionalParam(new JsonParser().parse(src));
//when
try {
- VnfInstantiateResponse response = lifecycleManager.instantiate(VNFM_ID, instantiationRequest, restResponse);
+ VnfInstantiateResponse response = lifecycleManager.createAndInstantiate(VNFM_ID, instantiationRequest, restResponse);
fail();
} catch (Exception e) {
assertEquals("The additional parameter section does not contain setting for VNF with myOnapCsarId CSAR id", e.getMessage());
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
index e26eab1a..18567f4c 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java
@@ -262,7 +262,7 @@ public class TestLifecycleChangeNotificationManager extends TestBase {
lifecycleChangeNotificationManager.handleLcn(recievedLcn);
//verify
Mockito.verifyZeroInteractions(operationExecutionApi);
- verify(logger).warn("The VNF with " + VNF_ID + " disappeared before being able to process the LCN");
+ verify(logger).warn("The VNF with " + VNF_ID + " identifier disappeared before being able to process the LCN");
}
/**