summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/images/VID_errorReportButton.pngbin174279 -> 162325 bytes
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java286
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java12
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java2
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java4
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js9
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitController.js12
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.js9
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.js10
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java126
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java39
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java37
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java9
13 files changed, 339 insertions, 216 deletions
diff --git a/docs/images/VID_errorReportButton.png b/docs/images/VID_errorReportButton.png
index 3d3e24eda..c7d330cbb 100644
--- a/docs/images/VID_errorReportButton.png
+++ b/docs/images/VID_errorReportButton.png
Binary files differ
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
index 00f9db246..db3a21910 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/MsoController.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,8 +20,14 @@
package org.onap.vid.controller;
+import static org.onap.vid.utils.Logging.getMethodName;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.vid.model.ExceptionResponse;
@@ -37,15 +43,13 @@ import org.onap.vid.services.CloudOwnerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import static org.onap.vid.utils.Logging.getMethodName;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
/**
* The Class MsoController.
@@ -94,7 +98,8 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_create_svc_instance", method = RequestMethod.POST)
- public ResponseEntity<String> createSvcInstance(HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
+ public ResponseEntity<String> createSvcInstance(HttpServletRequest request,
+ @RequestBody RequestDetails msoRequest) {
String methodName = "createSvcInstance";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -104,8 +109,7 @@ public class MsoController extends RestrictedBaseController {
cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
MsoResponseWrapper w = msoBusinessLogic.createSvcInstance(msoRequest);
- return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
-
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
@@ -116,7 +120,8 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_create_e2e_svc_instance", method = RequestMethod.POST)
- public ResponseEntity<String> createE2eSvcInstance(HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> msoRequest) {
+ public ResponseEntity<String> createE2eSvcInstance(HttpServletRequest request,
+ @RequestBody LinkedHashMap<String, Object> msoRequest) {
String methodName = "createE2eSvcInstance";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -126,62 +131,63 @@ public class MsoController extends RestrictedBaseController {
//cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
MsoResponseWrapper w = msoBusinessLogic.createE2eSvcInstance(msoRequest.get("requestDetails"));
- return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
-
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Creates the vnf.
*
* @param serviceInstanceId the service instance id
- * @param request the request
+ * @param request the request
* @return the response entity
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_create_vnf_instance/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
+ public ResponseEntity<String> createVnf(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
MsoResponseWrapper w = msoBusinessLogic.createVnf(msoRequest, serviceInstanceId);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
-
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Creates the nw instance.
*
* @param serviceInstanceId the service instance id
- * @param request the request
+ * @param request the request
* @return the response entity
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_create_nw_instance/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
+ public ResponseEntity<String> createNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
String methodName = "createNwInstance";
- LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
+ LOGGER.debug(EELFLoggerDelegate.debugLogger,
+ "<== " + methodName + " start, serviceInstanceId = " + serviceInstanceId);
cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
MsoResponseWrapper w = msoBusinessLogic.createNwInstance(msoRequest, serviceInstanceId);
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
-
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Creates the volume group instance.
*
* @param serviceInstanceId the service instance id
- * @param vnfInstanceId the vnf instance id
- * @param request the request
+ * @param vnfInstanceId the vnf instance id
+ * @param request the request
* @return the response entity
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_create_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
- HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
+ public ResponseEntity<String> createVolumeGroupInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("vnfInstanceId") String vnfInstanceId,
+ HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
String methodName = "createVolumeGroupInstance";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -189,21 +195,22 @@ public class MsoController extends RestrictedBaseController {
MsoResponseWrapper w = msoBusinessLogic.createVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Creates the vf module instance.
*
* @param serviceInstanceId the service instance id
- * @param vnfInstanceId the vnf instance id
- * @param request the request
+ * @param vnfInstanceId the vnf instance id
+ * @param request the request
* @return the response entity
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_create_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
public ResponseEntity<String> createVfModuleInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
+ @PathVariable("vnfInstanceId") String vnfInstanceId, HttpServletRequest request,
+ @RequestBody RequestDetails msoRequest) {
String methodName = "createVfModuleInstance";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -213,20 +220,21 @@ public class MsoController extends RestrictedBaseController {
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Creates a configuration instance.
*
* @param serviceInstanceId the service instance id
- * @param request the request
+ * @param request the request
* @return the response entity
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_create_configuration_instance/{serviceInstanceId}/configurations/", method = RequestMethod.POST)
- public ResponseEntity<String> createConfigurationInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- HttpServletRequest request, @RequestBody RequestDetailsWrapper msoRequest) {
+ public ResponseEntity<String> createConfigurationInstance(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ HttpServletRequest request, @RequestBody RequestDetailsWrapper msoRequest) {
String methodName = "createConfigurationInstance";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -235,42 +243,41 @@ public class MsoController extends RestrictedBaseController {
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Delete E2e svc instance.
*
* @param serviceInstanceId the service instance id
- * @param request the request
+ * @param request the request
* @return the response entity
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_delete_e2e_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
public ResponseEntity<String> deleteE2eSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> msoRequest) {
+ HttpServletRequest request, @RequestBody LinkedHashMap<String, Object> msoRequest) {
LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), msoRequest);
- MsoResponseWrapper w = msoBusinessLogic.deleteE2eSvcInstance(msoRequest.get("requestDetails"), serviceInstanceId);
+ MsoResponseWrapper w = msoBusinessLogic
+ .deleteE2eSvcInstance(msoRequest.get("requestDetails"), serviceInstanceId);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
-
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Delete svc instance.
*
* @param serviceInstanceId the service instance id
- * @param request the request
+ * @param request the request
* @return the response entity
* @throws Exception the exception
*/
-
@RequestMapping(value = "/mso_delete_svc_instance/{serviceInstanceId}", method = RequestMethod.POST)
public String deleteSvcInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- HttpServletRequest request, @RequestBody RequestDetails msoRequest,
- @RequestParam(value = "serviceStatus") String serviceStatus) {
+ HttpServletRequest request, @RequestBody RequestDetails msoRequest,
+ @RequestParam(value = "serviceStatus") String serviceStatus) {
LOGGER.debug(EELFLoggerDelegate.debugLogger, "start {}({})", getMethodName(), msoRequest);
MsoResponseWrapper w = msoBusinessLogic.deleteSvcInstance(msoRequest, serviceInstanceId, serviceStatus);
@@ -283,15 +290,16 @@ public class MsoController extends RestrictedBaseController {
* Delete vnf.
*
* @param serviceInstanceId the service instance id
- * @param vnfInstanceId the vnf instance id
- * @param request the request
+ * @param vnfInstanceId the vnf instance id
+ * @param request the request
* @return the response entity
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_delete_vnf_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
- HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
+ public ResponseEntity<String> deleteVnf(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("vnfInstanceId") String vnfInstanceId,
+ HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
String methodName = "deleteVnf";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -299,12 +307,12 @@ public class MsoController extends RestrictedBaseController {
MsoResponseWrapper w = msoBusinessLogic.deleteVnf(msoRequest, serviceInstanceId, vnfInstanceId);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
-
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Delete configuration instance
+ *
* @param serviceInstanceId the service instance id
* @param configurationId the configuration id
* @param msoRequest the request
@@ -312,25 +320,26 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "mso_delete_configuration/{serviceInstanceId}/configurations/{configurationId}",
- method = RequestMethod.POST)
+ method = RequestMethod.POST)
public ResponseEntity<String> deleteConfiguration(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable ("configurationId") String configurationId,
- @RequestBody RequestDetailsWrapper msoRequest) {
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetailsWrapper msoRequest) {
String methodName = "deleteConfiguration";
LOGGER.debug(EELFLoggerDelegate.debugLogger,
- "<== " + methodName + START_LOG);
+ "<== " + methodName + START_LOG);
cloudOwnerService.enrichRequestWithCloudOwner(msoRequest.getRequestDetails());
MsoResponseWrapper w = msoBusinessLogic.deleteConfiguration(msoRequest, serviceInstanceId, configurationId);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Activate configuration instance
+ *
* @param serviceInstanceId the service instace id
* @param configurationId the configuration id
* @param msoRequest the request
@@ -338,21 +347,23 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "mso_activate_configuration/{serviceInstanceId}/configurations/{configurationId}",
- method = RequestMethod.POST)
+ method = RequestMethod.POST)
public ResponseEntity<String> activateConfiguration(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("configurationId") String configurationId,
- @RequestBody RequestDetails msoRequest) {
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetails msoRequest) {
cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
- MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, true);
+ MsoResponseWrapper w = msoBusinessLogic
+ .setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, true);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Deactivate configuration instance
+ *
* @param serviceInstanceId the service instace id
* @param configurationId the configuration id
* @param msoRequest the request
@@ -360,21 +371,23 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "mso_deactivate_configuration/{serviceInstanceId}/configurations/{configurationId}",
- method = RequestMethod.POST)
+ method = RequestMethod.POST)
public ResponseEntity<String> deactivateConfiguration(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("configurationId") String configurationId,
- @RequestBody RequestDetails msoRequest) {
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetails msoRequest) {
cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
- MsoResponseWrapper w = msoBusinessLogic.setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, false);
+ MsoResponseWrapper w = msoBusinessLogic
+ .setConfigurationActiveStatus(msoRequest, serviceInstanceId, configurationId, false);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Disable port on configuration instance
+ *
* @param serviceInstanceId the service instance id
* @param configurationId the configuration instance id
* @param msoRequest the request
@@ -382,21 +395,23 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "mso_disable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
- method = RequestMethod.POST)
+ method = RequestMethod.POST)
public ResponseEntity<String> disablePortOnConfiguration(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("configurationId") String configurationId,
- @RequestBody RequestDetails msoRequest) {
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetails msoRequest) {
cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
- MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, false);
+ MsoResponseWrapper w = msoBusinessLogic
+ .setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, false);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Enable port on configuration instance
+ *
* @param serviceInstanceId the service instance id
* @param configurationId the configuration instance id
* @param msoRequest the request
@@ -404,67 +419,73 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "mso_enable_port_configuration/{serviceInstanceId}/configurations/{configurationId}",
- method = RequestMethod.POST)
+ method = RequestMethod.POST)
public ResponseEntity<String> enablePortOnConfiguration(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("configurationId") String configurationId,
- @RequestBody RequestDetails msoRequest) {
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("configurationId") String configurationId,
+ @RequestBody RequestDetails msoRequest) {
cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
- MsoResponseWrapper w = msoBusinessLogic.setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, true);
+ MsoResponseWrapper w = msoBusinessLogic
+ .setPortOnConfigurationStatus(msoRequest, serviceInstanceId, configurationId, true);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Delete vf module.
*
* @param serviceInstanceId the service instance id
- * @param vnfInstanceId the vnf instance id
- * @param vfModuleId the vf module id
- * @param request the request
+ * @param vnfInstanceId the vnf instance id
+ * @param vfModuleId the vf module id
+ * @param request the request
* @return the response entity
* @throws Exception the exception
*/
//mso_delete_vf_module/bc305d54-75b4-431b-adb2-eb6b9e546014/vnfs/fe9000-0009-9999/vfmodules/abeeee-abeeee-abeeee
@RequestMapping(value = "/mso_delete_vfmodule_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleId}", method = RequestMethod.POST)
public ResponseEntity<String> deleteVfModule(
- @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId,
- @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("vnfInstanceId") String vnfInstanceId,
+ @PathVariable("vfModuleId") String vfModuleId, HttpServletRequest request,
+ @RequestBody RequestDetails msoRequest) {
String methodName = "deleteVfModule";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
- MsoResponseWrapper w = msoBusinessLogic.deleteVfModule(msoRequest, serviceInstanceId, vnfInstanceId, vfModuleId);
+ MsoResponseWrapper w = msoBusinessLogic
+ .deleteVfModule(msoRequest, serviceInstanceId, vnfInstanceId, vfModuleId);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Delete volume group instance.
*
* @param serviceInstanceId the service instance id
- * @param vnfInstanceId the vnf instance id
- * @param volumeGroupId the volume group id
- * @param request the request
+ * @param vnfInstanceId the vnf instance id
+ * @param volumeGroupId the volume group id
+ * @param request the request
* @return the response entity
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_delete_volumegroup_instance/{serviceInstanceId}/vnfs/{vnfInstanceId}/volumeGroups/{volumeGroupId}", method = RequestMethod.POST)
public ResponseEntity<String> deleteVolumeGroupInstance(
- @PathVariable("serviceInstanceId") String serviceInstanceId, @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
- HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("vnfInstanceId") String vnfInstanceId, @PathVariable("volumeGroupId") String volumeGroupId,
+ HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
String methodName = "deleteVolumeGroupInstance";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
cloudOwnerService.enrichRequestWithCloudOwner(msoRequest);
- MsoResponseWrapper w = msoBusinessLogic.deleteVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId, volumeGroupId);
+ MsoResponseWrapper w = msoBusinessLogic
+ .deleteVolumeGroupInstance(msoRequest, serviceInstanceId, vnfInstanceId, volumeGroupId);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
@@ -472,13 +493,14 @@ public class MsoController extends RestrictedBaseController {
*
* @param serviceInstanceId the service instance id
* @param networkInstanceId the network instance id
- * @param request the request
+ * @param request the request
* @return the response entity
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_delete_nw_instance/{serviceInstanceId}/networks/{networkInstanceId}", method = RequestMethod.POST)
public ResponseEntity<String> deleteNwInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request, @RequestBody RequestDetails msoRequest) {
+ @PathVariable("networkInstanceId") String networkInstanceId, HttpServletRequest request,
+ @RequestBody RequestDetails msoRequest) {
String methodName = "deleteNwInstance";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -486,51 +508,49 @@ public class MsoController extends RestrictedBaseController {
MsoResponseWrapper w = msoBusinessLogic.deleteNwInstance(msoRequest, serviceInstanceId, networkInstanceId);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Gets the orchestration request.
*
* @param requestId the request id
- * @param request the request
+ * @param request the request
* @return the orchestration request
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_get_orch_req/{requestId}", method = RequestMethod.GET)
public ResponseEntity<String> getOrchestrationRequest(@PathVariable("requestId") String requestId,
- HttpServletRequest request) {
+ HttpServletRequest request) {
String methodName = "getOrchestrationRequest";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
-
MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequest(requestId);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
* Gets the orchestration requests.
*
* @param filterString the filter string
- * @param request the request
+ * @param request the request
* @return the orchestration requests
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_get_orch_reqs/{filterString}", method = RequestMethod.GET)
public ResponseEntity<String> getOrchestrationRequests(@PathVariable("filterString") String filterString,
- HttpServletRequest request) {
+ HttpServletRequest request) {
String methodName = "getOrchestrationRequests";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
-
MsoResponseWrapper w = msoBusinessLogic.getOrchestrationRequests(filterString);
// always return OK, the MSO status code is embedded in the body
- return (new ResponseEntity<String>(w.getResponse(), HttpStatus.OK));
+ return new ResponseEntity<>(w.getResponse(), HttpStatus.OK);
}
/**
@@ -542,7 +562,8 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_activate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) {
+ public ResponseEntity<String> activateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ @RequestBody RequestDetails requestDetails) {
String methodName = "activateServiceInstance";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -559,7 +580,8 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_deactivate_service_instance/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId, @RequestBody RequestDetails requestDetails) {
+ public ResponseEntity<String> deactivateServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId,
+ @RequestBody RequestDetails requestDetails) {
String methodName = "deactivateServiceInstance";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -569,7 +591,8 @@ public class MsoController extends RestrictedBaseController {
/**
* Gets the orchestration requests for the dashboard.
- * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
+ * currently its all the orchestration requests with RequestType updateInstance or replaceInstance.
+ *
* @return the orchestration requests
* @throws Exception the exception
*/
@@ -579,7 +602,6 @@ public class MsoController extends RestrictedBaseController {
String methodName = "getOrchestrationRequestsForDashboard";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
-
return msoBusinessLogic.getOrchestrationRequestsForDashboard();
}
@@ -596,7 +618,7 @@ public class MsoController extends RestrictedBaseController {
String methodName = "getManualTasksByRequestId";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
- return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
+ return msoBusinessLogic.getManualTasksByRequestId(originalRequestId);
}
/**
@@ -608,7 +630,8 @@ public class MsoController extends RestrictedBaseController {
* @throws Exception the exception
*/
@RequestMapping(value = "/mso_post_man_task/{taskId}", method = RequestMethod.POST)
- public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId , @RequestBody RequestDetails requestDetails) {
+ public ResponseEntity<String> manualTaskComplete(@PathVariable("taskId") String taskId,
+ @RequestBody RequestDetails requestDetails) {
String methodName = "manualTaskComplete";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -618,8 +641,9 @@ public class MsoController extends RestrictedBaseController {
}
@RequestMapping(value = "/mso_remove_relationship/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> removeRelationshipFromServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
- @RequestBody RequestDetails requestDetails) {
+ public ResponseEntity<String> removeRelationshipFromServiceInstance(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @RequestBody RequestDetails requestDetails) {
String methodName = "removeRelationshipFromServiceInstance";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -627,7 +651,7 @@ public class MsoController extends RestrictedBaseController {
MsoResponseWrapper w;
try {
w = msoBusinessLogic.removeRelationshipFromServiceInstance(requestDetails, serviceInstanceId);
- } catch (Exception e){
+ } catch (Exception e) {
LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
@@ -635,8 +659,9 @@ public class MsoController extends RestrictedBaseController {
}
@RequestMapping(value = "/mso_add_relationship/{serviceInstanceId}", method = RequestMethod.POST)
- public ResponseEntity<String> addRelationshipToServiceInstance(@PathVariable("serviceInstanceId") String serviceInstanceId ,
- @RequestBody RequestDetails requestDetails) {
+ public ResponseEntity<String> addRelationshipToServiceInstance(
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @RequestBody RequestDetails requestDetails) {
String methodName = "addRelationshipToServiceInstance";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -644,7 +669,7 @@ public class MsoController extends RestrictedBaseController {
MsoResponseWrapper w;
try {
w = msoBusinessLogic.addRelationshipToServiceInstance(requestDetails, serviceInstanceId);
- } catch (Exception e){
+ } catch (Exception e) {
LOGGER.error("Internal error when calling MSO controller logic for {}", methodName, e);
return new ResponseEntity<>(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
@@ -653,8 +678,8 @@ public class MsoController extends RestrictedBaseController {
@RequestMapping(value = "/mso_activate_fabric_configuration/{serviceInstanceId}", method = RequestMethod.POST)
public MsoResponseWrapper2 activateFabricConfiguration(
- @PathVariable("serviceInstanceId") String serviceInstanceId ,
- @RequestBody RequestDetails requestDetails) {
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @RequestBody RequestDetails requestDetails) {
String methodName = "activateFabricConfiguration";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -664,10 +689,10 @@ public class MsoController extends RestrictedBaseController {
@RequestMapping(value = "/mso_vfmodule_soft_delete/{serviceInstanceId}/{vnfInstanceId}/{vfModuleInstanceId}", method = RequestMethod.POST)
public MsoResponseWrapper2 deactivateAndCloudDelete(
- @PathVariable("serviceInstanceId") String serviceInstanceId,
- @PathVariable("vnfInstanceId") String vnfInstanceId,
- @PathVariable("vfModuleInstanceId") String vfModuleInstanceId,
- @RequestBody SoftDeleteRequest softDeleteRequest) {
+ @PathVariable("serviceInstanceId") String serviceInstanceId,
+ @PathVariable("vnfInstanceId") String vnfInstanceId,
+ @PathVariable("vfModuleInstanceId") String vfModuleInstanceId,
+ @RequestBody SoftDeleteRequest softDeleteRequest) {
String methodName = "deactivateAndCloudDelete";
LOGGER.debug(EELFLoggerDelegate.debugLogger, "<== " + methodName + START_LOG);
@@ -675,14 +700,14 @@ public class MsoController extends RestrictedBaseController {
RequestDetails requestDetails = msoBusinessLogic.buildRequestDetailsForSoftDelete(softDeleteRequest);
cloudOwnerService.enrichRequestWithCloudOwner(requestDetails);
- return msoBusinessLogic.deactivateAndCloudDelete(serviceInstanceId, vnfInstanceId, vfModuleInstanceId, requestDetails);
+ return msoBusinessLogic
+ .deactivateAndCloudDelete(serviceInstanceId, vnfInstanceId, vfModuleInstanceId, requestDetails);
}
-
/**
* Exception handler.
*
- * @param e the e
+ * @param e the e
* @param response the response
* @throws IOException Signals that an I/O exception has occurred.
*/
@@ -701,6 +726,5 @@ public class MsoController extends RestrictedBaseController {
response.getWriter().write(new ObjectMapper().writeValueAsString(exceptionResponse));
response.flushBuffer();
-
}
}
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
index dbeaa90cb..ae3c74d86 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoBusinessLogicImpl.java
@@ -480,7 +480,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
String str = "";
restObjStr.set(str);
- msoClientInterface.setServiceInstanceStatus(requestDetails, str, "", activateServicePath, restObjStr);
+ msoClientInterface.setServiceInstanceStatus(requestDetails, activateServicePath);
return MsoUtil.wrapResponse(restObjStr);
@@ -707,15 +707,7 @@ public class MsoBusinessLogicImpl implements MsoBusinessLogic {
String isActivateState = (isActivate ? ACTIVATE : DEACTIVATE);
endpoint = endpoint + isActivateState;
-
- RestObject<String> restObjStr = new RestObject<>();
- String str = "";
- restObjStr.set(str);
-
- msoClientInterface.setServiceInstanceStatus(requestDetails, str, "", endpoint, restObjStr);
-
- return MsoUtil.wrapResponse(restObjStr);
-
+ return msoClientInterface.setServiceInstanceStatus(requestDetails, endpoint);
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, methodName + e.toString());
logger.debug(EELFLoggerDelegate.debugLogger, methodName + e.toString());
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
index 9befc0f90..cab75bfed 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/MsoInterface.java
@@ -107,7 +107,7 @@ public interface MsoInterface {
MsoResponseWrapper setPortOnConfigurationStatus(RequestDetails requestDetails, String endpoint);
- void setServiceInstanceStatus(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject<String> restObject);
+ MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails, String endpoint);
MsoResponseWrapperInterface changeManagementUpdate(RequestDetailsWrapper requestDetails, String endpoint);
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
index 6a498fc01..c039e0078 100644
--- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
+++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/MsoRestClientNew.java
@@ -397,7 +397,8 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
}
- public void setServiceInstanceStatus(RequestDetails requestDetails, String t, String sourceId, String endpoint, RestObject<String> restObject) {
+ public MsoResponseWrapper setServiceInstanceStatus(RequestDetails requestDetails,
+ String endpoint) {
String methodName = "activateServiceInstance";
logger.debug(EELFLoggerDelegate.debugLogger, methodName + " start ");
try {
@@ -405,6 +406,7 @@ public class MsoRestClientNew extends RestMsoImplementation implements MsoInterf
HttpResponse<String> response = client.post(path, commonHeaders, requestDetails, String.class);
MsoResponseWrapper w = MsoUtil.wrapResponse(response);
logger.debug(EELFLoggerDelegate.debugLogger, methodName + " w =" + w.getResponse());
+ return w;
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "." + methodName + e.toString());
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
index ed03e3aec..072adf305 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/aaiSubscriberController.js
@@ -25,6 +25,13 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
function (COMPONENT, FIELD, PARAMETER, DataService, PropertyService, $scope, $http, $timeout, $location, $log, $route, $uibModal, VIDCONFIGURATION, UtilityService, vidService, AaiService, MsoService, OwningEntityService, AsdcService, featureFlags, $q, _) {
$scope.showReportWindow = function() {
+ let GuiMessage;
+
+ if ($scope.errorMsg !== undefined && $scope.errorMsg !== null) {
+ GuiMessage = $scope.errorMsg;
+ } else {
+ GuiMessage = $scope.status;
+ }
const modalWindow = $uibModal.open({
templateUrl: 'app/vid/scripts/modals/report-modal/report-modal.html',
@@ -32,7 +39,7 @@ appDS2.controller("aaiSubscriberController", ["COMPONENT", "FIELD", "PARAMETER",
controllerAs: 'vm',
resolve: {
errorMsg: function () {
- return $scope.errorMsg;
+ return GuiMessage;
}
}
});
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitController.js b/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitController.js
index e4c75fbe7..c841f14ee 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitController.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/controller/msoCommitController.js
@@ -74,8 +74,16 @@ var msoCommitController = function(COMPONENT, FIELD, $scope, $http, $timeout, $w
$scope.showReportWindow = function() {
let requestInfo = {};
- requestInfo.requestId = _this.requestId;
- requestInfo.serviceUuid = $scope.service.model.service.uuid;
+ if(_this.requestId !== undefined) {
+ requestInfo.requestId = _this.requestId;
+ } else {
+ requestInfo.requestId = null;
+ }
+ if($scope.service !== undefined) {
+ requestInfo.serviceUuid = $scope.service.model.service.uuid;
+ } else {
+ requestInfo.serviceUuid = null;
+ }
const modalWindow = $uibModal.open({
templateUrl: 'app/vid/scripts/modals/report-modal/report-modal.html',
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.js
index 6b69a08fe..48179dd02 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal-request.controller.js
@@ -42,10 +42,11 @@
};
vm.saveReportData = function(response) {
- vm.report =
- "Selected test API: \n" + DataService.getMsoRequestParametersTestApi()
- + "\n\n Data from GUI:\n" + errorMsg
- + "\n\n Collected data from API:\n" + JSON.stringify(response.data, null, "\t") ;
+ vm.report = "Selected test API: \n" + DataService.getMsoRequestParametersTestApi();
+ if(errorMsg !== undefined && errorMsg !== null) {
+ vm.report += "\n\n Data from GUI:\n" + errorMsg;
+ }
+ vm.report +="\n\n Collected data from API:\n" + JSON.stringify(response.data, null, "\t") ;
const blob = new Blob([ vm.report ], { type : 'text/plain' });
vm.download = ($window.URL || $window.webkitURL).createObjectURL( blob );
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.js
index eff029175..215439634 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/report-modal/report-modal.controller.js
@@ -42,11 +42,11 @@
};
vm.saveReportData = function(response) {
- vm.report =
- "Selected test API: \n" + DataService.getMsoRequestParametersTestApi()
- + "\n\n Data from GUI:\n" + errorMsg
- + "\n\n Collected data from API:\n" + JSON.stringify(response.data, null, "\t") ;
-
+ vm.report = "Selected test API: \n" + DataService.getMsoRequestParametersTestApi();
+ if(errorMsg !== undefined && errorMsg !== null) {
+ vm.report += "\n\n Data from GUI:\n" + errorMsg;
+ }
+ vm.report +="\n\n Collected data from API:\n" + JSON.stringify(response.data, null, "\t") ;
const blob = new Blob([ vm.report ], { type : 'text/plain' });
vm.download = ($window.URL || $window.webkitURL).createObjectURL( blob );
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java
index b0378b054..02ab287be 100644
--- a/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/controller/MsoControllerTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,8 +20,8 @@
package org.onap.vid.controller;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.then;
import static org.mockito.Mockito.mock;
@@ -34,7 +34,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
import org.jeasy.random.EasyRandom;
import org.jeasy.random.EasyRandomParameters;
@@ -42,7 +44,6 @@ import org.jeasy.random.randomizers.misc.BooleanRandomizer;
import org.jeasy.random.randomizers.text.StringRandomizer;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.ArgumentCaptor;
import org.onap.vid.mso.MsoBusinessLogic;
import org.onap.vid.mso.MsoResponseWrapper;
import org.onap.vid.mso.rest.Request;
@@ -76,26 +77,23 @@ public class MsoControllerTest {
}
@Test
- public void shouldDelegateNewInstanceCreation() throws Exception {
+ public void shouldDelegateNewServiceInstantiation() throws Exception {
// given
- RequestDetails given = modelGenerator.nextObject(RequestDetails.class);
- String payload = objectMapper.writeValueAsString(given);
+ RequestDetails requestDetails = modelGenerator.nextObject(RequestDetails.class);
MsoResponseWrapper expectedResponse = new MsoResponseWrapper(200, "test");
given(msoBusinessLogic
- .createSvcInstance(argThat(request -> asJson(request).equals(payload))))
+ .createSvcInstance(objectEqualTo(requestDetails)))
.willReturn(expectedResponse);
// when & then
mockMvc.perform(post("/mso/mso_create_svc_instance")
- .content(payload)
+ .content(asJson(requestDetails))
.contentType(APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().json(asJson(expectedResponse)));
- ArgumentCaptor<RequestDetails> captor = ArgumentCaptor.forClass(RequestDetails.class);
- then(cloudService).should(only()).enrichRequestWithCloudOwner(captor.capture());
- assertThat(captor.getValue()).matches(request -> asJson(request).equals(payload));
+ then(cloudService).should(only()).enrichRequestWithCloudOwner(objectEqualTo(requestDetails));
}
@Test
@@ -133,6 +131,106 @@ public class MsoControllerTest {
then(cloudService).shouldHaveZeroInteractions();
}
+ @Test
+ public void shouldDelegateE2EServiceInstantiation() throws Exception {
+ // given
+ String requestDetails = "some request details";
+ Map<String, Object> payload = new LinkedHashMap<>();
+ payload.put("requestDetails", requestDetails);
+
+ MsoResponseWrapper wrapper = mock(MsoResponseWrapper.class);
+ given(wrapper.getResponse()).willReturn("some response");
+ given(msoBusinessLogic.createE2eSvcInstance(requestDetails)).willReturn(wrapper);
+
+ // when & then
+ mockMvc.perform(post("/mso/mso_create_e2e_svc_instance")
+ .content(asJson(payload))
+ .contentType(APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string("some response"));
+
+ then(cloudService).shouldHaveZeroInteractions();
+ }
+
+ @Test
+ public void shouldDelegateServiceInstantiation() throws Exception {
+ // given
+ RequestDetails requestDetails = modelGenerator.nextObject(RequestDetails.class);
+
+ MsoResponseWrapper wrapper = mock(MsoResponseWrapper.class);
+ given(wrapper.getResponse()).willReturn("some response");
+ given(msoBusinessLogic.createSvcInstance(objectEqualTo(requestDetails))).willReturn(wrapper);
+
+ // when & then
+ mockMvc.perform(post("/mso/mso_create_svc_instance")
+ .content(asJson(requestDetails))
+ .contentType(APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string("some response"));
+
+ then(cloudService).should(only()).enrichRequestWithCloudOwner(objectEqualTo(requestDetails));
+ }
+
+ @Test
+ public void shouldDelegateVnfInstantiation() throws Exception {
+ // given
+ RequestDetails requestDetails = modelGenerator.nextObject(RequestDetails.class);
+ String serviceInstanceId = "bc305d54-75b4-431b-adb2-eb6b9e546014";
+
+ MsoResponseWrapper wrapper = mock(MsoResponseWrapper.class);
+ given(wrapper.getResponse()).willReturn("some response");
+ given(msoBusinessLogic.createVnf(objectEqualTo(requestDetails), eq(serviceInstanceId))).willReturn(wrapper);
+
+ // when & then
+ mockMvc.perform(post("/mso/mso_create_vnf_instance/" + serviceInstanceId)
+ .content(asJson(requestDetails))
+ .contentType(APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string("some response"));
+
+ then(cloudService).should(only()).enrichRequestWithCloudOwner(objectEqualTo(requestDetails));
+ }
+
+ @Test
+ public void shouldDelegateNewInstanceCreation() throws Exception {
+ // given
+ RequestDetails requestDetails = modelGenerator.nextObject(RequestDetails.class);
+ String serviceInstanceId = "bc305d54-75b4-431b-adb2-eb6b9e546014";
+
+ MsoResponseWrapper wrapper = mock(MsoResponseWrapper.class);
+ given(wrapper.getResponse()).willReturn("some response");
+ given(msoBusinessLogic.createNwInstance(objectEqualTo(requestDetails), eq(serviceInstanceId))).willReturn(wrapper);
+
+ // when & then
+ mockMvc.perform(post("/mso/mso_create_nw_instance/" + serviceInstanceId)
+ .content(asJson(requestDetails))
+ .contentType(APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string("some response"));
+
+ then(cloudService).should(only()).enrichRequestWithCloudOwner(objectEqualTo(requestDetails));
+ }
+
+ @Test
+ public void shouldCompleteManualTask() throws Exception {
+ // given
+ RequestDetails requestDetails = modelGenerator.nextObject(RequestDetails.class);
+ String taskId = "bc305d54-75b4-431b-adb2-eb6b9e546014";
+
+ MsoResponseWrapper wrapper = mock(MsoResponseWrapper.class);
+ given(wrapper.getResponse()).willReturn("some response");
+ given(msoBusinessLogic.completeManualTask(objectEqualTo(requestDetails), eq(taskId))).willReturn(wrapper);
+
+ // when & then
+ mockMvc.perform(post("/mso/mso_post_man_task/" + taskId)
+ .content(asJson(requestDetails))
+ .contentType(APPLICATION_JSON))
+ .andExpect(status().isOk())
+ .andExpect(content().string("some response"));
+
+ then(cloudService).shouldHaveZeroInteractions();
+ }
+
private <T> String asJson(T value) {
try {
return objectMapper.writeValueAsString(value);
@@ -140,4 +238,8 @@ public class MsoControllerTest {
throw new RuntimeException(e);
}
}
+
+ private <T> T objectEqualTo(T expected) {
+ return argThat(given -> asJson(given).equals(asJson(expected)));
+ }
} \ No newline at end of file
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
index a7fa8cd13..0efdb6b69 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/MsoBusinessLogicImplTest.java
@@ -92,7 +92,6 @@ import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import static org.onap.vid.controller.MsoController.CONFIGURATION_ID;
import static org.onap.vid.controller.MsoController.REQUEST_TYPE;
import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
@@ -628,26 +627,6 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
}
@Test(expectedExceptions = MsoTestException.class)
- public void shouldThrowExceptionWhenActivateServiceInstanceWithWrongParameters() {
- //given
- RequestDetails requestDetails = new RequestDetails();
- String taskId = "testTaskId";
-
- RestObject<String> restObjStr = new RestObject<>();
- restObjStr.set("");
- MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(restObjStr);
-
- doThrow(new MsoTestException("testException")).
- when(msoInterface).setServiceInstanceStatus(eq(requestDetails), any(String.class), any(String.class), any(String.class), any(RestObject.class));
-
- //when
- MsoResponseWrapper response = msoBusinessLogic.activateServiceInstance(requestDetails, taskId);
-
- //then
- assertThat(response).isEqualToComparingFieldByField(expectedResponse);
- }
-
- @Test(expectedExceptions = MsoTestException.class)
public void shouldThrowExceptionWhenManualTaskWithWrongParameters() {
//given
RequestDetails requestDetails = new RequestDetails();
@@ -1118,38 +1097,34 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
public void shouldProperlySetServiceInstanceStatusActiveWithProperParameters() {
// given
String serviceInstanceId = "testServiceId";
+ MsoResponseWrapper okResponse = createOkResponse();
org.onap.vid.changeManagement.RequestDetails requestDetails = new org.onap.vid.changeManagement.RequestDetails();
- RestObject<String> restObjStr = new RestObject<>();
- restObjStr.set("");
- MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(restObjStr);
+ given(msoInterface.setServiceInstanceStatus(eq(requestDetails), endsWith(serviceInstanceId + "/activate"))).willReturn(okResponse);
// when
MsoResponseWrapper response = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, true);
// then
- assertThat(response).isEqualToComparingFieldByField(expectedResponse);
-
+ assertThat(response).isEqualToComparingFieldByField(okResponse);
}
@Test
public void shouldProperlySetServiceInstanceStatusDeactivateWithProperParameters() {
// given
String serviceInstanceId = "testServiceId";
+ MsoResponseWrapper okResponse = createOkResponse();
org.onap.vid.changeManagement.RequestDetails requestDetails = new org.onap.vid.changeManagement.RequestDetails();
- RestObject<String> restObjStr = new RestObject<>();
- restObjStr.set("");
- MsoResponseWrapper expectedResponse = MsoUtil.wrapResponse(restObjStr);
+ given(msoInterface.setServiceInstanceStatus(eq(requestDetails), endsWith(serviceInstanceId + "/deactivate"))).willReturn(okResponse);
// when
MsoResponseWrapper response = msoBusinessLogic.setServiceInstanceStatus(requestDetails, serviceInstanceId, false);
// then
- assertThat(response).isEqualToComparingFieldByField(expectedResponse);
-
+ assertThat(response).isEqualToComparingFieldByField(okResponse);
}
@Test(expectedExceptions = MsoTestException.class)
@@ -1158,7 +1133,7 @@ public class MsoBusinessLogicImplTest extends AbstractTestNGSpringContextTests {
String serviceInstanceId = "testServiceId";
doThrow(new MsoTestException("testException")).
- when(msoInterface).setServiceInstanceStatus(eq(null), any(String.class), any(String.class), any(String.class), any(RestObject.class));
+ when(msoInterface).setServiceInstanceStatus(eq(null), any(String.class));
// when
msoBusinessLogic.setServiceInstanceStatus(null, serviceInstanceId, true);
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
index 832aa098a..d4abfae38 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientNewTest.java
@@ -20,11 +20,19 @@
*/
package org.onap.vid.mso.rest;
+import static org.apache.commons.io.IOUtils.toInputStream;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import static org.onap.vid.controller.MsoController.SVC_INSTANCE_ID;
import static org.onap.vid.controller.MsoController.VNF_INSTANCE_ID;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xebialabs.restito.server.StubServer;
+import io.joshworks.restclient.http.HttpResponse;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
@@ -413,20 +421,29 @@ public class MsoRestClientNewTest {
}
@Test
- public void testSetServiceInstanceStatus() throws Exception {
- MsoRestClientNew testSubject;
- RequestDetails requestDetails = null;
+ public void testSetServiceInstanceStatus_givenValidResponse_responseIsPopulatedAccordingly() {
+ RequestDetails requestDetails = new RequestDetails();
String t = "";
String sourceId = "";
String endpoint = "";
- RestObject<String> restObject = null;
+ final SyncRestClient client = mock(SyncRestClient.class);
+ MsoRestClientNew testSubject = new MsoRestClientNew(client, "", null, new SystemPropertiesWrapper());
- // default test
- try {
- testSubject = createTestSubject();
- testSubject.setServiceInstanceStatus(requestDetails, t, sourceId, endpoint, restObject);
- } catch (Exception e) {
- }
+ // setup
+ final HttpResponse<String> response = mock(HttpResponse.class);
+ final int expectedStatus = 202;
+ final String expectedResponse = "expected response";
+
+ when(client.post(eq(endpoint), anyMap(), eq(requestDetails), eq(String.class))).thenReturn(response);
+ when(response.getStatus()).thenReturn(expectedStatus);
+ when(response.getBody()).thenReturn(expectedResponse);
+ when(response.getRawBody()).thenReturn(toInputStream(expectedResponse));
+
+ // test
+ MsoResponseWrapper responseWrapper = testSubject.setServiceInstanceStatus(requestDetails, endpoint);
+
+ assertThat(responseWrapper.getStatus(), is(expectedStatus));
+ assertThat(responseWrapper.getEntity(), is(expectedResponse));
}
@Test
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
index 050fa0dce..8ea4836a2 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/MsoRestClientTest.java
@@ -35,11 +35,9 @@ import org.apache.http.ProtocolVersion;
import org.apache.http.StatusLine;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.message.BasicStatusLine;
-import org.jetbrains.annotations.NotNull;
import org.mockito.Mock;
import org.onap.portalsdk.core.util.SystemProperties;
import org.onap.vid.changeManagement.RequestDetailsWrapper;
-import org.onap.vid.changeManagement.RequestParameters;
import org.onap.vid.changeManagement.WorkflowRequestDetail;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.controller.LocalWebConfig;
@@ -49,7 +47,6 @@ import org.onap.vid.mso.MsoResponseWrapper;
import org.onap.vid.mso.MsoResponseWrapperInterface;
import org.onap.vid.mso.MsoUtil;
import org.onap.vid.mso.RestObject;
-import org.onap.vid.mso.model.CloudConfiguration;
import org.onap.vid.mso.model.RequestReferences;
import org.onap.vid.utils.SystemPropertiesWrapper;
import org.springframework.test.context.ContextConfiguration;
@@ -57,9 +54,7 @@ import org.springframework.test.context.web.WebAppConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -664,7 +659,7 @@ public class MsoRestClientTest {
when(client.post(eq(baseUrl + endpoint), anyMap(), eq(requestDetails), eq(String.class))).thenReturn(httpResponse);
// when
- restClient.setServiceInstanceStatus(requestDetails,"", "", endpoint, restObject);
+ restClient.setServiceInstanceStatus(requestDetails, endpoint);
}
@Test( expectedExceptions = MsoTestException.class)
@@ -675,7 +670,7 @@ public class MsoRestClientTest {
when(client.post(eq(baseUrl), anyMap(), eq(null), eq(String.class))).thenThrow(new MsoTestException("test-post-exception"));
// when
- restClient.setServiceInstanceStatus(null,"", "", endpoint, null);
+ restClient.setServiceInstanceStatus(null, endpoint);
}
@Test