diff options
author | yufei_zhou <yufei.zhou@nokia-sbell.com> | 2018-02-12 15:17:27 +0800 |
---|---|---|
committer | yufei_zhou <yufei.zhou@nokia-sbell.com> | 2018-02-12 15:52:49 +0800 |
commit | e29ba7011fd255cdd9780b1d5859b1f1d5c981e5 (patch) | |
tree | 436cbda610823050d3f664e3eb5d1870c2b4ac9f /nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap | |
parent | 834ea30c777cbb481e24200f168128e4885fd7bd (diff) |
Improve unit-test coverage
Change-Id: I734ed2d92e8ba00f0fb9ee6085835472352cc5e6
Issue-ID: VFC-724
Signed-off-by: yufei_zhou <yufei.zhou@nokia-sbell.com>
Diffstat (limited to 'nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap')
8 files changed, 466 insertions, 4 deletions
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/HealVnfContinueRunnableTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/HealVnfContinueRunnableTest.java new file mode 100644 index 00000000..e2d431f1 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/HealVnfContinueRunnableTest.java @@ -0,0 +1,84 @@ +/* + * 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.CBAMHealVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf; +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.nslcm.bo.NslcmGrantVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfRequest; + +public class HealVnfContinueRunnableTest { + @InjectMocks + private HealVnfContinueRunnable healVnfContinueRunnable; + + @Mock + private CbamMgmrInf cbamMgmr; + + @Mock + private NslcmMgmrInf nslcmMgmr; + + @Mock + private VnfmJobExecutionMapper jobDbMgmr; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + HealVnfRequest driverRequest = new HealVnfRequest(); + Driver2CbamRequestConverter requestConverter = new Driver2CbamRequestConverter(); + String vnfInstanceId = "vnfInstanceId_001"; + String jobId = "001"; + String vnfmId = "vnfmId_001"; + + healVnfContinueRunnable.setDriverRequest(driverRequest); + healVnfContinueRunnable.setRequestConverter(requestConverter); + healVnfContinueRunnable.setVnfInstanceId(vnfInstanceId); + healVnfContinueRunnable.setJobId(jobId); + healVnfContinueRunnable.setVnfmId(vnfmId); + + NslcmGrantVnfResponse grantResponse = new NslcmGrantVnfResponse(); + CBAMHealVnfResponse cbamResponse = new CBAMHealVnfResponse(); + cbamResponse.setId("1"); + VnfmJobExecutionInfo execInfo = new VnfmJobExecutionInfo(); + execInfo.setJobId(1L); + + when(nslcmMgmr.grantVnf(Mockito.any(NslcmGrantVnfRequest.class))).thenReturn(grantResponse); + when(cbamMgmr.healVnf(Mockito.any(CBAMHealVnfRequest.class), Mockito.anyString())).thenReturn(cbamResponse); + when(jobDbMgmr.findOne(Mockito.anyLong())).thenReturn(execInfo); + doNothing().when(jobDbMgmr).update(Mockito.any(VnfmJobExecutionInfo.class)); + + } + + @Test + public void testRun() + { + healVnfContinueRunnable.run(); + } +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/InstantiateVnfContinueRunnableTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/InstantiateVnfContinueRunnableTest.java new file mode 100644 index 00000000..d4d13458 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/InstantiateVnfContinueRunnableTest.java @@ -0,0 +1,115 @@ +/* + * 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 java.util.ArrayList; +import java.util.List; + +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.CBAMInstantiateVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMModifyVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMModifyVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryOperExecutionResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.ComputeResource; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VnfcResourceInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum.OperationStatus; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmJobExecutionInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfcResourceInfoMapper; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfmJobExecutionMapper; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVnfc; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.InstantiateVnfRequest; + +public class InstantiateVnfContinueRunnableTest{ + @InjectMocks + private InstantiateVnfContinueRunnable instantiateVnfContinueRunnable; + + @Mock + private CbamMgmrInf cbamMgmr; + + @Mock + private NslcmMgmrInf nslcmMgmr; + + @Mock + private VnfmJobExecutionMapper jobDbMgmr; + + @Mock + private VnfcResourceInfoMapper vnfcDbMgmr; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + InstantiateVnfRequest driverRequest = new InstantiateVnfRequest(); + Driver2CbamRequestConverter requestConverter = new Driver2CbamRequestConverter(); + + instantiateVnfContinueRunnable.setDriverRequest(driverRequest); + instantiateVnfContinueRunnable.setJobId("1"); + instantiateVnfContinueRunnable.setVnfInstanceId("001"); + instantiateVnfContinueRunnable.setVnfmId("001"); + instantiateVnfContinueRunnable.setRequestConverter(requestConverter); + + NslcmGrantVnfResponse grantResponse = new NslcmGrantVnfResponse(); + CBAMInstantiateVnfResponse cbamResponse = new CBAMInstantiateVnfResponse(); + cbamResponse.setId("1"); + CBAMModifyVnfResponse modifyResponse = new CBAMModifyVnfResponse(); + modifyResponse.setId("2"); + VnfmJobExecutionInfo execInfo = new VnfmJobExecutionInfo(); + execInfo.setJobId(1L); + + CBAMQueryOperExecutionResponse exeResponse = new CBAMQueryOperExecutionResponse(); + exeResponse.setStatus(OperationStatus.FINISHED); + + List<VnfcResourceInfo> vnfcResources = new ArrayList<>(); + VnfcResourceInfo res = new VnfcResourceInfo(); + res.setId("1"); + res.setVduId("vduId"); + ComputeResource computeResource = new ComputeResource(); + computeResource.setResourceId("resourceId"); + computeResource.setResourceType("OS::Nova::Server"); + computeResource.setVimId("vimId"); + res.setComputeResource(computeResource); + + vnfcResources.add(res); + + when(nslcmMgmr.grantVnf(Mockito.any(NslcmGrantVnfRequest.class))).thenReturn(grantResponse); + when(cbamMgmr.instantiateVnf(Mockito.any(CBAMInstantiateVnfRequest.class), Mockito.anyString())).thenReturn(cbamResponse); + when(cbamMgmr.modifyVnf(Mockito.any(CBAMModifyVnfRequest.class), Mockito.anyString())).thenReturn(modifyResponse); + when(cbamMgmr.queryOperExecution(Mockito.anyString())).thenReturn(exeResponse); + when(cbamMgmr.queryVnfcResource(Mockito.anyString())).thenReturn(vnfcResources); + when(jobDbMgmr.findOne(Mockito.anyLong())).thenReturn(execInfo); + doNothing().when(jobDbMgmr).update(Mockito.any(VnfmJobExecutionInfo.class)); + doNothing().when(vnfcDbMgmr).insert(Mockito.any(AffectedVnfc.class)); + } + + @Test + public void testRun() + { + instantiateVnfContinueRunnable.run(); + } +} 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 new file mode 100644 index 00000000..b2109a13 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/ScaleVnfContinueRunnableTest.java @@ -0,0 +1,83 @@ +/* + * 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.CBAMScaleVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf; +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.nslcm.bo.NslcmGrantVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.ScaleVnfRequest; + +public class ScaleVnfContinueRunnableTest{ + @InjectMocks + private ScaleVnfContinueRunnable scaleVnfContinueRunnable; + + @Mock + private CbamMgmrInf cbamMgmr; + + @Mock + private NslcmMgmrInf nslcmMgmr; + + @Mock + private VnfmJobExecutionMapper jobDbMgmr; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + ScaleVnfRequest driverRequest = new ScaleVnfRequest(); + driverRequest.setType(ScaleType.SCALE_IN); + Driver2CbamRequestConverter requestConverter = new Driver2CbamRequestConverter(); + + scaleVnfContinueRunnable.setDriverRequest(driverRequest); + scaleVnfContinueRunnable.setJobId("1"); + scaleVnfContinueRunnable.setType(ScaleType.SCALE_IN); + scaleVnfContinueRunnable.setVnfInstanceId("001"); + scaleVnfContinueRunnable.setVnfmId("001"); + scaleVnfContinueRunnable.setRequestConverter(requestConverter); + + NslcmGrantVnfResponse grantResponse = new NslcmGrantVnfResponse(); + CBAMScaleVnfResponse cbamResponse = new CBAMScaleVnfResponse(); + cbamResponse.setId("1"); + VnfmJobExecutionInfo execInfo = new VnfmJobExecutionInfo(); + execInfo.setJobId(1L); + + when(nslcmMgmr.grantVnf(Mockito.any(NslcmGrantVnfRequest.class))).thenReturn(grantResponse); + when(cbamMgmr.scaleVnf(Mockito.any(CBAMScaleVnfRequest.class), Mockito.anyString())).thenReturn(cbamResponse); + when(jobDbMgmr.findOne(Mockito.anyLong())).thenReturn(execInfo); + doNothing().when(jobDbMgmr).update(Mockito.any(VnfmJobExecutionInfo.class)); + } + + @Test + public void testRun() + { + scaleVnfContinueRunnable.run(); + } +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/TermiateVnfContinueRunnableTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/TermiateVnfContinueRunnableTest.java new file mode 100644 index 00000000..96808ad7 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/TermiateVnfContinueRunnableTest.java @@ -0,0 +1,110 @@ +/* + * 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 java.util.ArrayList; +import java.util.List; + +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.CBAMModifyVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryOperExecutionResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.ComputeResource; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VnfcResourceInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum.OperationStatus; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmJobExecutionInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfcResourceInfoMapper; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfmJobExecutionMapper; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmGrantVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVnfc; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.TerminateVnfRequest; + +public class TermiateVnfContinueRunnableTest{ + @InjectMocks + private TerminateVnfContinueRunnable terminateVnfContinueRunnable; + + @Mock + private CbamMgmrInf cbamMgmr; + + @Mock + private NslcmMgmrInf nslcmMgmr; + + @Mock + private VnfmJobExecutionMapper jobDbMgmr; + + @Mock + private VnfcResourceInfoMapper vnfcDbMgmr;; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + TerminateVnfRequest driverRequest = new TerminateVnfRequest(); + Driver2CbamRequestConverter requestConverter = new Driver2CbamRequestConverter(); + + terminateVnfContinueRunnable.setDriverRequest(driverRequest); + terminateVnfContinueRunnable.setJobId("1"); + terminateVnfContinueRunnable.setVnfInstanceId("001"); + terminateVnfContinueRunnable.setVnfmId("001"); + terminateVnfContinueRunnable.setRequestConverter(requestConverter); + + NslcmGrantVnfResponse grantResponse = new NslcmGrantVnfResponse(); + CBAMTerminateVnfResponse cbamResponse = new CBAMTerminateVnfResponse(); + cbamResponse.setId("1"); + CBAMModifyVnfResponse modifyResponse = new CBAMModifyVnfResponse(); + modifyResponse.setId("2"); + VnfmJobExecutionInfo execInfo = new VnfmJobExecutionInfo(); + execInfo.setJobId(1L); + + CBAMQueryOperExecutionResponse exeResponse = new CBAMQueryOperExecutionResponse(); + exeResponse.setStatus(OperationStatus.FINISHED); + + List<AffectedVnfc> vnfcResources = new ArrayList<>(); + + CBAMQueryVnfResponse cQueryVnfResponse = new CBAMQueryVnfResponse(); + cQueryVnfResponse.setInstantiationState(CommonEnum.InstantiationState.NOT_INSTANTIATED); + + when(nslcmMgmr.grantVnf(Mockito.any(NslcmGrantVnfRequest.class))).thenReturn(grantResponse); + when(cbamMgmr.terminateVnf(Mockito.any(CBAMTerminateVnfRequest.class), Mockito.anyString())).thenReturn(cbamResponse); + when(cbamMgmr.queryVnf(Mockito.anyString())).thenReturn(cQueryVnfResponse); + doNothing().when(cbamMgmr).deleteVnf(Mockito.anyString()); + + when(vnfcDbMgmr.getAllByInstanceId(Mockito.anyString())).thenReturn(vnfcResources); + when(cbamMgmr.queryOperExecution(Mockito.anyString())).thenReturn(exeResponse); + when(jobDbMgmr.findOne(Mockito.anyLong())).thenReturn(execInfo); + doNothing().when(jobDbMgmr).update(Mockito.any(VnfmJobExecutionInfo.class)); + } + + @Test + public void testRun() + { + terminateVnfContinueRunnable.run(); + } +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java index b47cc4db..f3fb6f3b 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java @@ -49,7 +49,7 @@ 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.repository.VnfmJobExecutionRepository; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfmJobExecutionMapper; import org.onap.vfc.nfvo.driver.vnfm.svnfm.exception.VnfmDriverException; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.inf.NslcmMgmrInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo.HealVnfRequest; @@ -82,7 +82,7 @@ public class VnfmDriverMgmrImplTest { private NslcmMgmrInf nslcmMgmr;; @Mock - private VnfmJobExecutionRepository jobDbManager; + private VnfmJobExecutionMapper jobDbManager; @Mock private VnfContinueProcessorInf vnfContinueProcessorInf; @@ -96,6 +96,8 @@ public class VnfmDriverMgmrImplTest { private String vnfmId = "vnfmId_001"; private String vnfInstanceId = "vnfInstanceId_001"; + private ScaleType type; + private String protocol = "https"; private String ip = "139.234.34.43"; private String port = "99"; @@ -135,7 +137,7 @@ public class VnfmDriverMgmrImplTest { execInfo.setVnfmExecutionId("executionId_001"); execInfo.setVnfInstanceId(vnfInstanceId); - when(jobDbManager.save(Mockito.any(VnfmJobExecutionInfo.class))).thenReturn(execInfo); + when(jobDbManager.findNewestJobInfo()).thenReturn(execInfo); } @Test @@ -200,6 +202,7 @@ public class VnfmDriverMgmrImplTest { VnfmJobExecutionInfo execInfo = new VnfmJobExecutionInfo(); execInfo.setJobId(1L); execInfo.setVnfmExecutionId("executionId_001"); + execInfo.setStatus("finished"); when(jobDbManager.findOne(Mockito.anyLong())).thenReturn(execInfo); CBAMQueryOperExecutionResponse cbamResponse = new CBAMQueryOperExecutionResponse(); @@ -208,7 +211,7 @@ public class VnfmDriverMgmrImplTest { cbamResponse.setGrantId("001002001"); // when(cbamMgmr.queryOperExecution(Mockito.anyString())).thenReturn(cbamResponse); -// OperStatusVnfResponse response = vnfmDriverMgmr.getOperStatus(vnfmId, "1"); + OperStatusVnfResponse response = vnfmDriverMgmr.getOperStatus(vnfmId, "1"); // // Assert.assertEquals("executionId_001", response.getJobId()); } 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 900e7021..aba3d88b 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 @@ -20,6 +20,7 @@ import static org.mockito.Mockito.when; import java.io.IOException; import java.util.HashMap; +import java.util.List; import org.apache.http.client.ClientProtocolException; import org.junit.Before; @@ -28,17 +29,26 @@ 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.CBAMCreateSubscriptionRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateSubscriptionResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMModifyVnfRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMModifyVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryOperExecutionResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfRequest; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMVnfNotificationRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMVnfNotificationResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.Subscription; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VnfcResourceInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv; import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpResult; @@ -61,6 +71,7 @@ public class CbamMgmrImplTest { String json = "{\"access_token\":\"1234567\"}"; HttpResult httpResult = new HttpResult(); + httpResult.setStatusCode(200); httpResult.setContent(json); when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult); @@ -81,6 +92,13 @@ public class CbamMgmrImplTest { } @Test + public void testModifyVnf() throws ClientProtocolException, IOException + { + CBAMModifyVnfRequest cbamRequest = new CBAMModifyVnfRequest(); + CBAMModifyVnfResponse response = cbamMgmr.modifyVnf(cbamRequest, vnfInstanceId); + } + + @Test public void testTerminateVnf() throws ClientProtocolException, IOException { CBAMTerminateVnfRequest cbamRequest = new CBAMTerminateVnfRequest(); @@ -112,4 +130,51 @@ public class CbamMgmrImplTest { { CBAMQueryVnfResponse response = cbamMgmr.queryVnf(vnfInstanceId); } + + @Test + public void testCreateSubscription() throws ClientProtocolException, IOException + { + CBAMCreateSubscriptionRequest cbamRequest = new CBAMCreateSubscriptionRequest(); + CBAMCreateSubscriptionResponse response = cbamMgmr.createSubscription(cbamRequest); + } + + @Test + public void testGetNotification() throws ClientProtocolException, IOException + { + CBAMVnfNotificationRequest cbamRequest = new CBAMVnfNotificationRequest(); + CBAMVnfNotificationResponse response = cbamMgmr.getNotification(cbamRequest); + } + + @Test + public void testGetSubscription() throws ClientProtocolException, IOException + { + String subscriptionId = "subscriptionId_001"; + Subscription response = cbamMgmr.getSubscription(subscriptionId); + } + + @Test + public void testQueryVnfcResource() throws ClientProtocolException, IOException + { + String json = "[{'id':'id_001'}]"; + HttpResult httpResult = new HttpResult(); + httpResult.setStatusCode(200); + httpResult.setContent(json); + + when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult); + List<VnfcResourceInfo> response = cbamMgmr.queryVnfcResource(vnfInstanceId); + } + + @Test + public void testQueryOperExecution() throws ClientProtocolException, IOException + { + String execId = "execId_001"; + CBAMQueryOperExecutionResponse response = cbamMgmr.queryOperExecution(execId); + } + + @Test + public void testUploadVnfPackage() throws ClientProtocolException, IOException + { + String cbamPackageFilePath = "cbamPackageFilePath_001"; + cbamMgmr.uploadVnfPackage(cbamPackageFilePath); + } } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java index aa1a0217..1b9be3b4 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java @@ -52,6 +52,7 @@ public class MsbMgmrImplTest { String json = "{\"serviceName\":\"catalog\", \"url\":\"/api/catalog/v1\"}"; HttpResult httpResult = new HttpResult(); httpResult.setContent(json); + httpResult.setStatusCode(200); when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult); } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/service/MsbServiceRegisterTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/service/MsbServiceRegisterTest.java index 8741bc80..0319735a 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/service/MsbServiceRegisterTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/service/MsbServiceRegisterTest.java @@ -24,6 +24,7 @@ import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.init.MsbServiceRegister; import org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.inf.IMsbMgmr; import org.springframework.boot.ApplicationArguments; |