From 6f37b2926e216487b44d7b25cdae7a9bbfd8160d Mon Sep 17 00:00:00 2001 From: yufei_zhou Date: Mon, 2 Apr 2018 16:28:04 +0800 Subject: Fix nexus-iq commons-httpclient issues Change-Id: I96c6140accfb8a1c35f08eb9ac66a4a8ff27e88f Issue-ID: VFC-863 Signed-off-by: yufei_zhou --- .../vfcadaptorservice/vfcadaptor/pom.xml | 150 ++------------------- .../vnfm/svnfm/adaptor/VnfmDriverMgmrImpl.java | 7 +- .../vnfm/svnfm/db/bean/VnfmResourceInfo.java | 88 ------------ .../vnfm/svnfm/db/bean/VnfmSubscriptionInfo.java | 24 +++- .../svnfm/db/mapper/VnfmSubscriptionsMapper.java | 14 +- .../db/repository/VnfmJobExecutionRepository.java | 21 --- .../db/repository/VnfmResourceRepository.java | 21 --- .../db/repository/VnfmSubscriptionsRepository.java | 24 ---- .../vnfm/svnfm/http/client/HttpClientUtils.java | 2 +- .../controller/VnfmDriverController.java | 35 ++--- .../vnfm/svnfm/adaptor/VnfmDriverMgmrImplTest.java | 3 +- .../controller/VnfmDriverControllerTest.java | 27 ++++ 12 files changed, 97 insertions(+), 319 deletions(-) delete mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmResourceInfo.java delete mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/repository/VnfmJobExecutionRepository.java delete mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/repository/VnfmResourceRepository.java delete mode 100644 nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/repository/VnfmSubscriptionsRepository.java (limited to 'nokia/vnfmdriver/vfcadaptorservice') diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml index 52ebd0e5..283a2cc3 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/pom.xml @@ -41,12 +41,7 @@ - + org.springframework.boot spring-boot-starter-web @@ -54,47 +49,13 @@ org.springframework.boot spring-boot-starter - + org.springframework.boot spring-boot-starter-logging - + org.mariadb.jdbc @@ -118,11 +79,7 @@ httpclient 4.5.5 - - commons-httpclient - commons-httpclient - 3.1 - + com.google.code.gson gson @@ -161,68 +118,18 @@ mybatis-spring-boot-starter 1.3.2 + + + com.alibaba + dubbo + 2.6.1 + - - ca.juliusdavies - not-yet-commons-ssl - 0.3.11 - - + - + org.springframework.boot spring-boot-maven-plugin @@ -242,38 +149,7 @@ maven-surefire-plugin 2.21.0 - - + 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 028f6152..e2e349d9 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 @@ -37,6 +37,7 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants; 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.bean.VnfmSubscriptionInfo; 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.db.mapper.VnfmSubscriptionsMapper; @@ -363,7 +364,11 @@ public class VnfmDriverMgmrImpl implements VnfmDriverMgmrInf { cbamRequest.setFilter(request.getFilter()); CBAMCreateSubscriptionResponse cbamResponse = cbamMgmr.createSubscription(cbamRequest); driverResponse = responseConverter.queryRspConvert(cbamResponse); - subscriptionsMapper.insert(cbamResponse.getId()); + VnfmSubscriptionInfo subscriptionInfo = new VnfmSubscriptionInfo(); + subscriptionInfo.setId(cbamResponse.getId()); + subscriptionInfo.setDriverCallbackUrl(cbamResponse.getId()); + subscriptionInfo.setNslcmCallbackUrl(request.getCallbackUri()); + subscriptionsMapper.insert(subscriptionInfo); } catch (Exception e) { logger.error("error VnfmDriverMgmrImpl --> createSubscripiton. ", e); throw new VnfmDriverException(HttpStatus.SC_INTERNAL_SERVER_ERROR, CommonConstants.HTTP_ERROR_DESC_500); diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmResourceInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmResourceInfo.java deleted file mode 100644 index c40fe91d..00000000 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmResourceInfo.java +++ /dev/null @@ -1,88 +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.db.bean; - -import java.io.Serializable; - -//import javax.persistence.Column; -//import javax.persistence.Entity; -//import javax.persistence.GeneratedValue; -//import javax.persistence.GenerationType; -//import javax.persistence.Id; -//import javax.persistence.Table; - -//@Entity -//@Table(name="vnfm_resource_info") -public class VnfmResourceInfo implements Serializable { - private static final long serialVersionUID = -288015953900428312L; -// @Id -// @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - -// @Column(name = "type") - private ResourceType type; - -// @Column(name = "resource_definition_id") - private String resourceDefinitionId; - -// @Column(name = "vdu") - private String vdu; - -// @Column(name = "status") - private String status; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public ResourceType getType() { - return type; - } - - public void setType(ResourceType type) { - this.type = type; - } - - public String getResourceDefinitionId() { - return resourceDefinitionId; - } - - public void setResourceDefinitionId(String resourceDefinitionId) { - this.resourceDefinitionId = resourceDefinitionId; - } - - public String getVdu() { - return vdu; - } - - public void setVdu(String vdu) { - this.vdu = vdu; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - -} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmSubscriptionInfo.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmSubscriptionInfo.java index b517657d..f2753115 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmSubscriptionInfo.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/bean/VnfmSubscriptionInfo.java @@ -33,6 +33,10 @@ public class VnfmSubscriptionInfo implements Serializable { // @Id // @Column(name = "id") private String id; + + private String driverCallbackUrl; + + private String nslcmCallbackUrl; public static long getSerialversionuid() { return serialVersionUID; @@ -46,10 +50,24 @@ public class VnfmSubscriptionInfo implements Serializable { this.id = id; } - @Override - public String toString() { - return " VnfmSubscriptionInfo: [ " + super.toString() + ", id = " + id + "]"; + public String getDriverCallbackUrl() { + return driverCallbackUrl; + } + + public void setDriverCallbackUrl(String driverCallbackUrl) { + this.driverCallbackUrl = driverCallbackUrl; + } + public String getNslcmCallbackUrl() { + return nslcmCallbackUrl; } + public void setNslcmCallbackUrl(String nslcmCallbackUrl) { + this.nslcmCallbackUrl = nslcmCallbackUrl; + } + + @Override + public String toString() { + return " VnfmSubscriptionInfo: [ " + super.toString() + ", id = " + id + ", driverCallbackUrl = " + driverCallbackUrl +", nslcmCallbackUrl = " + nslcmCallbackUrl + "]"; + } } diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/mapper/VnfmSubscriptionsMapper.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/mapper/VnfmSubscriptionsMapper.java index 6840cf39..8b2a26d4 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/mapper/VnfmSubscriptionsMapper.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/mapper/VnfmSubscriptionsMapper.java @@ -24,7 +24,6 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Result; import org.apache.ibatis.annotations.Results; import org.apache.ibatis.annotations.Select; -import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmJobExecutionInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmSubscriptionInfo; @Mapper @@ -32,20 +31,25 @@ public interface VnfmSubscriptionsMapper { @Select("SELECT * FROM vnfm_subscription_info") @Results({ @Result(property = "id", column = "id"), + @Result(property = "driverCallbackUrl", column = "driver_callback_url"), + @Result(property = "nslcmCallbackUrl", column = "nslcm_callback_url") }) List getAll(); @Select("SELECT * FROM vnfm_subscription_info WHERE id = #{id}") @Results({ @Result(property = "id", column = "id"), + @Result(property = "driverCallbackUrl", column = "driver_callback_url"), + @Result(property = "nslcmCallbackUrl", column = "nslcm_callback_url") }) VnfmSubscriptionInfo findOne(String id); -// @Insert("INSERT INTO vnfm_subscription_info(id) VALUES(#{id})") -// void insert(VnfmJobExecutionInfo user); + @Insert("INSERT IGNORE INTO vnfm_subscription_info(id, driver_callback_url, nslcm_callback_url) VALUES(#{id}, #{driverCallbackUrl}, #{nslcmCallbackUrl})") + void insert(VnfmSubscriptionInfo info); + + @Insert("update vnfm_subscription_info set driver_callback_url = #{driverCallbackUrl}, nslcm_callback_url = #{nslcmCallbackUrl}) WHERE id = #{id}") + void update(VnfmSubscriptionInfo info); - @Insert("INSERT INTO vnfm_subscription_info(id) VALUES(#{id})") - void insert(String id); @Delete("DELETE FROM vnfm_subscription_info WHERE id =#{id}") void delete(String id); diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/repository/VnfmJobExecutionRepository.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/repository/VnfmJobExecutionRepository.java deleted file mode 100644 index 4726d9c2..00000000 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/repository/VnfmJobExecutionRepository.java +++ /dev/null @@ -1,21 +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.db.repository; - -public interface VnfmJobExecutionRepository //extends CrudRepository< VnfmJobExecutionInfo, Long> -{ - -} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/repository/VnfmResourceRepository.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/repository/VnfmResourceRepository.java deleted file mode 100644 index 1c8456bd..00000000 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/repository/VnfmResourceRepository.java +++ /dev/null @@ -1,21 +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.db.repository; - -public interface VnfmResourceRepository //extends CrudRepository -{ - -} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/repository/VnfmSubscriptionsRepository.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/repository/VnfmSubscriptionsRepository.java deleted file mode 100644 index e5d3bd7d..00000000 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/db/repository/VnfmSubscriptionsRepository.java +++ /dev/null @@ -1,24 +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.db.repository; - -import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.bean.VnfmSubscriptionInfo; -//import org.springframework.data.repository.CrudRepository; - -public interface VnfmSubscriptionsRepository //extends CrudRepository -{ - -} diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientUtils.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientUtils.java index 0d3d5a1e..cbd56f42 100644 --- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientUtils.java +++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientUtils.java @@ -52,7 +52,7 @@ public class HttpClientUtils { @Bean public static HttpClientBuilder createHttpClientBuilder() { - org.apache.commons.httpclient.protocol.Protocol.unregisterProtocol("https"); +// org.apache.commons.httpclient.protocol.Protocol.unregisterProtocol("https"); SSLContext sslcontext = null; try { sslcontext = createIgnoreVerifySSL(); 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 99c06b2c..fa7eb46d 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 @@ -16,12 +16,15 @@ package org.onap.vfc.nfvo.driver.vnfm.svnfm.vnfmdriver.controller; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.io.IOUtils; +//import org.apache.commons.io.IOUtils; +import com.alibaba.dubbo.common.utils.IOUtils; import org.apache.http.HttpStatus; import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf; import org.onap.vfc.nfvo.driver.vnfm.svnfm.exception.VnfmDriverException; @@ -60,9 +63,6 @@ public class VnfmDriverController { @Autowired private VnfmDriverMgmrInf vnfmDriverMgmr; - @Autowired - private CbamMgmrInf cbamMgmr; - private Gson gson = new Gson(); @RequestMapping(value = "/swagger.json", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @@ -70,7 +70,7 @@ public class VnfmDriverController { public String apidoc() throws IOException { // String client = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getRemoteAddr(); ClassLoader classLoader = getClass().getClassLoader(); - return IOUtils.toString(classLoader.getResourceAsStream("swagger.json")); + return IOUtils.read(new BufferedReader(new InputStreamReader(classLoader.getResourceAsStream("swagger.json")))); } @RequestMapping(value = "/{vnfmId}/vnfs", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @@ -197,29 +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) + public void notificationVnf(HttpServletRequest request, HttpServletResponse httpResponse) throws IOException { -// String jsonString = gson.toJson(request); -// logger.info("notificationVnf request: bodyMessage is " + jsonString); - logger.info("notificationVnf request: bodyMessage is " + request.getMethod() + ","); + logger.info("VnfmDriverController -> notificationVnf request: request method is " + request.getMethod() + ","); try { -// CBAMVnfNotificationResponse response = cbamMgmr.getNotification(request); - httpResponse.setStatus(204); -// logger.info("cbamController --> notificationVnf response is " + gson.toJson(response)); -// return response; + if("GET".equalsIgnoreCase(request.getMethod())) // this is for link test + { + httpResponse.setStatus(HttpStatus.SC_NO_CONTENT); + } + else if("POST".equalsIgnoreCase(request.getMethod())) + { + httpResponse.setStatus(HttpStatus.SC_NO_CONTENT); + BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream())); + String bodyString = IOUtils.read(reader); + logger.info("VnfmDriverController -> notificationVnf request: bodyMessage is " + bodyString); + } } catch(VnfmDriverException e) { processControllerException(httpResponse, e); } -// return null; } private void processControllerException(HttpServletResponse httpResponse, VnfmDriverException e) { 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 8a2090fd..beb70763 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 @@ -52,6 +52,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.bean.VnfmSubscriptionInfo; import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfmJobExecutionMapper; import org.onap.vfc.nfvo.driver.vnfm.svnfm.db.mapper.VnfmSubscriptionsMapper; import org.onap.vfc.nfvo.driver.vnfm.svnfm.exception.VnfmDriverException; @@ -239,7 +240,7 @@ public class VnfmDriverMgmrImplTest { mockCbamResponse.setId("subscriptionId_001"); mockCbamResponse.setCallbackUrl("callbackUrl"); when(cbamMgmr.createSubscription(Mockito.any(CBAMCreateSubscriptionRequest.class))).thenReturn(mockCbamResponse); - doNothing().when(subscriptionsMapper).insert(Mockito.anyString()); + doNothing().when(subscriptionsMapper).insert(Mockito.any(VnfmSubscriptionInfo.class)); CreateSubscriptionRequest request = new CreateSubscriptionRequest(); CreateSubscriptionResponse response = vnfmDriverMgmr.createSubscription(request); Assert.assertEquals("callbackUrl", response.getCallbackUri()); 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 103b394b..9bacde42 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 @@ -305,5 +305,32 @@ public class VnfmDriverControllerTest { JSONObject jsonObj = new JSONObject(responseString); Assert.assertEquals("jobId is ", mockResponse.getCallbackUri(), jsonObj.get("callbackUri")); } + + @Test + public void testNotificationVnfCreateSubscripitonPost() throws Exception { + CreateSubscriptionResponse mockResponse = new CreateSubscriptionResponse(); + mockResponse.setCallbackUri("callbackUri"); + String jsonString = "{\"callbackUri\":\"callbackUri\"," + "\"authentication\":{\"userName\":\"userName\",\"password\":\"password\",\"clientName\":\"clientName\"}}"; + + when(vnfmDriverMgmr.createSubscription(Mockito.any(CreateSubscriptionRequest.class))).thenReturn(mockResponse); + + mockMvc.perform( + post("/api/nokiavnfmdriver/v1/notifications"). + characterEncoding("UTF-8"). + accept(MediaType.APPLICATION_JSON). + contentType(MediaType.APPLICATION_JSON). + content(jsonString)) + .andDo(print()) + .andExpect(status().isNoContent()) + .andReturn().getResponse().getContentAsString(); + } + + @Test + public void testNotificationVnfCreateSubscripitonGet() throws Exception { + mockMvc.perform( + get("/api/nokiavnfmdriver/v1/notifications")) + .andDo(print()) + .andExpect(status().isNoContent()); + } } -- cgit 1.2.3-korg