diff options
author | 2017-10-10 15:06:41 +0800 | |
---|---|---|
committer | 2017-10-10 15:13:08 +0800 | |
commit | 2298a4397584c2c3fff8a5efe34a1ecbd3c91c62 (patch) | |
tree | de35a834d5043b74f82cd248d92d35b6a19522ff /nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test | |
parent | 428b9b17bfe8d7448b731da77e1963daec2ba472 (diff) |
Modify POM parent oparent version as 0.1.1
Change-Id: I1320e0ecea14536e4524e9dff0d41fbbf4411d3c
Issue-ID: VFC-53
Signed-off-by: yufei_zhou <yufei.zhou@nokia-sbell.com>
Diffstat (limited to 'nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test')
6 files changed, 201 insertions, 19 deletions
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImplTest.java index ceeb6fba..3a2ca761 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImplTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImplTest.java @@ -53,6 +53,9 @@ public class AaiMgmrInfImplTest { String json = "{" + "\"vnfm-id\":\"vnfm-id_001\"," + + "\"vim-id\":\"vim-id_001\"," + + "\"certificate-url\":\"certificate-url_001\"," + + "\"resource-version\":\"resource-version_001\"," + "\"esr-system-info-list\":[{\"ip-address\" : \"1.3.5.6\"}]" + "}" + ""; 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 b738fcc5..3948638c 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 @@ -108,11 +108,25 @@ public class VnfmDriverMgmrImplTest { esrSystemInfo.setProtocal(protocol); esrSystemInfo.setIp(ip); esrSystemInfo.setPort(port); + esrSystemInfo.setCloudDomain("cloudDomain"); + esrSystemInfo.setDefaultTenant("defaultTenant"); + esrSystemInfo.setEsrSystemId("esrSystemId"); + esrSystemInfo.setPassword("password"); + esrSystemInfo.setServiceUrl("serviceUrl"); + esrSystemInfo.setSslCacert("sslCacert"); + esrSystemInfo.setSslInsecure("sslInsecure"); + esrSystemInfo.setType("type"); + esrSystemInfo.setUserName("userName"); + esrSystemInfo.setVendor("vendor"); + esrSystemInfo.setVersion("version"); List<EsrSystemInfo> esrSystemInfoList = new ArrayList<EsrSystemInfo>(); esrSystemInfoList.add(esrSystemInfo); AaiVnfmInfo mockVnfmInfo = new AaiVnfmInfo(); mockVnfmInfo.setVnfmId(vnfmId); + mockVnfmInfo.setVimId("vimId"); + mockVnfmInfo.setResourceVersion("resourceVersion"); + mockVnfmInfo.setCertificateUrl("certificateUrl"); mockVnfmInfo.setEsrSystemInfoList(esrSystemInfoList); Driver2CbamRequestConverter reqConverter = new Driver2CbamRequestConverter(); diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImplTest.java index 33ca1761..5667908d 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImplTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImplTest.java @@ -19,7 +19,9 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.impl; import static org.mockito.Mockito.when; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import org.apache.http.client.ClientProtocolException; import org.junit.Assert; @@ -29,12 +31,19 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.bo.CatalogQueryVnfResponse; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.bo.entity.ImageInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.bo.entity.VnfInstanceInfo; 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.CommonEnum.Deletionpending; import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpResult; import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VnfPackageInfo; import org.springframework.web.bind.annotation.RequestMethod; +import com.google.gson.Gson; + public class CatalogMgmrImplTest { @InjectMocks private CatalogMgmrImpl catalogMgmr; @@ -44,29 +53,63 @@ public class CatalogMgmrImplTest { private String vnfPackageId = "vnfPackageId_001"; + private Gson gson = new Gson(); + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); AdaptorEnv env = new AdaptorEnv(); catalogMgmr.setAdaptorEnv(env); MockitoAnnotations.initMocks(this); - - String json = "{" - + "\"csarId\":\"vnfPackageId_001\"," - + "\"packageInfo\":{\"downloadUri\" : \"1.3.5.6\"}" - + "}" - + ""; - HttpResult httpResult = new HttpResult(); - httpResult.setContent(json); - - when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult); } - @Test public void testQueryVnfPackage() throws ClientProtocolException, IOException { - VnfPackageInfo packageInfo = catalogMgmr.queryVnfPackage(vnfPackageId); + CatalogQueryVnfResponse response = new CatalogQueryVnfResponse(); + List<VnfInstanceInfo> vnfInstanceInfos = new ArrayList<VnfInstanceInfo>(); + VnfInstanceInfo vnfInstanceInfo = new VnfInstanceInfo(); + vnfInstanceInfo.setVnfInstanceId("vnfInstanceId"); + vnfInstanceInfo.setVnfInstanceName("vnfInstanceName"); + vnfInstanceInfos.add(vnfInstanceInfo ); + + + response.setVnfInstanceInfo(vnfInstanceInfos); + + response.setCsarId("csarId"); + List<ImageInfo> imageInfos = new ArrayList<ImageInfo>(); + ImageInfo imageInfo = new ImageInfo(); + imageInfo.setFileName("fileName"); + imageInfo.setImageId("imageId"); + imageInfo.setIndex("index"); + imageInfo.setStatus("status"); + imageInfo.setTenant("tenant"); + imageInfo.setVimId("vimId"); + imageInfo.setVimUser("vimUser"); + + imageInfos.add(imageInfo); + response.setImageInfo(imageInfos); + + VnfPackageInfo packageInfo = new VnfPackageInfo(); + packageInfo.setDownloadUri("1.3.5.6"); + packageInfo.setName("name"); + packageInfo.setOnBoardState("onBoardState"); + packageInfo.setVnfdId("vnfdId"); + packageInfo.setVnfdProvider("vnfdProvider"); + packageInfo.setVnfdVersion("vnfdVersion"); + packageInfo.setVnfVersion("vnfVersion"); + Deletionpending deletionPending = CommonEnum.Deletionpending.fALSE; + packageInfo.setDeletionPending(deletionPending ); + + response.setPackageInfo(packageInfo ); + + String json = gson.toJson(packageInfo); + + HttpResult httpResult = new HttpResult(); + httpResult.setContent(json); + + when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult); + VnfPackageInfo packageInfo1 = catalogMgmr.queryVnfPackage(vnfPackageId); Assert.assertEquals("1.3.5.6", packageInfo.getDownloadUri()); } 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 6c7eede1..900e7021 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 @@ -58,7 +58,6 @@ public class CbamMgmrImplTest { MockitoAnnotations.initMocks(this); AdaptorEnv env = new AdaptorEnv(); cbamMgmr.setAdaptorEnv(env); - MockitoAnnotations.initMocks(this); String json = "{\"access_token\":\"1234567\"}"; HttpResult httpResult = new 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 new file mode 100644 index 00000000..8741bc80 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/service/MsbServiceRegisterTest.java @@ -0,0 +1,50 @@ +/* + * 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.msb.service; + +import java.io.IOException; + +import org.apache.http.client.ClientProtocolException; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.inf.IMsbMgmr; +import org.springframework.boot.ApplicationArguments; + +public class MsbServiceRegisterTest { + @InjectMocks + private MsbServiceRegister msbServiceRegister; + + @Mock + private IMsbMgmr msbMgmr; + + @Mock + private ApplicationArguments argments; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + } + + @Test + public void testRegister() throws ClientProtocolException, IOException + { + msbServiceRegister.run(argments); + } +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java index 5a26b2ef..ddff4ca2 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java @@ -19,7 +19,9 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.impl; import static org.mockito.Mockito.when; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import org.apache.http.client.ClientProtocolException; import org.junit.Before; @@ -29,13 +31,25 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.KeyValuePair; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonEnum.LifecycleOperation; import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpResult; 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.NslcmNotifyLCMEventsRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AccessInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVirtualStorage; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.AffectedVnfc; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.InterfaceInfo; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.ResourceDefinition; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VimAssets; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VimInfo; import org.springframework.web.bind.annotation.RequestMethod; +import com.google.gson.Gson; + public class NslcmMgmrImplTest { @InjectMocks private NslcmMgmrImpl nslcmMgmr; @@ -45,31 +59,90 @@ public class NslcmMgmrImplTest { private String vnfInstanceId = "vnfInstanceId_001"; + private Gson gson = new Gson(); + @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); AdaptorEnv env = new AdaptorEnv(); nslcmMgmr.setAdaptorEnv(env); MockitoAnnotations.initMocks(this); - - String json = "{\"access_token\":\"1234567\"}"; - HttpResult httpResult = new HttpResult(); - httpResult.setContent(json); - - when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult); } @Test public void testGrantVnf() throws ClientProtocolException, IOException { + ResourceDefinition resource = new ResourceDefinition(); + resource.setResourceDefinitionId("resourceDefinitionId"); + resource.setVdu("vdu"); + + NslcmGrantVnfResponse gresponse = new NslcmGrantVnfResponse(); + List<KeyValuePair> additionalParam1 = new ArrayList<KeyValuePair>(); + KeyValuePair pair = new KeyValuePair(); + pair.setKey("key"); + pair.setValue("value"); + additionalParam1.add(pair); + + List<ResourceDefinition> additionalParam2 = new ArrayList<ResourceDefinition>(); + additionalParam2.add(resource); + gresponse.setAdditionalParam(additionalParam2); + + VimInfo vim = new VimInfo(); + vim.setInterfaceEndpoint("interfaceEndpoint"); + vim.setVimId("vimId"); + AccessInfo accessInfo = null; + vim.setAccessInfo(accessInfo ); + InterfaceInfo interfaceInfo = null; + vim.setInterfaceInfo(interfaceInfo); + + VimAssets vimAssets = null; + gresponse.setVimAssets(vimAssets); + + gresponse.setVim(vim ); + String json = gson.toJson(gresponse); + HttpResult httpResult = new HttpResult(); + httpResult.setContent(json); + + when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult); + NslcmGrantVnfRequest cbamRequest = new NslcmGrantVnfRequest(); + List<KeyValuePair> additionalParam = new ArrayList<KeyValuePair>(); + pair = new KeyValuePair(); + pair.setKey("key"); + pair.setValue("value"); + additionalParam.add(pair); + cbamRequest.setAdditionalParam(additionalParam); + + + List<ResourceDefinition> addResource = new ArrayList<ResourceDefinition>(); + addResource.add(resource); + + cbamRequest.setAddResource(addResource); + cbamRequest.setVnfInstanceId("vnfInstanceId"); + cbamRequest.setJobId("jobId"); + LifecycleOperation lifecycleOperation = CommonEnum.LifecycleOperation.Instantiate; + cbamRequest.setLifecycleOperation(lifecycleOperation); + cbamRequest.setRemoveResource(addResource); + NslcmGrantVnfResponse response = nslcmMgmr.grantVnf(cbamRequest); } @Test public void testNotifyVnf() throws ClientProtocolException, IOException { + String json = "{}"; + HttpResult httpResult = new HttpResult(); + httpResult.setContent(json); + + when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult); NslcmNotifyLCMEventsRequest cbamRequest = new NslcmNotifyLCMEventsRequest(); + cbamRequest.setJobId("jobId"); + cbamRequest.setOperation("operation"); + cbamRequest.setVnfInstanceId(vnfInstanceId); + AffectedVirtualStorage affectedVirtualStorage = new AffectedVirtualStorage(); + cbamRequest.setAffectedVirtualStorage(affectedVirtualStorage ); + AffectedVnfc affectedVnfc = new AffectedVnfc(); + cbamRequest.setAffectedVnfc(affectedVnfc ); nslcmMgmr.notifyVnf(cbamRequest, vnfInstanceId); } } |