summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImpl.java17
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImpl.java16
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/controller/CbamController.java183
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImpl.java6
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java2
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorInf.java2
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java19
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpResult.java58
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImpl.java2
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImplTest.java70
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImplTest.java41
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/impl/CbamMgmrImplTest.java5
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java34
-rw-r--r--nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nslcm/impl/NslcmMgmrImplTest.java5
14 files changed, 240 insertions, 220 deletions
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 caec85da..00fc0000 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
@@ -17,6 +17,7 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.impl;
import java.io.IOException;
+import java.util.HashMap;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.impl.client.HttpClientBuilder;
@@ -24,6 +25,7 @@ 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;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpRequestProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,8 +43,8 @@ public class AaiMgmrInfImpl implements AaiMgmrInf{
@Autowired
private AdaptorEnv adaptorEnv;
- @Autowired
- private HttpClientBuilder httpClientBuilder;
+ @Autowired
+ HttpClientProcessorInf httpClientProcessor;
private Gson gson = new Gson();
@Override
@@ -61,14 +63,17 @@ public class AaiMgmrInfImpl implements AaiMgmrInf{
private String operateHttpTask(Object httpBodyObj, String httpPath, RequestMethod method) throws ClientProtocolException, IOException {
String url=adaptorEnv.getAaiApiUriFront() + httpPath;
- HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, method);
- processor.addHdeader(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
- processor.addPostEntity(gson.toJson(httpBodyObj));
+ HashMap<String, String> map = new HashMap<String, String>();
+ map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
- String responseStr = processor.process(url);
+ String responseStr = httpClientProcessor.process(url, method, map, gson.toJson(httpBodyObj)).getContent();
return responseStr;
}
+ 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/catalog/impl/CatalogMgmrImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/catalog/impl/CatalogMgmrImpl.java
index b00f61c7..2e4dd999 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
@@ -17,6 +17,7 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.impl;
import java.io.IOException;
+import java.util.HashMap;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.impl.client.HttpClientBuilder;
@@ -26,9 +27,11 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.bo.CatalogQueryVnfResponse;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.inf.CatalogMgmrInf;
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;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpRequestProcessor;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VnfPackageInfo;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -44,13 +47,16 @@ public class CatalogMgmrImpl implements CatalogMgmrInf{
private AdaptorEnv adaptorEnv;
@Autowired
- private HttpClientBuilder httpClientBuilder;
+ HttpClientProcessorInf httpClientProcessor;
public VnfPackageInfo queryVnfPackage(String vnfPackageId) throws ClientProtocolException, IOException {
+
String url=adaptorEnv.getCatalogApiUriFront() + String.format(CommonConstants.RetrieveVnfPackagePath, vnfPackageId);
- HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, RequestMethod.GET);
+ HashMap<String, String> map = new HashMap<String, String>();
+
+ String bodyPostStr = String.format(CommonConstants.RetrieveCbamTokenPostStr, adaptorEnv.getGrantType(), adaptorEnv.getClientId(), adaptorEnv.getClientSecret());
- String responseStr = processor.process(url);
+ String responseStr = httpClientProcessor.process(url, RequestMethod.GET, map, bodyPostStr).getContent();
logger.info("CbamMgmrImpl -> queryVnfPackage, responseStr is " + responseStr);
@@ -59,5 +65,9 @@ public class CatalogMgmrImpl implements CatalogMgmrInf{
return resp.getPackageInfo();
}
+ 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/cbam/controller/CbamController.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/controller/CbamController.java
deleted file mode 100644
index 0e772a4b..00000000
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/cbam/controller/CbamController.java
+++ /dev/null
@@ -1,183 +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.controller;
-
-import java.io.IOException;
-
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.log4j.Logger;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.bo.CatalogQueryVnfResponse;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMCreateVnfResponse;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfRequest;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMHealVnfResponse;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfRequest;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMInstantiateVnfResponse;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMOperExecutVnfResponse;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMQueryVnfResponse;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfRequest;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMScaleVnfResponse;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfRequest;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.bo.CBAMTerminateVnfResponse;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.constant.CommonConstants;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpRequestProcessor;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import com.google.gson.Gson;
-
-@Controller
-@RequestMapping(value = "/vnfm/lcm/v3")
-public class CbamController {
- private static final Logger logger = Logger.getLogger(CbamController.class);
- @Autowired
- private AdaptorEnv adaptorEnv;
-
- @Autowired
- private HttpClientBuilder httpClientBuilder;
-
- private Gson gson = new Gson();
-
- @RequestMapping(value = "/vnfs", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- @ResponseBody
- public CBAMCreateVnfResponse createVnf(CBAMInstantiateVnfRequest request) throws ClientProtocolException, IOException
- {
- CBAMCreateVnfResponse response = new CBAMCreateVnfResponse();
- String url=adaptorEnv.getCbamApiUriFront() + String.format(CommonConstants.CbamCreateVnfPath);
- HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, RequestMethod.GET);
-
- String responseStr = processor.process(url);
-
- logger.info("CbamMgmrImpl -> createVnf, responseStr is " + responseStr);
-
- CatalogQueryVnfResponse resp = gson.fromJson(responseStr, CatalogQueryVnfResponse.class);
-
-
- return response;
- }
- @RequestMapping(value = "/vnfs/{vnfInstanceId}/instantiate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- @ResponseBody
- public CBAMInstantiateVnfResponse initiateVnf(CBAMInstantiateVnfRequest request, @PathVariable("vnfInstanceId") String vnfInstanceId) throws ClientProtocolException, IOException
- {
- CBAMInstantiateVnfResponse response = new CBAMInstantiateVnfResponse();
- String url=adaptorEnv.getCbamApiUriFront() + String.format(CommonConstants.CbamInstantiateVnfPath,vnfInstanceId);
- HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, RequestMethod.GET);
-
- String responseStr = processor.process(url);
-
- logger.info("CbamMgmrImpl -> initiateVnf, responseStr is " + responseStr);
-
- CatalogQueryVnfResponse resp = gson.fromJson(responseStr, CatalogQueryVnfResponse.class);
-
-
- return response;
- }
-
- @RequestMapping(value = "/vnfs/{vnfInstanceId}/terminate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- @ResponseBody
- public CBAMTerminateVnfResponse terminateVnf(CBAMTerminateVnfRequest request, @PathVariable("vnfInstanceId") String vnfInstanceId) throws ClientProtocolException, IOException
- {
- CBAMTerminateVnfResponse response = new CBAMTerminateVnfResponse();
- String url=adaptorEnv.getCbamApiUriFront() + String.format(CommonConstants.CbamTerminateVnfPath,vnfInstanceId);
- HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, RequestMethod.GET);
-
- String responseStr = processor.process(url);
-
- logger.info("CbamMgmrImpl -> terminateVnf, responseStr is " + responseStr);
-
- CatalogQueryVnfResponse resp = gson.fromJson(responseStr, CatalogQueryVnfResponse.class);
- return response;
- }
-
- @RequestMapping(value = "/vnfs/{vnfInstanceId}/scale", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- @ResponseBody
- public CBAMScaleVnfResponse scaleVnf(CBAMScaleVnfRequest request, @PathVariable("vnfInstanceId") String vnfInstanceId) throws ClientProtocolException, IOException
- {
- CBAMScaleVnfResponse response = new CBAMScaleVnfResponse();
- String url=adaptorEnv.getCbamApiUriFront() + String.format(CommonConstants.CbamScaleVnfPath,vnfInstanceId);
- HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, RequestMethod.GET);
-
- String responseStr = processor.process(url);
-
- logger.info("CbamMgmrImpl -> scaleVnf, responseStr is " + responseStr);
-
- CatalogQueryVnfResponse resp = gson.fromJson(responseStr, CatalogQueryVnfResponse.class);
- return response;
- }
-
- @RequestMapping(value = "/vnfs/{vnfInstanceId}/heal", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
- @ResponseBody
- public CBAMHealVnfResponse healVnf(CBAMHealVnfRequest request, @PathVariable("vnfInstanceId") String vnfInstanceId) throws ClientProtocolException, IOException
- {
- CBAMHealVnfResponse response = new CBAMHealVnfResponse();
- String url=adaptorEnv.getCbamApiUriFront() + String.format(CommonConstants.CbamHealVnfPath,vnfInstanceId);
- HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, RequestMethod.GET);
-
- String responseStr = processor.process(url);
-
- logger.info("CbamMgmrImpl -> healVnf, responseStr is " + responseStr);
-
- CatalogQueryVnfResponse resp = gson.fromJson(responseStr, CatalogQueryVnfResponse.class);
- return response;
- }
-
-
- @RequestMapping(value = "/vnfs/{vnfInstanceId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- @ResponseBody
- public CBAMQueryVnfResponse queryVnf(@PathVariable("vnfInstanceId") String vnfInstanceId) throws ClientProtocolException, IOException
- {
- CBAMQueryVnfResponse response = new CBAMQueryVnfResponse();
- String url=adaptorEnv.getCbamApiUriFront() + String.format(CommonConstants.CbamQueryVnfPath, vnfInstanceId);
- HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, RequestMethod.GET);
-
- String responseStr = processor.process(url);
-
- logger.info("CbamMgmrImpl -> queryVnfPackage, responseStr is " + responseStr);
-
- CatalogQueryVnfResponse resp = gson.fromJson(responseStr, CatalogQueryVnfResponse.class);
-
-
- return response;
- }
-
-
- @RequestMapping(value = "/operation_executions/{operationExecutionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
- @ResponseBody
- public CBAMOperExecutVnfResponse operVnf(@PathVariable("operationExecutionId") String operationExecutionId) throws ClientProtocolException, IOException
- {
- CBAMOperExecutVnfResponse response = new CBAMOperExecutVnfResponse();
- String url=adaptorEnv.getCbamApiUriFront() + String.format(CommonConstants.CbamGetOperStatusPath,operationExecutionId);
- HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, RequestMethod.GET);
-
- String responseStr = processor.process(url);
-
- logger.info("CbamMgmrImpl -> operVnf, responseStr is " + responseStr);
-
- CatalogQueryVnfResponse resp = gson.fromJson(responseStr, CatalogQueryVnfResponse.class);
- return response;
- }
-
-
-
-
-}
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 2c88320e..ee6b011a 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
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.HashMap;
import org.apache.http.client.ClientProtocolException;
-import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.log4j.Logger;
import org.json.JSONException;
import org.json.JSONObject;
@@ -40,7 +39,6 @@ import org.onap.vfc.nfvo.driver.vnfm.svnfm.cbam.inf.CbamMgmrInf;
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;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpRequestProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
@@ -68,7 +66,7 @@ public class CbamMgmrImpl implements CbamMgmrInf {
String bodyPostStr = String.format(CommonConstants.RetrieveCbamTokenPostStr, adaptorEnv.getGrantType(), adaptorEnv.getClientId(), adaptorEnv.getClientSecret());
- String responseStr = httpClientProcessor.process(url, RequestMethod.GET, map, bodyPostStr);
+ String responseStr = httpClientProcessor.process(url, RequestMethod.GET, map, bodyPostStr).getContent();
logger.info("CbamMgmrImpl -> retrieveToken, responseStr is " + responseStr);
@@ -181,7 +179,7 @@ public class CbamMgmrImpl implements CbamMgmrInf {
map.put(CommonConstants.AUTHORIZATION, "bearer " + token);
map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
- String responseStr = httpClientProcessor.process(url, method, map, gson.toJson(httpBodyObj));
+ String responseStr = httpClientProcessor.process(url, method, map, gson.toJson(httpBodyObj)).getContent();
return responseStr;
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java
index 9bebb1c9..319b0e32 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorImpl.java
@@ -31,7 +31,7 @@ public class HttpClientProcessorImpl implements HttpClientProcessorInf{
@Autowired
private HttpClientBuilder httpClientBuilder;
- public String process(String url, RequestMethod methodType, HashMap<String, String> headerMap, String bodyString) throws ClientProtocolException, IOException
+ public HttpResult process(String url, RequestMethod methodType, HashMap<String, String> headerMap, String bodyString) throws ClientProtocolException, IOException
{
HttpRequestProcessor processor = new HttpRequestProcessor(httpClientBuilder, methodType);
if(headerMap != null && !headerMap.isEmpty())
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorInf.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorInf.java
index 41b84d9b..cbb820b8 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorInf.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpClientProcessorInf.java
@@ -23,6 +23,6 @@ import org.apache.http.client.ClientProtocolException;
import org.springframework.web.bind.annotation.RequestMethod;
public interface HttpClientProcessorInf {
- public String process(String url, RequestMethod methodType, HashMap<String, String> headerMap, String bodyString) throws ClientProtocolException, IOException;
+ public HttpResult process(String url, RequestMethod methodType, HashMap<String, String> headerMap, String bodyString) throws ClientProtocolException, IOException;
}
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java
index b2414a52..bd3e3635 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpRequestProcessor.java
@@ -41,20 +41,33 @@ public class HttpRequestProcessor {
httpRequest = HttpClientUtils.getHttpRequest(requestMethod);
}
- public String process(String url) throws ClientProtocolException, IOException
+ public HttpResult process(String url) throws ClientProtocolException, IOException
{
httpRequest.setURI(URI.create(url));
HttpResponse response = httpClient.execute(httpRequest);
+
+ HttpResult httpResult = buildHttpResult(response);
+ httpClient.close();
+
+ return httpResult;
+ }
+
+ private HttpResult buildHttpResult(HttpResponse response) throws IOException {
HttpEntity resEntity = response.getEntity();
String responseContent = "";
if (resEntity != null) {
responseContent = EntityUtils.toString(resEntity, CommonConstants.UTF_8);
EntityUtils.consume(resEntity);
}
- httpClient.close();
- return responseContent;
+ HttpResult httpResult = new HttpResult();
+ httpResult.setStatusCode(response.getStatusLine().getStatusCode());
+ httpResult.setStatusCause(response.getStatusLine().getReasonPhrase());
+ httpResult.setHeaders(response.getAllHeaders());
+ httpResult.setContent(responseContent);
+
+ return httpResult;
}
public void addHdeader(String key, String value) {
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpResult.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpResult.java
new file mode 100644
index 00000000..3c5ace92
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/http/client/HttpResult.java
@@ -0,0 +1,58 @@
+/*
+ * 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.http.client;
+
+import org.apache.http.Header;
+
+public class HttpResult {
+ private int statusCode;
+ private String statusCause;
+ private Header[] headers;
+ private String content;
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ public void setStatusCode(int statusCode) {
+ this.statusCode = statusCode;
+ }
+
+ public String getStatusCause() {
+ return statusCause;
+ }
+
+ public void setStatusCause(String statusCause) {
+ this.statusCause = statusCause;
+ }
+
+ public Header[] getHeaders() {
+ return headers;
+ }
+
+ public void setHeaders(Header[] headers) {
+ this.headers = headers;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+}
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 405c7365..e9c58122 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
@@ -92,7 +92,7 @@ public class NslcmMgmrImpl implements NslcmMgmrInf{
HashMap<String, String> map = new HashMap<String, String>();
map.put(CommonConstants.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
- String responseStr = httpClientProcessor.process(url, method, map, gson.toJson(httpBodyObj));
+ String responseStr = httpClientProcessor.process(url, method, map, gson.toJson(httpBodyObj)).getContent();
return responseStr;
}
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
new file mode 100644
index 00000000..23a4893f
--- /dev/null
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/aai/impl/AaiMgmrInfImplTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.aai.impl;
+
+import static org.mockito.Mockito.when;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+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.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.aai.bo.AaiVnfmInfo;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpResult;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+public class AaiMgmrInfImplTest {
+ @InjectMocks
+ private AaiMgmrInfImpl aaiMgmr;
+
+ @Mock
+ private HttpClientProcessorInf httpClientProcessor;
+
+ private String vnfmId = "vnfmId_001";
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ AdaptorEnv env = new AdaptorEnv();
+ aaiMgmr.setAdaptorEnv(env);
+ MockitoAnnotations.initMocks(this);
+
+ String json = "{"
+ + "\"vnfm-id\":\"vnfm-id_001\","
+ + "\"esr-system-info-list\":[{\"ip\" : \"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
+ {
+ AaiVnfmInfo vnfmInfo = aaiMgmr.queryVnfm(vnfmId);
+// Assert.assertEquals("1.3.5.6", vnfmInfo.getEsrSystemInfoList().get(0).getIp());
+ }
+}
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 7fac27b0..a8ad4ae3 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
@@ -16,20 +16,55 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.catalog.impl;
-import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+import java.io.IOException;
+import java.util.HashMap;
+
+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.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpResult;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.bo.entity.VnfPackageInfo;
+import org.springframework.web.bind.annotation.RequestMethod;
public class CatalogMgmrImplTest {
+ @InjectMocks
+ private CatalogMgmrImpl catalogMgmr;
+ @Mock
+ private HttpClientProcessorInf httpClientProcessor;
+
+ private String vnfPackageId = "vnfPackageId_001";
+
@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 test() {
-// fail("Not yet implemented");
+ public void testQueryVnfPackage() throws ClientProtocolException, IOException
+ {
+ VnfPackageInfo response = catalogMgmr.queryVnfPackage(vnfPackageId);
}
}
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 b4cabfbe..6c7eede1 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
@@ -41,6 +41,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.common.bo.AdaptorEnv;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpResult;
import org.springframework.web.bind.annotation.RequestMethod;
public class CbamMgmrImplTest {
@@ -60,8 +61,10 @@ public class CbamMgmrImplTest {
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(json);
+ when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult);
}
@Test
diff --git a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java
index 08587109..8e175e63 100644
--- a/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java
+++ b/nokia/vnfmdriver/vfcadaptorservice/vfcadaptor/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/msb/impl/MsbMgmrImplTest.java
@@ -16,22 +16,14 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.msb.impl;
-import static org.mockito.Mockito.when;
-
-import java.io.IOException;
-import java.util.HashMap;
-
-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.Mockito;
import org.mockito.MockitoAnnotations;
+import org.onap.msb.sdk.discovery.common.RouteException;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.common.bo.AdaptorEnv;
import org.onap.vfc.nfvo.driver.vnfm.svnfm.http.client.HttpClientProcessorInf;
-import org.onap.vfc.nfvo.driver.vnfm.svnfm.nslcm.impl.NslcmMgmrImpl;
-import org.springframework.web.bind.annotation.RequestMethod;
public class MsbMgmrImplTest {
@InjectMocks
@@ -44,11 +36,27 @@ public class MsbMgmrImplTest {
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
AdaptorEnv env = new AdaptorEnv();
+ env.setMsbIp("127.0.0.1");
+ env.setMsbPort(80);
msbMgmr.setAdaptorEnv(env);
MockitoAnnotations.initMocks(this);
-
- String json = "{\"access_token\":\"1234567\"}";
-
- when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(json);
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testRegister()
+ {
+ msbMgmr.register();
+ }
+
+ @Test(expected = RuntimeException.class)
+ public void testunRegister()
+ {
+ msbMgmr.unregister();
+ }
+
+ @Test(expected = RouteException.class)
+ public void testGetServiceUrlInMsbBySeriveNameAndPort() throws RouteException
+ {
+ msbMgmr.getServiceUrlInMsbBySeriveNameAndPort("serviceName", "88");
}
}
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 d445212a..5a26b2ef 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
@@ -30,6 +30,7 @@ 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.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;
@@ -52,8 +53,10 @@ public class NslcmMgmrImplTest {
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(json);
+ when(httpClientProcessor.process(Mockito.anyString(), Mockito.any(RequestMethod.class), Mockito.any(HashMap.class), Mockito.anyString())).thenReturn(httpResult);
}
@Test