diff options
author | 2018-03-07 12:54:19 +0100 | |
---|---|---|
committer | 2018-03-07 21:56:38 +0100 | |
commit | 817338bc7da3127ff01e6736d284a081461f484b (patch) | |
tree | 071d310a8b2a50ab81e3ea07a33dfc2b760cb04a /nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm | |
parent | 45f12914d2ba01cd0b7df7069e2879d4d7d275c6 (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/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm')
4 files changed, 29 insertions, 26 deletions
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"); } /** |