diff options
Diffstat (limited to 'nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java')
4 files changed, 155 insertions, 7 deletions
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverterTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverterTest.java new file mode 100644 index 00000000..2d1c7a9a --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverterTest.java @@ -0,0 +1,150 @@ +/* + * 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.adaptor; + +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.OperationExecution; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.OperationExecution.OperationType; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.ScaleType; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmJobExecutionInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfmJobExecutionMapper; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.ScaleVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfResponse; + +public class Cbam2DriverResponseConverterTest { + @InjectMocks + Cbam2DriverResponseConverter convertor; + + @Mock + private VnfmJobExecutionMapper jobDbManager; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + AdaptorEnv adaptorEnv = new AdaptorEnv(); + adaptorEnv.setInitialProgress(10); + adaptorEnv.setInstantiateTimeInterval(60); + adaptorEnv.setTerminateTimeInterval(60); + convertor.setAdaptorEnv(adaptorEnv); + + VnfmJobExecutionInfo execInfo = new VnfmJobExecutionInfo(); + execInfo.setJobId(1L); + execInfo.setOperateStartTime(123456); + when(jobDbManager.findNewestJobInfo()).thenReturn(execInfo); + when(jobDbManager.findOne(Mockito.anyLong())).thenReturn(execInfo); + doNothing().when(jobDbManager).insert(Mockito.any(VnfmJobExecutionInfo.class)); + } + + @Test + public void testTerminateRspConvert() + { + CBAMTerminateVnfResponse cbamResponse = new CBAMTerminateVnfResponse(); + TerminateVnfResponse response = convertor.terminateRspConvert(cbamResponse); + } + + @Test + public void testCalculateProgressInstantiate() + { + OperationExecution operationExecution = new OperationExecution(); + operationExecution.setOperationType(OperationType.INSTANTIATE); + convertor.calculateProgress(operationExecution, "1"); + } + + @Test + public void testCalculateProgressTerminate() + { + OperationExecution operationExecution = new OperationExecution(); + operationExecution.setOperationType(OperationType.TERMINATE); + convertor.calculateProgress(operationExecution, "1"); + } + + @Test + public void testCalculateProgressScale() + { + OperationExecution operationExecution = new OperationExecution(); + operationExecution.setOperationType(OperationType.SCALE); + convertor.calculateProgress(operationExecution, "1"); + } + + @Test + public void testScaleRspConvertOut() + { + CBAMScaleVnfResponse cbamResponse = new CBAMScaleVnfResponse(); + ScaleVnfResponse response = convertor.scaleRspConvert(cbamResponse, ScaleType.SCALE_OUT); + } + + @Test + public void testScaleRspConvertIn() + { + CBAMScaleVnfResponse cbamResponse = new CBAMScaleVnfResponse(); + ScaleVnfResponse response = convertor.scaleRspConvert(cbamResponse, ScaleType.SCALE_IN); + } + + @Test + public void testHeallRspConvert() + { + CBAMHealVnfResponse cbamResponse = new CBAMHealVnfResponse(); + HealVnfResponse response = convertor.healRspConvert(cbamResponse); + } + + @Test + public void testOperRspConvertStarted() + { + OperationExecution operationExecution = new OperationExecution(); + operationExecution.setStatus(CommonEnum.OperationStatus.STARTED); + convertor.operRspConvert(operationExecution, "1"); + } + + @Test + public void testOperRspConvertFinished() + { + OperationExecution operationExecution = new OperationExecution(); + operationExecution.setStatus(CommonEnum.OperationStatus.FINISHED); + convertor.operRspConvert(operationExecution, "1"); + } + + @Test + public void testOperRspConvertOngoing() + { + OperationExecution operationExecution = new OperationExecution(); + operationExecution.setStatus(CommonEnum.OperationStatus.OTHER); + convertor.operRspConvert(operationExecution, "1"); + } + + @Test + public void testOperRspConvertFailed() + { + OperationExecution operationExecution = new OperationExecution(); + operationExecution.setStatus(CommonEnum.OperationStatus.FAILED); + convertor.operRspConvert(operationExecution, "1"); + } +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/ScaleVnfContinueRunnableTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/ScaleVnfContinueRunnableTest.java index b2109a13..38172162 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/ScaleVnfContinueRunnableTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/ScaleVnfContinueRunnableTest.java @@ -58,9 +58,7 @@ public class ScaleVnfContinueRunnableTest{ scaleVnfContinueRunnable.setDriverRequest(driverRequest); scaleVnfContinueRunnable.setJobId("1"); - scaleVnfContinueRunnable.setType(ScaleType.SCALE_IN); scaleVnfContinueRunnable.setVnfInstanceId("001"); - scaleVnfContinueRunnable.setVnfmId("001"); scaleVnfContinueRunnable.setRequestConverter(requestConverter); NslcmGrantVnfResponse grantResponse = new NslcmGrantVnfResponse(); diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImplTest.java index 9a05e23b..9f31e9f9 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImplTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImplTest.java @@ -52,7 +52,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMVnfNotificationResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.ExtManagedVirtualLinkData; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.ExtVirtualLinkData; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.NetworkAddress; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.Subscription; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.SubscriptionResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VimComputeResourceFlavour; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VimInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VimSoftwareImage; @@ -377,7 +377,7 @@ public class CbamMgmrImplTest { public void testGetSubscriptionSuccess() throws ClientProtocolException, IOException { String subscriptionId = "subscriptionId_001"; - Subscription response = cbamMgmr.getSubscription(subscriptionId); + SubscriptionResponse response = cbamMgmr.getSubscription(subscriptionId); } @Test @@ -388,7 +388,7 @@ public class CbamMgmrImplTest { when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult); String subscriptionId = "subscriptionId_001"; - Subscription response = cbamMgmr.getSubscription(subscriptionId); + SubscriptionResponse response = cbamMgmr.getSubscription(subscriptionId); } @Test diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverControllerTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverControllerTest.java index 97659a7b..103b394b 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverControllerTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverControllerTest.java @@ -288,12 +288,12 @@ public class VnfmDriverControllerTest { public void testCreateSubscripiton() throws Exception { CreateSubscriptionResponse mockResponse = new CreateSubscriptionResponse(); mockResponse.setCallbackUri("callbackUri"); - String jsonString = "{\"callbackUri\":\"callbackUri\",\"callbackUri\":\"callbackUrl\"," + "\"authentication\":{\"userName\":\"userName\",\"password\":\"password\",\"clientName\":\"clientName\"}}"; + String jsonString = "{\"callbackUri\":\"callbackUri\"," + "\"authentication\":{\"userName\":\"userName\",\"password\":\"password\",\"clientName\":\"clientName\"}}"; when(vnfmDriverMgmr.createSubscription(Mockito.any(CreateSubscriptionRequest.class))).thenReturn(mockResponse); String responseString = mockMvc.perform( - post("/api/nokiavnfmdriver/v1/createSubscripiton"). + post("/api/nokiavnfmdriver/v1/createSubscription"). characterEncoding("UTF-8"). accept(MediaType.APPLICATION_JSON). contentType(MediaType.APPLICATION_JSON). |