diff options
Diffstat (limited to 'nokiav2')
11 files changed, 91 insertions, 60 deletions
diff --git a/nokiav2/NOTES.txt b/nokiav2/NOTES.txt new file mode 100644 index 00000000..dc0957d4 --- /dev/null +++ b/nokiav2/NOTES.txt @@ -0,0 +1,5 @@ +Scatchpad + +mvn jacoco:report -Djacoco.dataFile='${project.build.directory}/code-coverage/jacoco-ut.exec' +mvn sonar:sonar -Dsonar.host.url=http://sonar.onap.org + diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AaiSecurityProvider.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AaiSecurityProvider.java index 688a82fd..1cd3346d 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AaiSecurityProvider.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/AaiSecurityProvider.java @@ -25,24 +25,24 @@ import org.springframework.stereotype.Component; @Component public class AaiSecurityProvider extends GenericSecurityProvider { @Value("${trustedCertificatesForAai}") - private String trustedCertificates; + private String trustedCertificatesForAai; @Value("${skipCertificateVerificationForAai}") - private boolean skipCertificateVerification; + private boolean skipCertificateVerificationForAai; @Value("${skipHostnameVerificationForAai}") - private boolean skipHostnameVerification; + private boolean skipHostnameVerificationForAai; @Override protected boolean skipHostnameVerification() { - return skipHostnameVerification; + return skipHostnameVerificationForAai; } @Override protected boolean skipCertificateVerification() { - return skipCertificateVerification; + return skipCertificateVerificationForAai; } @Override protected String trustedCertificates() { - return trustedCertificates; + return trustedCertificatesForAai; } } diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java index ab216bd7..37a6993a 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/LInterfaceManager.java @@ -95,22 +95,18 @@ class LInterfaceManager extends AbstractManager { logicalInterface.setInterfaceRole(affectedCp.getCpdId()); logicalInterface.setMacaddr(affectedCp.getMacAddress()); logicalInterface.setProvStatus("active"); + logicalInterface.setL3InterfaceIpv6AddressList(new ArrayList<>()); + logicalInterface.setL3InterfaceIpv4AddressList(new ArrayList<>()); if (affectedCp.getIpAddress() != null) { if (affectedCp.getIpAddress().contains(":")) { L3InterfaceIpv6AddressList ipv6Address = new L3InterfaceIpv6AddressList(); ipv6Address.setL3InterfaceIpv6Address(affectedCp.getIpAddress()); ipv6Address.setNeutronNetworkId(affectedCp.getNetworkProviderId()); - if (logicalInterface.getL3InterfaceIpv6AddressList() == null) { - logicalInterface.setL3InterfaceIpv6AddressList(new ArrayList<>()); - } logicalInterface.getL3InterfaceIpv6AddressList().add(ipv6Address); } else { L3InterfaceIpv4AddressList ipv4Address = new L3InterfaceIpv4AddressList(); ipv4Address.setL3InterfaceIpv4Address(affectedCp.getIpAddress()); ipv4Address.setNeutronNetworkId(affectedCp.getNetworkProviderId()); - if (logicalInterface.getL3InterfaceIpv4AddressList() == null) { - logicalInterface.setL3InterfaceIpv4AddressList(new ArrayList<>()); - } logicalInterface.getL3InterfaceIpv4AddressList().add(ipv4Address); } } diff --git a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java index c3405201..f7c9ed10 100644 --- a/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java +++ b/nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/restapi/LcmApi.java @@ -83,7 +83,7 @@ public class LcmApi { @ResponseBody public JobInfo terminateVnf(@RequestBody VnfTerminateRequest request, @PathVariable("vnfmId") String vnfmId, @PathVariable("vnfId") String vnfInstanceId, HttpServletResponse httpResponse) { logger.info("REST: Terminate VNF"); - return lifecycleManager.terminateVnf(vnfmId, vnfInstanceId, request, httpResponse); + return lifecycleManager.terminateAndDelete(vnfmId, vnfInstanceId, request, httpResponse); } /** 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 9b69fcfb..94ab240a 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 @@ -398,7 +398,7 @@ public class LifecycleManager { * @param httpResponse the HTTP response * @return the job for polling the progress of the termination */ - public JobInfo terminateVnf(String vnfmId, String vnfId, VnfTerminateRequest request, HttpServletResponse httpResponse) { + public JobInfo terminateAndDelete(String vnfmId, String vnfId, VnfTerminateRequest request, HttpServletResponse httpResponse) { logOperationInput(vnfId, "termination", request); return scheduleExecution(vnfId, httpResponse, "terminate", jobInfo -> { TerminateVnfRequest cbamRequest = new TerminateVnfRequest(); @@ -415,29 +415,34 @@ public class LifecycleManager { cbamRequest.setAdditionalParams(new Gson().toJsonTree(jobInfo).getAsJsonObject()); com.nokia.cbam.lcm.v32.model.VnfInfo vnf = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdGet(vnfId, NOKIA_LCM_API_VERSION).blockingFirst(); if (vnf.getInstantiationState() == INSTANTIATED) { - terminateVnf(vnfmId, vnfId, jobInfo, cbamRequest, vnf); + terminateAndDelete(vnfmId, vnfId, jobInfo, cbamRequest, vnf); } else { - cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdDelete(vnfId, NOKIA_LCM_API_VERSION).blockingFirst(); + logger.debug("The VNF {} with identifier is not instantiated no termination required", vnf.getId()); + deleteVnf(vnfmId, vnfId); } }); } - private void terminateVnf(String vnfmId, String vnfId, JobInfo jobInfo, TerminateVnfRequest cbamRequest, com.nokia.cbam.lcm.v32.model.VnfInfo vnf) { + private void terminateAndDelete(String vnfmId, String vnfId, JobInfo jobInfo, TerminateVnfRequest cbamRequest, com.nokia.cbam.lcm.v32.model.VnfInfo vnf) { String vimId = getVimIdFromInstantiationRequest(vnfmId, vnf); grantManager.requestGrantForTerminate(vnfmId, vnfId, vimId, getVnfdIdFromModifyableAttributes(vnf), vnf, jobInfo.getJobId()); OperationExecution terminationOperation = cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdTerminatePost(vnfId, cbamRequest, NOKIA_LCM_API_VERSION).blockingFirst(); OperationExecution finishedOperation = waitForOperationToFinish(vnfmId, vnfId, terminationOperation.getId()); if (finishedOperation.getStatus() == FINISHED) { notificationManager.waitForTerminationToBeProcessed(finishedOperation.getId()); - logger.info("Deleting VNF with {}", vnfId); - cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdDelete(vnfId, NOKIA_LCM_API_VERSION).blockingFirst(); - logger.info("VNF with {} has been deleted", vnfId); + deleteVnf(vnfmId, vnfId); } else { logger.error("Unable to terminate VNF the operation did not finish with success"); } } + private void deleteVnf(String vnfmId, String vnfId) { + logger.info("Deleting VNF with {} identifier", vnfId); + cbamRestApiProvider.getCbamLcmApi(vnfmId).vnfsVnfInstanceIdDelete(vnfId, NOKIA_LCM_API_VERSION).blockingFirst(); + logger.info("The VNF with {} identifier has been deleted", vnfId); + } + private String getVimIdFromInstantiationRequest(String vnfmId, com.nokia.cbam.lcm.v32.model.VnfInfo vnf) { OperationExecution lastInstantiation = findLastInstantiation(vnf.getOperationExecutions()); Object operationParameters = cbamRestApiProvider.getCbamOperationExecutionApi(vnfmId).operationExecutionsOperationExecutionIdOperationParamsGet(lastInstantiation.getId(), NOKIA_LCM_API_VERSION).blockingFirst(); @@ -571,12 +576,6 @@ public class LifecycleManager { logger.error("Unable to " + operation + " VNF with " + vnfId + " identifier", e); jobManager.jobFinished(jobInfo.getJobId()); throw e; - } catch (Exception e) { - String msg = "Unable to " + operation + " VNF with " + vnfId + " identifier"; - logger.error(msg, e); - //the job can only be signaled to be finished after the error is logged - jobManager.jobFinished(jobInfo.getJobId()); - throw new UserVisibleError(msg, e); } jobManager.jobFinished(jobInfo.getJobId()); }); @@ -616,10 +615,5 @@ public class LifecycleManager { this.vnfInfo = vnfInfo; this.vnfdId = vnfdId; } - - public com.nokia.cbam.lcm.v32.model.VnfInfo getVnfInfo() { - return vnfInfo; - } - } } diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIRestApiProvider.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIRestApiProvider.java index fafaf2cd..a97b74d5 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIRestApiProvider.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/TestAAIRestApiProvider.java @@ -56,7 +56,8 @@ public class TestAAIRestApiProvider extends TestBase { private AAIRestApiProvider aaiRestApiProvider; @Mock private HostnameVerifier hostnameVerifier; - private AaiSecurityProvider aaiSecurityProvider = spy(new AaiSecurityProvider()); + private AaiSecurityProvider aaiSecurityProviderReal = new AaiSecurityProvider(); + private AaiSecurityProvider aaiSecurityProvider = spy(aaiSecurityProviderReal); @Before public void init() { @@ -68,8 +69,8 @@ public class TestAAIRestApiProvider extends TestBase { */ @Test public void testApiClientBuilder() throws Exception { - setField(aaiSecurityProvider, "skipCertificateVerification", true); - setField(aaiSecurityProvider, "skipHostnameVerification", true); + when(aaiSecurityProvider.skipCertificateVerification()).thenReturn(true); + when(aaiSecurityProvider.skipHostnameVerification()).thenReturn(true); setFieldWithPropertyAnnotation(aaiRestApiProvider, "${aaiUsername}", "username"); setFieldWithPropertyAnnotation(aaiRestApiProvider, "${aaiPassword}", "aaiPassword"); ResultCaptor<SSLSocketFactory> sslSocketFactoryResultCaptor = new ResultCaptor<>(); @@ -107,8 +108,8 @@ public class TestAAIRestApiProvider extends TestBase { */ @Test public void testApiClientBuilderMissingSlash() throws Exception { - setField(aaiSecurityProvider, "skipCertificateVerification", true); - setField(aaiSecurityProvider, "skipHostnameVerification", true); + when(aaiSecurityProvider.skipCertificateVerification()).thenReturn(true); + when(aaiSecurityProvider.skipHostnameVerification()).thenReturn(true); setFieldWithPropertyAnnotation(aaiRestApiProvider, "${aaiUsername}", "username"); setFieldWithPropertyAnnotation(aaiRestApiProvider, "${aaiPassword}", "aaiPassword"); ResultCaptor<SSLSocketFactory> sslSocketFactoryResultCaptor = new ResultCaptor<>(); @@ -131,8 +132,8 @@ public class TestAAIRestApiProvider extends TestBase { */ @Test public void testApiClientBuilderForCloud() throws Exception { - setField(aaiSecurityProvider, "skipCertificateVerification", true); - setField(aaiSecurityProvider, "skipHostnameVerification", true); + when(aaiSecurityProvider.skipCertificateVerification()).thenReturn(true); + when(aaiSecurityProvider.skipHostnameVerification()).thenReturn(true); setFieldWithPropertyAnnotation(aaiRestApiProvider, "${aaiUsername}", "username"); setFieldWithPropertyAnnotation(aaiRestApiProvider, "${aaiPassword}", "aaiPassword"); ResultCaptor<SSLSocketFactory> sslSocketFactoryResultCaptor = new ResultCaptor<>(); @@ -155,8 +156,8 @@ public class TestAAIRestApiProvider extends TestBase { */ @Test public void testApiClientBuilderForExternalSystems() throws Exception { - setField(aaiSecurityProvider, "skipCertificateVerification", true); - setField(aaiSecurityProvider, "skipHostnameVerification", true); + when(aaiSecurityProvider.skipCertificateVerification()).thenReturn(true); + when(aaiSecurityProvider.skipHostnameVerification()).thenReturn(true); setFieldWithPropertyAnnotation(aaiRestApiProvider, "${aaiUsername}", "username"); setFieldWithPropertyAnnotation(aaiRestApiProvider, "${aaiPassword}", "aaiPassword"); ResultCaptor<SSLSocketFactory> sslSocketFactoryResultCaptor = new ResultCaptor<>(); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestLInterfaceManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestLInterfaceManager.java index 0ac93330..8cef628e 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestLInterfaceManager.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestLInterfaceManager.java @@ -86,7 +86,7 @@ public class TestLInterfaceManager extends TestBase { assertEquals("mac", actualInterface.getMacaddr()); assertEquals("active", actualInterface.getProvStatus()); assertEquals(1, actualInterface.getL3InterfaceIpv4AddressList().size()); - assertEquals(null, actualInterface.getL3InterfaceIpv6AddressList()); + assertEquals(0, actualInterface.getL3InterfaceIpv6AddressList().size()); assertEquals("networkProviderId", actualInterface.getL3InterfaceIpv4AddressList().get(0).getNeutronNetworkId()); assertEquals("1.2.3.4", actualInterface.getL3InterfaceIpv4AddressList().get(0).getL3InterfaceIpv4Address()); assertRelation(actualInterface.getRelationshipList(), "generic-vnf", buildRelationshipData("generic-vnf.vnf-id", VNF_ID)); @@ -124,8 +124,8 @@ public class TestLInterfaceManager extends TestBase { assertEquals("cpdId", actualInterface.getInterfaceRole()); assertEquals("mac", actualInterface.getMacaddr()); assertEquals("active", actualInterface.getProvStatus()); - assertEquals(null, actualInterface.getL3InterfaceIpv6AddressList()); - assertEquals(null, actualInterface.getL3InterfaceIpv4AddressList()); + assertEquals(0, actualInterface.getL3InterfaceIpv6AddressList().size()); + assertEquals(0, actualInterface.getL3InterfaceIpv4AddressList().size()); assertRelation(actualInterface.getRelationshipList(), "generic-vnf", buildRelationshipData("generic-vnf.vnf-id", VNF_ID)); VOID_OBSERVABLE.assertCalled(); } @@ -165,7 +165,7 @@ public class TestLInterfaceManager extends TestBase { assertEquals("mac", actualInterface.getMacaddr()); assertEquals("active", actualInterface.getProvStatus()); assertEquals(1, actualInterface.getL3InterfaceIpv4AddressList().size()); - assertEquals(null, actualInterface.getL3InterfaceIpv6AddressList()); + assertEquals(0, actualInterface.getL3InterfaceIpv6AddressList().size()); assertEquals("networkProviderId", actualInterface.getL3InterfaceIpv4AddressList().get(0).getNeutronNetworkId()); assertEquals("1.2.3.4", actualInterface.getL3InterfaceIpv4AddressList().get(0).getL3InterfaceIpv4Address()); assertEquals("v3", lInterface.getResourceVersion()); @@ -207,7 +207,7 @@ public class TestLInterfaceManager extends TestBase { assertEquals("cpdId", actualInterface.getInterfaceRole()); assertEquals("mac", actualInterface.getMacaddr()); assertEquals("active", actualInterface.getProvStatus()); - assertEquals(null, actualInterface.getL3InterfaceIpv4AddressList()); + assertEquals(0, actualInterface.getL3InterfaceIpv4AddressList().size()); assertEquals(1, actualInterface.getL3InterfaceIpv6AddressList().size()); assertEquals("networkProviderId", actualInterface.getL3InterfaceIpv6AddressList().get(0).getNeutronNetworkId()); assertEquals("::", actualInterface.getL3InterfaceIpv6AddressList().get(0).getL3InterfaceIpv6Address()); diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVnfcManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVnfcManager.java index efec7b37..ece65ee6 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVnfcManager.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/onap/direct/notification/TestVnfcManager.java @@ -17,7 +17,9 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification; import com.nokia.cbam.lcm.v32.model.AffectedVnfc; import com.nokia.cbam.lcm.v32.model.ResourceHandle; +import io.reactivex.Observable; import java.util.ArrayList; +import java.util.NoSuchElementException; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -53,6 +55,36 @@ public class TestVnfcManager extends TestBase { when(aaiRestApiProvider.getNetworkApi()).thenReturn(networkApi); } + + /** + * test create + */ + @Test + public void testCreate() throws Exception { + AffectedVnfc affectedVnfc = new AffectedVnfc(); + affectedVnfc.setComputeResource(new ResourceHandle()); + affectedVnfc.getComputeResource().setResourceId("serverProviderId"); + affectedVnfc.setId("vnfcId"); + when(networkApi.getNetworkVnfcsVnfc("myVnfId_vnfcId", null, null, null, null, null, null, null, null, null)).thenReturn(Observable.error(new NoSuchElementException())); + when(networkApi.createOrUpdateNetworkVnfcsVnfc(eq("myVnfId_vnfcId"), payload.capture())).thenReturn(VOID_OBSERVABLE.value()); + //when + vnfcManager.update(VIM_ID, "myTenantPrivderId", VNF_ID, affectedVnfc, true); + //verify + Vnfc vnfc = payload.getValue(); + assertEquals("myVnfId_vnfcId", vnfc.getVnfcName()); + assertEquals("vnfcId", vnfc.getNfcFunction()); + assertEquals("vnfcId", vnfc.getNfcNamingCode()); + assertRelation(payload.getValue().getRelationshipList(), "generic-vnf", buildRelationshipData("generic-vnf.vnf-id", VNF_ID)); + + assertRelation(vnfc.getRelationshipList(), "vserver", + buildRelationshipData("cloud-region.cloud-owner", getCloudOwner(VIM_ID)), + buildRelationshipData("cloud-region.cloud-region-id", getRegionName(VIM_ID)), + buildRelationshipData("tenant.tenant-id", "myTenantPrivderId"), + buildRelationshipData("vserver.vserver-id", "serverProviderId")); + assertEquals(2, vnfc.getRelationshipList().size()); + VOID_OBSERVABLE.assertCalled(); + } + /** * test update */ 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 dbbad3f0..8711c3f4 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 @@ -112,7 +112,7 @@ public class TestLcmApi extends TestBase { //when lcmApi.terminateVnf(req, VNFM_ID, VNF_ID, httpResponse); //verify - verify(lifecycleManager).terminateVnf(VNFM_ID, VNF_ID, req, httpResponse); + verify(lifecycleManager).terminateAndDelete(VNFM_ID, VNF_ID, req, httpResponse); verify(logger).info("REST: Terminate VNF"); } diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java index a699ee9e..e61edc3c 100644 --- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java +++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestBase.java @@ -26,10 +26,7 @@ import io.reactivex.internal.operators.observable.ObservableFromCallable; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.lang.reflect.Field; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.Callable; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -209,12 +206,14 @@ public class TestBase { try { field.setAccessible(true); field.set(obj, value); + return; } catch (IllegalAccessException e) { throw new RuntimeException(e); } } } } + throw new NoSuchElementException("The " + obj.getClass() + " does not have a filed with " + key + " annotation"); } protected static class VoidObservable { 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 178f0b5a..16d1f021 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 @@ -750,7 +750,7 @@ public class TestLifecycleManager extends TestBase { JsonElement instantiationParameters = new JsonParser().parse("{ \"vims\" : [ { \"id\" : \"" + VIM_ID + "\" } ] } "); when(operationExecutionApi.operationExecutionsOperationExecutionIdOperationParamsGet("operationExecutionId", NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(instantiationParameters)); //when - JobInfo jobInfo = lifecycleManager.terminateVnf(VNFM_ID, VNF_ID, terminationRequest, restResponse); + JobInfo jobInfo = lifecycleManager.terminateAndDelete(VNFM_ID, VNF_ID, terminationRequest, restResponse); //verify waitForJobToFinishInJobManager(finished); assertEquals(1, actualTerminationRequest.getAllValues().size()); @@ -781,21 +781,25 @@ public class TestLifecycleManager extends TestBase { vnfdId.setValue(ONAP_CSAR_ID); vnfInfo.getExtensions().add(vnfdId); JsonElement instantiationParameters = new JsonParser().parse("{ \"vims\" : [ { \"id\" : \"" + VIM_ID + "\" } ] } "); + when(vnfApi.vnfsVnfInstanceIdDelete(VNF_ID, NOKIA_LCM_API_VERSION)).thenReturn(VOID_OBSERVABLE.value()); when(operationExecutionApi.operationExecutionsOperationExecutionIdOperationParamsGet("operationExecutionId", NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(instantiationParameters)); //when - JobInfo jobInfo = lifecycleManager.terminateVnf(VNFM_ID, VNF_ID, terminationRequest, restResponse); + lifecycleManager.terminateAndDelete(VNFM_ID, VNF_ID, terminationRequest, restResponse); //verify boolean deleted = false; while (!deleted) { try { - Mockito. - verify(vnfApi).vnfsVnfInstanceIdDelete(VNF_ID, NOKIA_LCM_API_VERSION); + verify(vnfApi).vnfsVnfInstanceIdDelete(VNF_ID, NOKIA_LCM_API_VERSION); deleted = true; } catch (Error e) { } } verify(vfcGrantManager, never()).requestGrantForTerminate(VNFM_ID, VNF_ID, VIM_ID, ONAP_CSAR_ID, vnfInfo, JOB_ID); verify(notificationManager, never()).waitForTerminationToBeProcessed("terminationId"); + verify(logger).debug("The VNF {} with identifier is not instantiated no termination required", VNF_ID); + verify(logger).info("Deleting VNF with {} identifier", VNF_ID); + verify(logger).info("The VNF with {} identifier has been deleted", VNF_ID); + VOID_OBSERVABLE.assertCalled(); } /** @@ -831,7 +835,7 @@ public class TestLifecycleManager extends TestBase { return buildObservable(operationExecutions); }); //when - JobInfo jobInfo = lifecycleManager.terminateVnf(VNFM_ID, VNF_ID, terminationRequest, restResponse); + JobInfo jobInfo = lifecycleManager.terminateAndDelete(VNFM_ID, VNF_ID, terminationRequest, restResponse); //verify waitForJobToFinishInJobManager(finished); verify(vnfApi, times(1001)).vnfsVnfInstanceIdOperationExecutionsGet(VNF_ID, NOKIA_LCM_API_VERSION); @@ -882,7 +886,7 @@ public class TestLifecycleManager extends TestBase { } }); //when - JobInfo jobInfo = lifecycleManager.terminateVnf(VNFM_ID, VNF_ID, terminationRequest, restResponse); + JobInfo jobInfo = lifecycleManager.terminateAndDelete(VNFM_ID, VNF_ID, terminationRequest, restResponse); //verify waitForJobToFinishInJobManager(finished); verify(vnfApi, times(101)).vnfsVnfInstanceIdOperationExecutionsGet(VNF_ID, NOKIA_LCM_API_VERSION); @@ -926,7 +930,7 @@ public class TestLifecycleManager extends TestBase { JsonElement instantiationParameters = new JsonParser().parse("{ \"vims\" : [ { \"id\" : \"" + VIM_ID + "\" } ] } "); when(operationExecutionApi.operationExecutionsOperationExecutionIdOperationParamsGet("operationExecutionId", NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(instantiationParameters)); //when - JobInfo jobInfo = lifecycleManager.terminateVnf(VNFM_ID, VNF_ID, terminationRequest, restResponse); + JobInfo jobInfo = lifecycleManager.terminateAndDelete(VNFM_ID, VNF_ID, terminationRequest, restResponse); //verify waitForJobToFinishInJobManager(finished); assertEquals(1, actualTerminationRequest.getAllValues().size()); @@ -988,7 +992,7 @@ public class TestLifecycleManager extends TestBase { JsonElement instantiationParameters = new JsonParser().parse("{ \"vims\" : [ { \"id\" : \"" + VIM_ID + "\" } ] } "); when(operationExecutionApi.operationExecutionsOperationExecutionIdOperationParamsGet("operationExecutionId", NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(instantiationParameters)); //when - JobInfo jobInfo = lifecycleManager.terminateVnf(VNFM_ID, VNF_ID, terminationRequest, restResponse); + JobInfo jobInfo = lifecycleManager.terminateAndDelete(VNFM_ID, VNF_ID, terminationRequest, restResponse); //verify waitForJobToFinishInJobManager(finished); assertEquals(1, actualTerminationRequest.getAllValues().size()); @@ -1032,7 +1036,7 @@ public class TestLifecycleManager extends TestBase { JsonElement instantiationParameters = new JsonParser().parse("{ \"vims\" : [ { \"id\" : \"" + VIM_ID + "\" } ] } "); when(operationExecutionApi.operationExecutionsOperationExecutionIdOperationParamsGet("operationExecutionId", NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(instantiationParameters)); //when - JobInfo jobInfo = lifecycleManager.terminateVnf(VNFM_ID, VNF_ID, terminationRequest, restResponse); + JobInfo jobInfo = lifecycleManager.terminateAndDelete(VNFM_ID, VNF_ID, terminationRequest, restResponse); //verify waitForJobToFinishInJobManager(finished); assertEquals(0, actualTerminationRequest.getAllValues().size()); @@ -1067,7 +1071,7 @@ public class TestLifecycleManager extends TestBase { JsonElement instantiationParameters = new JsonParser().parse("{ \"vims\" : [ { \"id\" : \"" + VIM_ID + "\" } ] } "); when(operationExecutionApi.operationExecutionsOperationExecutionIdOperationParamsGet("operationExecutionId", NOKIA_LCM_API_VERSION)).thenReturn(buildObservable(instantiationParameters)); //when - JobInfo jobInfo = lifecycleManager.terminateVnf(VNFM_ID, VNF_ID, terminationRequest, restResponse); + JobInfo jobInfo = lifecycleManager.terminateAndDelete(VNFM_ID, VNF_ID, terminationRequest, restResponse); //verify waitForJobToFinishInJobManager(finished); assertEquals(1, actualTerminationRequest.getAllValues().size()); |