From d6d11f0b1bfda4dc337bd208b86b0fb49d35d82e Mon Sep 17 00:00:00 2001 From: yufei_zhou Date: Fri, 30 Mar 2018 10:18:30 +0800 Subject: Add unit test cases Change-Id: I2948ad38b50c47203b46160d1370f2dc74dab18f Issue-ID: VFC-724 Signed-off-by: yufei_zhou --- .../driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java | 7 +- .../nfvo/driver/vnfm/svnfm/aai/inf/AaiMgmrInf.java | 2 +- .../adaptor/Cbam2DriverResponseConverter.java | 16 ++- .../svnfm/adaptor/ScaleVnfContinueRunnable.java | 14 +- .../vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java | 7 +- .../vnfm/svnfm/catalog/impl/CatalogMgmrImpl.java | 4 +- .../vnfm/svnfm/catalog/inf/CatalogMgmrInf.java | 3 +- .../cbam/bo/CBAMCreateSubscriptionRequest.java | 29 +--- .../cbam/bo/CBAMCreateSubscriptionResponse.java | 34 ++--- .../vnfm/svnfm/cbam/bo/SubscriptionRequest.java | 48 +++++++ .../vnfm/svnfm/cbam/bo/entity/Subscription.java | 78 ----------- .../svnfm/cbam/bo/entity/SubscriptionResponse.java | 56 ++++++++ .../driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java | 12 +- .../vnfm/svnfm/cbam/impl/MultipartUtility.java | 15 +-- .../driver/vnfm/svnfm/cbam/inf/CbamMgmrInf.java | 4 +- .../vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java | 9 +- .../driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java | 4 +- .../vnfmdriver/bo/CreateSubscriptionRequest.java | 6 +- .../vnfmdriver/bo/CreateSubscriptionResponse.java | 4 +- .../vnfm/svnfm/vnfmdriver/bo/ScaleVnfRequest.java | 2 +- .../controller/VnfmDriverController.java | 58 ++++---- .../adaptor/Cbam2DriverResponseConverterTest.java | 150 +++++++++++++++++++++ .../adaptor/ScaleVnfContinueRunnableTest.java | 2 - .../vnfm/svnfm/cbam/impl/CbamMgmrImplTest.java | 6 +- .../controller/VnfmDriverControllerTest.java | 4 +- 25 files changed, 359 insertions(+), 215 deletions(-) create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/SubscriptionRequest.java delete mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/Subscription.java create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/SubscriptionResponse.java create mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverterTest.java (limited to 'nokia/vnfmdriver') diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java index ddc78ebe..748680aa 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.util.HashMap; import org.apache.commons.codec.binary.Base64; -import org.apache.http.client.ClientProtocolException; import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.AaiVnfmInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.inf.AaiMgmrInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv; @@ -46,7 +45,7 @@ public class AaiMgmrInfImpl implements AaiMgmrInf{ private Gson gson = new Gson(); @Override - public AaiVnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException { + public AaiVnfmInfo queryVnfm(String vnfmId) throws IOException { String httpPath = String.format(CommonConstants.RetrieveVnfmListPath, vnfmId); RequestMethod method = RequestMethod.GET; @@ -59,7 +58,7 @@ public class AaiMgmrInfImpl implements AaiMgmrInf{ return response; } - private String operateHttpTask(Object httpBodyObj, String httpPath, RequestMethod method) throws ClientProtocolException, IOException { + private String operateHttpTask(Object httpBodyObj, String httpPath, RequestMethod method) throws IOException { String url=adaptorEnv.getAaiApiUriFront() + httpPath; HashMap headerMap = new HashMap<>(); @@ -72,7 +71,6 @@ public class AaiMgmrInfImpl implements AaiMgmrInf{ String authen = new String(token.encode(("AAI:AAI").getBytes())); headerMap.put("Authorization", "Basic " + authen); logger.info("getVimById headerMap: {}", headerMap.toString()); - String responseStr = httpClientProcessor.process(url, method, headerMap, gson.toJson(httpBodyObj)).getContent(); @@ -82,5 +80,4 @@ public class AaiMgmrInfImpl implements AaiMgmrInf{ public void setAdaptorEnv(AdaptorEnv env) { this.adaptorEnv = env; } - } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/inf/AaiMgmrInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/inf/AaiMgmrInf.java index c81496dc..1dd1e4be 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/inf/AaiMgmrInf.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/inf/AaiMgmrInf.java @@ -22,5 +22,5 @@ import org.apache.http.client.ClientProtocolException; import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.AaiVnfmInfo; public interface AaiMgmrInf { - public AaiVnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException; + public AaiVnfmInfo queryVnfm(String vnfmId) throws IOException; } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java index 50339e4c..889ea0a3 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/Cbam2DriverResponseConverter.java @@ -67,7 +67,7 @@ public class Cbam2DriverResponseConverter { jobInfo.setStatus(CommonConstants.CBAM_OPERATION_STATUS_START); jobDbManager.insert(jobInfo); - VnfmJobExecutionInfo jobInfo1 = (VnfmJobExecutionInfo) jobDbManager.findNewestJobInfo(); + VnfmJobExecutionInfo jobInfo1 = jobDbManager.findNewestJobInfo(); Long jobId = jobInfo1.getJobId(); TerminateVnfResponse response = new TerminateVnfResponse(); response.setJobId(jobId.longValue() + ""); @@ -126,8 +126,17 @@ public class Cbam2DriverResponseConverter { } public HealVnfResponse healRspConvert(CBAMHealVnfResponse cbamResponse) { + VnfmJobExecutionInfo jobInfo = new VnfmJobExecutionInfo(); + jobInfo.setVnfInstanceId(cbamResponse.getId()); + jobInfo.setStatus(CommonConstants.CBAM_OPERATION_STATUS_START); + jobInfo.setVnfmInterfceName(CommonConstants.NSLCM_OPERATION_HEAL); + + jobDbManager.insert(jobInfo); + VnfmJobExecutionInfo jobInfo1 = jobDbManager.findNewestJobInfo(); + Long jobId = jobInfo1.getJobId(); + HealVnfResponse response = new HealVnfResponse(); - response.setJobId("1"); + response.setJobId(jobId.longValue() + ""); return response; } @@ -142,7 +151,7 @@ public class Cbam2DriverResponseConverter { jobInfo.setStatus(CommonConstants.CBAM_OPERATION_STATUS_START); jobDbManager.insert(jobInfo); - VnfmJobExecutionInfo jobInfo1 = (VnfmJobExecutionInfo) jobDbManager.findNewestJobInfo(); + VnfmJobExecutionInfo jobInfo1 = jobDbManager.findNewestJobInfo(); Long jobId = jobInfo1.getJobId(); ScaleVnfResponse response = new ScaleVnfResponse(); @@ -180,7 +189,6 @@ public class Cbam2DriverResponseConverter { response.set_links(cbamResponse.get_links()); response.setId(cbamResponse.getId()); response.setCallbackUri(cbamResponse.getCallbackUrl()); - response.setCallbackUrl(cbamResponse.getCallbackUrl()); response.setFilter(cbamResponse.getFilter()); return response; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/ScaleVnfContinueRunnable.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/ScaleVnfContinueRunnable.java index 1f6caf83..1606d533 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/ScaleVnfContinueRunnable.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/ScaleVnfContinueRunnable.java @@ -48,8 +48,7 @@ public class ScaleVnfContinueRunnable implements Runnable { private ScaleVnfRequest driverRequest; private String vnfInstanceId; private String jobId; - private String vnfmId; - private ScaleType type; + @Autowired private VnfmJobExecutionMapper jobDbMgmr; @@ -65,7 +64,6 @@ public class ScaleVnfContinueRunnable implements Runnable { this.requestConverter = requestConverter; this.jobId = jobId; this.jobDbMgmr = dbManager; - this.vnfmId = vnfmId; } private void handleGrant(){ @@ -114,7 +112,7 @@ public class ScaleVnfContinueRunnable implements Runnable { NslcmGrantVnfRequest request = new NslcmGrantVnfRequest(); request.setVnfInstanceId(vnfInstanceId); - if(type.equals(ScaleType.SCALE_OUT)) { + if(ScaleType.SCALE_OUT == driverRequest.getType()) { request.setLifecycleOperation(LifecycleOperation.Scaleout); }else { request.setLifecycleOperation(LifecycleOperation.Scalein); @@ -155,14 +153,6 @@ public class ScaleVnfContinueRunnable implements Runnable { this.jobId = jobId; } - public void setVnfmId(String vnfmId) { - this.vnfmId = vnfmId; - } - - public void setType(ScaleType type) { - this.type = type; - } - public void setRequestConverter(Driver2CbamRequestConverter requestConverter) { this.requestConverter = requestConverter; } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java index 69d36efe..028f6152 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java @@ -24,6 +24,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.AaiVnfmInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.entity.EsrSystemInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.inf.AaiMgmrInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf; +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; @@ -356,7 +357,11 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf { public CreateSubscriptionResponse createSubscription(CreateSubscriptionRequest request) throws VnfmDriverException { CreateSubscriptionResponse driverResponse; try { - CBAMCreateSubscriptionResponse cbamResponse = cbamMgmr.createSubscription(request); + CBAMCreateSubscriptionRequest cbamRequest = new CBAMCreateSubscriptionRequest(); + cbamRequest.setCallbackUrl(request.getCallbackUri()); + cbamRequest.setAuthentication(request.getAuthentication()); + cbamRequest.setFilter(request.getFilter()); + CBAMCreateSubscriptionResponse cbamResponse = cbamMgmr.createSubscription(cbamRequest); driverResponse = responseConverter.queryRspConvert(cbamResponse); subscriptionsMapper.insert(cbamResponse.getId()); } catch (Exception e) { diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImpl.java index feebf5c0..c522cb2b 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImpl.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImpl.java @@ -18,7 +18,6 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.impl; import java.io.IOException; -import org.apache.http.client.ClientProtocolException; import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.bo.CatalogQueryVnfResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.bo.entity.VnfPackageInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf; @@ -29,7 +28,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.RequestMethod; import com.google.gson.Gson; @@ -45,7 +43,7 @@ public class CatalogMgmrImpl implements CatalogMgmrInf{ @Autowired HttpClientProcessorInf httpClientProcessor; - public VnfPackageInfo queryVnfPackage(String vnfPackageId) throws ClientProtocolException, IOException { + public VnfPackageInfo queryVnfPackage(String vnfPackageId) throws IOException { String url=adaptorEnv.getCatalogApiUriFront() + String.format(CommonConstants.RetrieveVnfPackagePath, vnfPackageId); diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/inf/CatalogMgmrInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/inf/CatalogMgmrInf.java index 72ce572e..028375ee 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/inf/CatalogMgmrInf.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/inf/CatalogMgmrInf.java @@ -18,10 +18,9 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf; import java.io.IOException; -import org.apache.http.client.ClientProtocolException; import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.bo.entity.VnfPackageInfo; public interface CatalogMgmrInf { - public VnfPackageInfo queryVnfPackage(String vnfPackageId) throws ClientProtocolException, IOException; + public VnfPackageInfo queryVnfPackage(String vnfPackageId) throws IOException; } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/CBAMCreateSubscriptionRequest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/CBAMCreateSubscriptionRequest.java index e0069771..563ce6a2 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/CBAMCreateSubscriptionRequest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/CBAMCreateSubscriptionRequest.java @@ -16,29 +16,12 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.SubscriptionAuthentication; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.SubscriptionFilter; - import com.fasterxml.jackson.annotation.JsonProperty; -public class CBAMCreateSubscriptionRequest { - @JsonProperty("filter") - private SubscriptionFilter filter; - +public class CBAMCreateSubscriptionRequest extends SubscriptionRequest{ @JsonProperty("callbackUrl") private String callbackUrl; - @JsonProperty("authentication") - private SubscriptionAuthentication authentication; - - public SubscriptionFilter getFilter() { - return filter; - } - - public void setFilter(SubscriptionFilter filter) { - this.filter = filter; - } - public String getCallbackUrl() { return callbackUrl; } @@ -46,14 +29,4 @@ public class CBAMCreateSubscriptionRequest { public void setCallbackUrl(String callbackUrl) { this.callbackUrl = callbackUrl; } - - public SubscriptionAuthentication getAuthentication() { - return authentication; - } - - public void setAuthentication(SubscriptionAuthentication authentication) { - this.authentication = authentication; - } - - } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/CBAMCreateSubscriptionResponse.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/CBAMCreateSubscriptionResponse.java index 78cd9ce0..6bcc469f 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/CBAMCreateSubscriptionResponse.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/CBAMCreateSubscriptionResponse.java @@ -16,26 +16,30 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.Subscription; - -public class CBAMCreateSubscriptionResponse extends Subscription{ -/* - - @JsonProperty("problemDetails") - private ProblemDetails problemDetails; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.SubscriptionResponse; +import com.fasterxml.jackson.annotation.JsonProperty; - public ProblemDetails getProblemDetails() { - return problemDetails; +public class CBAMCreateSubscriptionResponse extends SubscriptionResponse{ + @JsonProperty("lcnApiVersion") + private String lcnApiVersion; + + @JsonProperty("callbackUrl") + private String callbackUrl; + + public String getLcnApiVersion() { + return lcnApiVersion; } - public void setProblemDetails(ProblemDetails problemDetails) { - this.problemDetails = problemDetails; + public void setLcnApiVersion(String lcnApiVersion) { + this.lcnApiVersion = lcnApiVersion; } -*/ - + public String getCallbackUrl() { + return callbackUrl; + } - - + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/SubscriptionRequest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/SubscriptionRequest.java new file mode 100644 index 00000000..84639922 --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/SubscriptionRequest.java @@ -0,0 +1,48 @@ +/* + * 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.cbam.bo; + +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.SubscriptionAuthentication; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.SubscriptionFilter; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class SubscriptionRequest { + @JsonProperty("filter") + private SubscriptionFilter filter; + + @JsonProperty("authentication") + private SubscriptionAuthentication authentication; + + public SubscriptionFilter getFilter() { + return filter; + } + + public void setFilter(SubscriptionFilter filter) { + this.filter = filter; + } + + public SubscriptionAuthentication getAuthentication() { + return authentication; + } + + public void setAuthentication(SubscriptionAuthentication authentication) { + this.authentication = authentication; + } + + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/Subscription.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/Subscription.java deleted file mode 100644 index 1345d72f..00000000 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/Subscription.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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.cbam.bo.entity; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class Subscription { - @JsonProperty("id") - private String id; - - @JsonProperty("lcnApiVersion") - private String lcnApiVersion; - - @JsonProperty("filter") - private SubscriptionFilter filter; - - @JsonProperty("callbackUrl") - private String callbackUrl; - - @JsonProperty("_links") - private _links _links; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getLcnApiVersion() { - return lcnApiVersion; - } - - public void setLcnApiVersion(String lcnApiVersion) { - this.lcnApiVersion = lcnApiVersion; - } - - public SubscriptionFilter getFilter() { - return filter; - } - - public void setFilter(SubscriptionFilter filter) { - this.filter = filter; - } - - public String getCallbackUrl() { - return callbackUrl; - } - - public void setCallbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - } - - public _links get_links() { - return _links; - } - - public void set_links(_links _links) { - this._links = _links; - } - - - -} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/SubscriptionResponse.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/SubscriptionResponse.java new file mode 100644 index 00000000..bc89147f --- /dev/null +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/bo/entity/SubscriptionResponse.java @@ -0,0 +1,56 @@ +/* + * 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.cbam.bo.entity; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class SubscriptionResponse { + @JsonProperty("id") + private String id; + + @JsonProperty("filter") + private SubscriptionFilter filter; + + @JsonProperty("_links") + private _links _links; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public SubscriptionFilter getFilter() { + return filter; + } + + public void setFilter(SubscriptionFilter filter) { + this.filter = filter; + } + + public _links get_links() { + return _links; + } + + public void set_links(_links _links) { + this._links = _links; + } + + + +} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java index 3f3ae57b..4af38475 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java @@ -44,7 +44,7 @@ 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.SubscriptionResponse; 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.common.bo.AdaptorEnv; @@ -208,7 +208,7 @@ public class CbamMgmrImpl implements CbamMgmrInf { if (code == 202) { logger.info("CbamMgmrImpl -> scaleVnf success."); } else { - logger.error("CbamMgmrImpl -> scaleVnf error. "); + logger.error("CbamMgmrImpl -> scaleVnf error. detail info is " + httpResult.getContent()); } CBAMScaleVnfResponse response = gson.fromJson(responseStr, CBAMScaleVnfResponse.class); @@ -228,7 +228,7 @@ public class CbamMgmrImpl implements CbamMgmrInf { if (code == 202) { logger.info("CbamMgmrImpl -> healVnf success."); } else { - logger.error("CbamMgmrImpl -> healVnf error. "); + logger.error("CbamMgmrImpl -> healVnf error. " + httpResult.getContent()); } CBAMHealVnfResponse response = gson.fromJson(responseStr, CBAMHealVnfResponse.class); @@ -247,7 +247,7 @@ public class CbamMgmrImpl implements CbamMgmrInf { if (code == 200) { logger.info("CbamMgmrImpl -> queryVnf success."); } else { - logger.error("CbamMgmrImpl -> queryVnf error. "); + logger.error("CbamMgmrImpl -> queryVnf error. " + httpResult.getContent()); } CBAMQueryVnfResponse response = gson.fromJson(responseStr, CBAMQueryVnfResponse.class); @@ -490,7 +490,7 @@ public class CbamMgmrImpl implements CbamMgmrInf { } @Override - public Subscription getSubscription(String subscriptionId) throws ClientProtocolException, IOException { + public SubscriptionResponse getSubscription(String subscriptionId) throws ClientProtocolException, IOException { String httpPath = String.format(CommonConstants.CbamGetSubscriptionPath, subscriptionId); RequestMethod method = RequestMethod.GET; @@ -504,7 +504,7 @@ public class CbamMgmrImpl implements CbamMgmrInf { } else { logger.error("CbamMgmrImpl -> getSubscription error , statusCode = " + code); } - Subscription response = gson.fromJson(responseStr, Subscription.class); + SubscriptionResponse response = gson.fromJson(responseStr, SubscriptionResponse.class); return response; } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java index 834c2a7b..ee294cdd 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/MultipartUtility.java @@ -159,23 +159,23 @@ public class MultipartUtility { KeyManager[] kms = null; try { String CERT_STORE = "/etc/conf/server.p12"; - String CERT_STORE_PASSWORD = "Changeme_123"; + String CERT_STORE_CRED = "Changeme_123"; String KEY_STORE_TYPE = "PKCS12"; if(sslConf != null) { CERT_STORE = sslConf.getKeyStore(); - CERT_STORE_PASSWORD = sslConf.getKeyStorePass(); + CERT_STORE_CRED= sslConf.getKeyStorePass(); KEY_STORE_TYPE = sslConf.getKeyStoreType(); } // load jks file try(FileInputStream f_certStore = new FileInputStream(CommonUtil.getAppRoot() + CERT_STORE)){ KeyStore ks = KeyStore.getInstance(KEY_STORE_TYPE); - ks.load(f_certStore, CERT_STORE_PASSWORD.toCharArray()); + ks.load(f_certStore, CERT_STORE_CRED.toCharArray()); // init and create String alg = KeyManagerFactory.getDefaultAlgorithm(); KeyManagerFactory kmFact = KeyManagerFactory.getInstance(alg); - kmFact.init(ks, CERT_STORE_PASSWORD.toCharArray()); + kmFact.init(ks, CERT_STORE_CRED.toCharArray()); kms = kmFact.getKeyManagers(); } @@ -190,18 +190,18 @@ public class MultipartUtility { try { String TRUST_STORE = "/etc/conf/trust.jks"; - String TRUST_STORE_PASSWORD = "Changeme_123"; + String TRUST_STORE_CRED = "Changeme_123"; String TRUST_STORE_TYPE = "jks"; if(sslConf != null) { TRUST_STORE = sslConf.getTrustStore(); - TRUST_STORE_PASSWORD = sslConf.getTrustStorePass(); + TRUST_STORE_CRED = sslConf.getTrustStorePass(); TRUST_STORE_TYPE = sslConf.getTrustStoreType(); } String jksFilePath1 =CommonUtil.getAppRoot() + TRUST_STORE; logger.info("jks path is " + jksFilePath1); try(FileInputStream f_trustStore = new FileInputStream(jksFilePath1)){ KeyStore ks = KeyStore.getInstance(TRUST_STORE_TYPE); - ks.load(f_trustStore, TRUST_STORE_PASSWORD.toCharArray()); + ks.load(f_trustStore, TRUST_STORE_CRED.toCharArray()); String alg = TrustManagerFactory.getDefaultAlgorithm(); @@ -216,7 +216,6 @@ public class MultipartUtility { return tms; } - /** * Adds a upload file section to the request * @param fieldName name attribute in diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/inf/CbamMgmrInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/inf/CbamMgmrInf.java index cb62689d..6252d10b 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/inf/CbamMgmrInf.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/inf/CbamMgmrInf.java @@ -38,7 +38,7 @@ 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.SubscriptionResponse; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.entity.VnfcResourceInfo; public interface CbamMgmrInf { @@ -51,7 +51,7 @@ public interface CbamMgmrInf { throws ClientProtocolException, IOException; public CBAMCreateSubscriptionResponse createSubscription(CBAMCreateSubscriptionRequest subscriptionRequest) throws ClientProtocolException, IOException; - public Subscription getSubscription(String subscriptionId) + public SubscriptionResponse getSubscription(String subscriptionId) throws ClientProtocolException, IOException; public CBAMVnfNotificationResponse getNotification(CBAMVnfNotificationRequest getNotificationRequest) throws ClientProtocolException, IOException; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java index 13ee87d0..aded710f 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java @@ -19,7 +19,6 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.impl; import java.io.IOException; import java.util.HashMap; -import org.apache.http.client.ClientProtocolException; import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv; import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants; import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf; @@ -49,7 +48,7 @@ public class NslcmMgmrImpl implements NslcmMgmrInf{ private Gson gson = new Gson(); // @Deprecated -// public VnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException +// public VnfmInfo queryVnfm(String vnfmId) throws IOException // { // String httpPath = String.format(CommonConstants.RetrieveVnfmListPath, vnfmId); // RequestMethod method = RequestMethod.GET; @@ -63,7 +62,7 @@ public class NslcmMgmrImpl implements NslcmMgmrInf{ // return response; // } - public NslcmGrantVnfResponse grantVnf(NslcmGrantVnfRequest driverRequest) throws ClientProtocolException, IOException { + public NslcmGrantVnfResponse grantVnf(NslcmGrantVnfRequest driverRequest) throws IOException { String httpPath = CommonConstants.NslcmGrantPath; RequestMethod method = RequestMethod.POST; @@ -76,14 +75,14 @@ public class NslcmMgmrImpl implements NslcmMgmrInf{ return response; } - public void notifyVnf(NslcmNotifyLCMEventsRequest driverRequest, String vnfmId, String vnfInstanceId) throws ClientProtocolException, IOException { + public void notifyVnf(NslcmNotifyLCMEventsRequest driverRequest, String vnfmId, String vnfInstanceId) throws IOException { String httpPath = String.format(CommonConstants.NslcmNotifyPath, vnfmId, vnfInstanceId); RequestMethod method = RequestMethod.POST; operateNslcmHttpTask(driverRequest, httpPath, method); } - private String operateNslcmHttpTask(Object httpBodyObj, String httpPath, RequestMethod method) throws ClientProtocolException, IOException { + private String operateNslcmHttpTask(Object httpBodyObj, String httpPath, RequestMethod method) throws IOException { String url=adaptorEnv.getLcmApiUriFront() + httpPath; HashMap map = new HashMap<>(); diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java index c1df7acb..5290e166 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/inf/NslcmMgmrInf.java @@ -26,7 +26,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.NslcmNotifyLCMEventsRequest; public interface NslcmMgmrInf { // public VnfmInfo queryVnfm(String vnfmId) throws ClientProtocolException, IOException; - public NslcmGrantVnfResponse grantVnf(NslcmGrantVnfRequest driverRequest) throws ClientProtocolException, IOException; + public NslcmGrantVnfResponse grantVnf(NslcmGrantVnfRequest driverRequest) throws IOException; - public void notifyVnf(NslcmNotifyLCMEventsRequest driverRequest, String vnfmId, String vnfInstanceId) throws ClientProtocolException, IOException; + public void notifyVnf(NslcmNotifyLCMEventsRequest driverRequest, String vnfmId, String vnfInstanceId) throws IOException; } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/CreateSubscriptionRequest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/CreateSubscriptionRequest.java index 2834cd2c..fe09bc29 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/CreateSubscriptionRequest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/CreateSubscriptionRequest.java @@ -16,14 +16,12 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateSubscriptionRequest; +import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.SubscriptionRequest; import com.fasterxml.jackson.annotation.JsonProperty; -public class CreateSubscriptionRequest extends CBAMCreateSubscriptionRequest{ +public class CreateSubscriptionRequest extends SubscriptionRequest{ - - //the attribute callbackUri is for SOL003 driver, while callbackUrl is for CBAM @JsonProperty("callbackUri") private String callbackUri; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/CreateSubscriptionResponse.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/CreateSubscriptionResponse.java index 0f6f563a..d8c687f3 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/CreateSubscriptionResponse.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/CreateSubscriptionResponse.java @@ -15,11 +15,11 @@ */ package org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.bo; -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 com.fasterxml.jackson.annotation.JsonProperty; -public class CreateSubscriptionResponse extends Subscription{ +public class CreateSubscriptionResponse extends SubscriptionResponse{ //the attribute callbackUri is for SOL003 driver, while callbackUrl is for CBAM @JsonProperty("callbackUri") private String callbackUri; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/ScaleVnfRequest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/ScaleVnfRequest.java index 13bf9bc3..1a967543 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/ScaleVnfRequest.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/bo/ScaleVnfRequest.java @@ -35,7 +35,7 @@ public class ScaleVnfRequest { @JsonProperty("numberOfSteps") private Integer numberOfSteps; - @JsonProperty("additionalParam") + @JsonProperty("additionalParams") private AdditionalParam additionalParam; diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverController.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverController.java index cb429149..99c06b2c 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverController.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/vnfmdriver/controller/VnfmDriverController.java @@ -18,6 +18,7 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.controller; import java.io.IOException; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.io.IOUtils; @@ -196,30 +197,30 @@ public class VnfmDriverController { return null; } -//// @RequestMapping(value = "/notifications", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) -//// public CBAMVnfNotificationResponse notificationVnf(@RequestBody CBAMVnfNotificationRequest request, HttpServletResponse httpResponse) throws ClientProtocolException, Exception -// @RequestMapping(value = "/notifications") -//// @ResponseBody -// public void notificationVnf(HttpServletRequest request, HttpServletResponse httpResponse) throws ClientProtocolException, Exception -// { -// -//// String jsonString = gson.toJson(request); -//// logger.info("notificationVnf request: bodyMessage is " + jsonString); -// logger.info("notificationVnf request: bodyMessage is " + request.getMethod() + ","); -// -// try { -//// CBAMVnfNotificationResponse response = cbamMgmr.getNotification(request); -// httpResponse.setStatus(204); -//// logger.info("cbamController --> notificationVnf response is " + gson.toJson(response)); -//// return response; -// } -// catch(VnfmDriverException e) -// { -// processControllerException(httpResponse, e); -// } -// -//// return null; -// } +// @RequestMapping(value = "/notifications", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) +// public CBAMVnfNotificationResponse notificationVnf(@RequestBody CBAMVnfNotificationRequest request, HttpServletResponse httpResponse) throws ClientProtocolException, Exception + @RequestMapping(value = "/notifications") +// @ResponseBody + public void notificationVnf(HttpServletRequest request, HttpServletResponse httpResponse) + { + +// String jsonString = gson.toJson(request); +// logger.info("notificationVnf request: bodyMessage is " + jsonString); + logger.info("notificationVnf request: bodyMessage is " + request.getMethod() + ","); + + try { +// CBAMVnfNotificationResponse response = cbamMgmr.getNotification(request); + httpResponse.setStatus(204); +// logger.info("cbamController --> notificationVnf response is " + gson.toJson(response)); +// return response; + } + catch(VnfmDriverException e) + { + processControllerException(httpResponse, e); + } + +// return null; + } private void processControllerException(HttpServletResponse httpResponse, VnfmDriverException e) { try { @@ -233,18 +234,17 @@ public class VnfmDriverController { // -- The following VNFM Driver APIs are compliant to ETSI SOL003 -- Begin - @RequestMapping(value = "/createSubscripiton", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) + @RequestMapping(value = "/createSubscription", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @ResponseBody - public CreateSubscriptionResponse createSubscripiton(@RequestBody CreateSubscriptionRequest request, HttpServletResponse httpResponse) + public CreateSubscriptionResponse createSubscription(@RequestBody CreateSubscriptionRequest request, HttpServletResponse httpResponse) { String jsonString = gson.toJson(request); - logger.info("VnfmDriverController --> createSubscripiton, bodyMessage is " + jsonString); + logger.info("VnfmDriverController --> createSubscription, bodyMessage is " + jsonString); try { - request.setCallbackUrl(request.getCallbackUri()); CreateSubscriptionResponse response = vnfmDriverMgmr.createSubscription(request); httpResponse.setStatus(HttpStatus.SC_CREATED); - logger.info("VnfmDriverController --> createSubscripiton end "); + logger.info("VnfmDriverController --> createSubscription end "); return response; } catch(VnfmDriverException e) 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). -- cgit 1.2.3-korg