diff options
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra')
51 files changed, 2528 insertions, 1153 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java index 974d025ff2..d0302f2e59 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Action.java @@ -22,5 +22,28 @@ package org.onap.so.apihandlerinfra; public enum Action implements Actions { - createInstance, updateInstance, deleteInstance, configureInstance, replaceInstance, replaceInstanceRetainAssignments, activateInstance, deactivateInstance, enablePort, disablePort, addRelationships, removeRelationships, inPlaceSoftwareUpdate, applyUpdatedConfig, completeTask, assignInstance, unassignInstance, compareModel, scaleInstance, deactivateAndCloudDelete, scaleOut, recreateInstance, addMembers, removeMembers + createInstance, + updateInstance, + deleteInstance, + configureInstance, + replaceInstance, + replaceInstanceRetainAssignments, + activateInstance, + deactivateInstance, + enablePort, + disablePort, + addRelationships, + removeRelationships, + inPlaceSoftwareUpdate, + applyUpdatedConfig, + completeTask, + assignInstance, + unassignInstance, + compareModel, + scaleInstance, + deactivateAndCloudDelete, + scaleOut, + recreateInstance, + addMembers, + removeMembers } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java index 3996d511a7..835a24c4ce 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/E2EServiceInstances.java @@ -38,6 +38,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.onap.so.logger.LoggingAnchor; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.json.JSONObject; @@ -228,8 +229,8 @@ public class E2EServiceInstances { Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.SchemaError.getValue(), requestJSON, e); logger.debug(END_OF_THE_TRANSACTION + response.getEntity().toString()); return response; @@ -280,8 +281,8 @@ public class E2EServiceInstances { Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); logger.debug(END_OF_THE_TRANSACTION + resp.getEntity().toString()); return resp; } @@ -306,7 +307,7 @@ public class E2EServiceInstances { try { operationStatus = requestsDbClient.getOneByServiceIdAndOperationId(serviceId, operationId); } catch (Exception e) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Request DB - Infra Request Lookup", e); Response response = @@ -321,8 +322,8 @@ public class E2EServiceInstances { Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NO_CONTENT, MsoException.ServiceException, "E2E serviceId " + serviceId + " is not found in DB", ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.BusinessProcesssError.getValue(), + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcesssError.getValue(), "Null response from RequestDB when searching by serviceId"); logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); return resp; @@ -350,8 +351,8 @@ public class E2EServiceInstances { Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.SchemaError.getValue(), requestJSON, e); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -375,8 +376,8 @@ public class E2EServiceInstances { return response; } if (recipeLookupResult == null) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.DataError.getValue(), "No recipe found in DB"); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB"); Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, "Recipe does not exist in catalog DB", ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); @@ -414,8 +415,9 @@ public class E2EServiceInstances { Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), "Exception while communicate with BPMN engine"); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), + "Exception while communicate with BPMN engine"); logger.debug("End of the transaction, the final response is: " + resp.getEntity()); return resp; } @@ -424,8 +426,8 @@ public class E2EServiceInstances { Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); return resp; } @@ -455,8 +457,8 @@ public class E2EServiceInstances { Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.SchemaError.getValue(), requestJSON, e); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -473,8 +475,8 @@ public class E2EServiceInstances { if (requestId != null) { logger.debug("Logging failed message to the database"); } - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.SchemaError.getValue(), requestJSON, e); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -483,7 +485,7 @@ public class E2EServiceInstances { try { recipeLookupResult = getServiceInstanceOrchestrationURI(e2eSir.getService().getServiceUuid(), action); } catch (Exception e) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), @@ -495,8 +497,8 @@ public class E2EServiceInstances { } if (recipeLookupResult == null) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.DataError.getValue(), "No recipe found in DB"); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB"); Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, "Recipe does not exist in catalog DB", ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); @@ -530,8 +532,9 @@ public class E2EServiceInstances { MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), "Exception while communicate with BPMN engine"); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), + "Exception while communicate with BPMN engine"); logger.debug(END_OF_THE_TRANSACTION + getBPMNResp.getEntity()); return getBPMNResp; @@ -541,8 +544,8 @@ public class E2EServiceInstances { Response getBPMNResp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); logger.debug(END_OF_THE_TRANSACTION + getBPMNResp.getEntity()); return getBPMNResp; } @@ -572,8 +575,8 @@ public class E2EServiceInstances { Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.SchemaError.getValue(), requestJSON, e); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -590,8 +593,8 @@ public class E2EServiceInstances { if (requestId != null) { logger.debug("Logging failed message to the database"); } - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.SchemaError.getValue(), requestJSON, e); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -600,7 +603,7 @@ public class E2EServiceInstances { try { recipeLookupResult = getServiceInstanceOrchestrationURI(e2eSir.getService().getServiceUuid(), action); } catch (Exception e) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(), @@ -610,8 +613,8 @@ public class E2EServiceInstances { } if (recipeLookupResult == null) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.DataError.getValue(), "No recipe found in DB"); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB"); Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, "Recipe does not exist in catalog DB", ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null, version); @@ -644,8 +647,9 @@ public class E2EServiceInstances { MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), "Exception while communicate with BPMN engine"); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), + "Exception while communicate with BPMN engine"); logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); return resp; } @@ -654,8 +658,8 @@ public class E2EServiceInstances { Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); return resp; } @@ -684,8 +688,8 @@ public class E2EServiceInstances { Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST, MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.SchemaError.getValue(), requestJSON, e); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_REQUEST_VALIDATION_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.SchemaError.getValue(), requestJSON, e); logger.debug(END_OF_THE_TRANSACTION + response.getEntity()); return response; } @@ -695,7 +699,7 @@ public class E2EServiceInstances { // TODO Get the service template model version uuid from AAI. recipeLookupResult = getServiceInstanceOrchestrationURI(null, action); } catch (Exception e) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), "Exception while communciate with Catalog DB", e); Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, @@ -708,8 +712,8 @@ public class E2EServiceInstances { return response; } if (recipeLookupResult == null) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.DataError.getValue(), "No recipe found in DB"); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.DataError.getValue(), "No recipe found in DB"); Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, "Recipe does not exist in catalog DB", @@ -747,8 +751,9 @@ public class E2EServiceInstances { MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(), ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.AvailabilityError.getValue(), "Exception while communicate with BPMN engine", e); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.AvailabilityError.getValue(), + "Exception while communicate with BPMN engine", e); logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); return resp; } @@ -757,8 +762,8 @@ public class E2EServiceInstances { Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), MSO_PROP_APIHANDLER_INFRA, - ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_COMMUNICATE_ERROR.toString(), + MSO_PROP_APIHANDLER_INFRA, ErrorCode.BusinessProcesssError.getValue(), "Null response from BPEL"); logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); return resp; } @@ -790,8 +795,8 @@ public class E2EServiceInstances { Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException, "Request Failed due to BPEL error with HTTP Status= %1 " + '\n' + camundaJSONResponseBody, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables, version); - logger.error("{} {} {} {}", MessageEnum.APIH_BPEL_RESPONSE_ERROR.toString(), requestClient.getUrl(), - ErrorCode.BusinessProcesssError.getValue(), + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_BPEL_RESPONSE_ERROR.toString(), + requestClient.getUrl(), ErrorCode.BusinessProcesssError.getValue(), "Response from BPEL engine is failed with HTTP Status=" + bpelStatus); logger.debug(END_OF_THE_TRANSACTION + resp.getEntity()); return resp; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java index 4d283f26b1..3d4b2c76fb 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java @@ -25,6 +25,7 @@ package org.onap.so.apihandlerinfra; import java.net.URI; import java.util.Collections; +import org.onap.so.logger.LoggingAnchor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; @@ -112,7 +113,7 @@ public class GlobalHealthcheckHandler { try { // Generated RequestId String requestId = requestContext.getProperty("requestId").toString(); - logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); + logger.info(LoggingAnchor.TWO, MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); // set APIH status, this is the main entry point rsp.setApih(HealthcheckStatus.UP.toString()); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java index c1f55c7555..c582e429ff 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/InstanceManagement.java @@ -253,7 +253,7 @@ public class InstanceManagement { if (workflow == null) { return null; } else { - String workflowName = workflow.getArtifactName(); + String workflowName = workflow.getName(); recipeUri = "/mso/async/services/" + workflowName; } return new RecipeLookupResult(recipeUri, 180); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java index 3c06804594..47f978a9e2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java @@ -34,6 +34,7 @@ import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.onap.so.logger.LoggingAnchor; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; @@ -91,7 +92,7 @@ public class ManualTasks { @PathParam("taskId") String taskId, @Context ContainerRequestContext requestContext) throws ApiException { String requestId = requestContext.getProperty("requestId").toString(); - logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); + logger.info(LoggingAnchor.TWO, MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); long startTime = System.currentTimeMillis(); logger.debug("requestId is: {}", requestId); TasksRequest taskRequest = null; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java index 401a6a9db6..45b521d984 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java @@ -44,13 +44,13 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandlerinfra.tasksbeans.TasksRequest; -import org.onap.so.apihandlerinfra.validation.MembersValidation; import org.onap.so.apihandlerinfra.validation.ApplyUpdatedConfigValidation; import org.onap.so.apihandlerinfra.validation.CloudConfigurationValidation; import org.onap.so.apihandlerinfra.validation.ConfigurationParametersValidation; import org.onap.so.apihandlerinfra.validation.CustomWorkflowValidation; import org.onap.so.apihandlerinfra.validation.InPlaceSoftwareUpdateValidation; import org.onap.so.apihandlerinfra.validation.InstanceIdMapValidation; +import org.onap.so.apihandlerinfra.validation.MembersValidation; import org.onap.so.apihandlerinfra.validation.ModelInfoValidation; import org.onap.so.apihandlerinfra.validation.PlatformLOBValidation; import org.onap.so.apihandlerinfra.validation.ProjectOwningEntityValidation; @@ -68,9 +68,7 @@ import org.onap.so.apihandlerinfra.vnfbeans.VnfRequest; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; -import org.onap.so.logger.ErrorCode; import org.onap.so.logger.LogConstants; -import org.onap.so.logger.MessageEnum; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.InstanceDirection; import org.onap.so.serviceinstancebeans.ModelInfo; @@ -151,8 +149,7 @@ public class MsoRequest { mapper.setSerializationInclusion(Include.NON_DEFAULT); requestErrorStr = mapper.writeValueAsString(re); } catch (Exception e) { - logger.error("{} {} {}", MessageEnum.APIH_VALIDATION_ERROR.toString(), ErrorCode.DataError.getValue(), - "Exception in buildServiceErrorResponse writing exceptionType to string ", e); + logger.error("Exception in buildServiceErrorResponse writing exceptionType to string ", e); } return builder.buildResponse(httpResponseCode, null, requestErrorStr, version); @@ -396,8 +393,7 @@ public class MsoRequest { aq.setRequestStatus(status.toString()); aq.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); } catch (Exception e) { - logger.error("{} {} {}", MessageEnum.APIH_DB_INSERT_EXC.toString(), ErrorCode.DataError.getValue(), - "Exception when creation record request", e); + logger.error("Exception when creation record request", e); if (!status.equals(Status.FAILED)) { throw e; @@ -437,8 +433,7 @@ public class MsoRequest { aq.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); } catch (Exception e) { - logger.error("{} {} {}", MessageEnum.APIH_DB_INSERT_EXC.toString(), ErrorCode.DataError.getValue(), - "Exception when creation record request", e); + logger.error("Exception when creation record request", e); if (!status.equals(Status.FAILED)) { throw e; @@ -465,8 +460,7 @@ public class MsoRequest { request.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); requestsDbClient.save(request); } catch (Exception e) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_UPDATE_EXC.toString(), e.getMessage(), - ErrorCode.DataError.getValue(), "Exception when updating record in DB"); + logger.error("Exception when updating record in DB", e); logger.debug("Exception: ", e); } } @@ -547,8 +541,7 @@ public class MsoRequest { return null; } catch (Exception e) { - logger.error("{} {} {}", MessageEnum.APIH_DOM2STR_ERROR.toString(), ErrorCode.DataError.getValue(), - "Exception in domToStr", e); + logger.error("Exception in domToStr", e); } return null; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoSubsystems.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoSubsystems.java index fd0df1d2b0..13f1e52068 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoSubsystems.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoSubsystems.java @@ -20,9 +20,14 @@ package org.onap.so.apihandlerinfra; public enum MsoSubsystems { - APIH("API Handler"), ASDC("ASDC Controller"), BPMN("BPMN Infra"), CATALOGDB("CatalogDb Adapter"), OPENSTACK( - "Openstack Adapter"), REQUESTDB( - "RequestDB Adapter"), REQUESTDBATT("RequestDB Adapter ATT Svc"), SDNC("SDNC Adapter"); + APIH("API Handler"), + ASDC("ASDC Controller"), + BPMN("BPMN Infra"), + CATALOGDB("CatalogDb Adapter"), + OPENSTACK("Openstack Adapter"), + REQUESTDB("RequestDB Adapter"), + REQUESTDBATT("RequestDB Adapter ATT Svc"), + SDNC("SDNC Adapter"); private String subsystem; private MsoSubsystems(String subsystem) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java index 9810895ad9..3337c62afd 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java @@ -30,6 +30,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; +import org.onap.so.logger.LoggingAnchor; import org.apache.http.HttpStatus; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; @@ -57,7 +58,7 @@ public class NodeHealthcheckHandler { public Response nodeHealthcheck(@Context ContainerRequestContext requestContext) throws UnknownHostException { // Generated RequestId String requestId = requestContext.getProperty("requestId").toString(); - logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); + logger.info(LoggingAnchor.TWO, MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); return HEALTH_CHECK_RESPONSE; } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index ff8b5d14cd..e14b01792a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java @@ -290,7 +290,7 @@ public class OrchestrationRequests { return Response.status(HttpStatus.SC_NO_CONTENT).entity("").build(); } - private Request mapInfraActiveRequestToRequest(InfraActiveRequests iar, boolean includeCloudRequest) + protected Request mapInfraActiveRequestToRequest(InfraActiveRequests iar, boolean includeCloudRequest) throws ApiException { String requestBody = iar.getRequestBody(); Request request = new Request(); @@ -304,6 +304,11 @@ public class OrchestrationRequests { String flowStatusMessage = iar.getFlowStatus(); String retryStatusMessage = iar.getRetryStatusMessage(); + String originalRequestId = iar.getOriginalRequestId(); + if (originalRequestId != null) { + request.setOriginalRequestId(originalRequestId); + } + InstanceReferences ir = new InstanceReferences(); if (iar.getNetworkId() != null) ir.setNetworkInstanceId(iar.getNetworkId()); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java index f6fc88d559..f88d244a88 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -52,6 +52,7 @@ import org.onap.so.apihandler.common.RequestClientFactory; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandler.common.ResponseHandler; +import org.onap.so.apihandlerinfra.TestApi; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException; @@ -59,7 +60,9 @@ import org.onap.so.apihandlerinfra.exceptions.ContactCamundaException; import org.onap.so.apihandlerinfra.exceptions.DuplicateRequestException; import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; +import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException; import org.onap.so.apihandlerinfra.logging.ErrorLoggerInfo; +import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; @@ -67,6 +70,7 @@ import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.LogConstants; import org.onap.so.logger.MessageEnum; +import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.RelatedInstance; import org.onap.so.serviceinstancebeans.RelatedInstanceList; @@ -621,7 +625,8 @@ public class RequestHandlerUtils { } protected InfraActiveRequests createNewRecordCopyFromInfraActiveRequest(InfraActiveRequests infraActiveRequest, - String requestId, Timestamp startTimeStamp, String source, String requestUri, String requestorId) { + String requestId, Timestamp startTimeStamp, String source, String requestUri, String requestorId, + String originalRequestId) { InfraActiveRequests request = new InfraActiveRequests(); request.setRequestId(requestId); request.setStartTime(startTimeStamp); @@ -630,17 +635,83 @@ public class RequestHandlerUtils { request.setProgress(new Long(5)); request.setRequestorId(requestorId); request.setRequestStatus(Status.IN_PROGRESS.toString()); + request.setOriginalRequestId(originalRequestId); request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); if (infraActiveRequest != null) { request.setTenantId(infraActiveRequest.getTenantId()); - request.setRequestBody(infraActiveRequest.getRequestBody()); + request.setRequestBody(updateRequestorIdInRequestBody(infraActiveRequest, requestorId)); request.setAicCloudRegion(infraActiveRequest.getAicCloudRegion()); request.setRequestScope(infraActiveRequest.getRequestScope()); - request.setServiceInstanceId(infraActiveRequest.getServiceInstanceId()); - request.setServiceInstanceName(infraActiveRequest.getServiceInstanceName()); request.setRequestAction(infraActiveRequest.getRequestAction()); + setInstanceIdAndName(infraActiveRequest, request); } return request; } + protected void setInstanceIdAndName(InfraActiveRequests infraActiveRequest, + InfraActiveRequests currentActiveRequest) { + String requestScope = infraActiveRequest.getRequestScope(); + try { + ModelType type = ModelType.valueOf(requestScope); + type.setName(currentActiveRequest, type.getName(infraActiveRequest)); + type.setId(currentActiveRequest, type.getId(infraActiveRequest)); + } catch (IllegalArgumentException e) { + logger.error( + "requestScope \"{}\" does not match a ModelType enum. Unable to set instanceId and instanceName from the original request.", + requestScope); + } + } + + protected Boolean getIsBaseVfModule(ModelInfo modelInfo, Actions action, String vnfType, + String sdcServiceModelVersion, InfraActiveRequests currentActiveReq) throws ApiException { + // Get VF Module-specific base module indicator + VfModule vfm = null; + String modelVersionId = modelInfo.getModelVersionId(); + Boolean isBaseVfModule = false; + + if (modelVersionId != null) { + vfm = catalogDbClient.getVfModuleByModelUUID(modelVersionId); + } else if (modelInfo.getModelInvariantId() != null && modelInfo.getModelVersion() != null) { + vfm = catalogDbClient.getVfModuleByModelInvariantUUIDAndModelVersion(modelInfo.getModelInvariantId(), + modelInfo.getModelVersion()); + } + + if (vfm != null) { + if (vfm.getIsBase()) { + isBaseVfModule = true; + } + } else if (action == Action.createInstance || action == Action.updateInstance) { + String serviceVersionText = ""; + if (sdcServiceModelVersion != null && !sdcServiceModelVersion.isEmpty()) { + serviceVersionText = " with version " + sdcServiceModelVersion; + } + String errorMessage = "VnfType " + vnfType + " and VF Module Model Name " + modelInfo.getModelName() + + serviceVersionText + " not found in MSO Catalog DB"; + ErrorLoggerInfo errorLoggerInfo = + new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError) + .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder(errorMessage, + HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build(); + updateStatus(currentActiveReq, Status.FAILED, vfModuleException.getMessage()); + throw vfModuleException; + } + return isBaseVfModule; + } + + protected ModelType getModelType(Actions action, ModelInfo modelInfo) { + if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) { + return ModelType.vnf; + } else if (action == Action.addMembers || action == Action.removeMembers) { + return ModelType.instanceGroup; + } else { + return modelInfo.getModelType(); + } + } + + protected String updateRequestorIdInRequestBody(InfraActiveRequests infraActiveRequest, String newRequestorId) { + String requestBody = infraActiveRequest.getRequestBody(); + return requestBody.replaceAll( + "(?s)(\"requestInfo\"\\s*?:\\s*?\\{.*?\"requestorId\"\\s*?:\\s*?\")(.*?)(\"[ ]*(?:,|\\R|\\}))", + "$1" + newRequestorId + "$3"); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java index 6ca23a339b..32d2c50978 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequest.java @@ -47,6 +47,8 @@ import org.onap.so.logger.HttpHeadersConstants; import org.onap.so.logger.LogConstants; import org.onap.so.logger.MdcConstants; import org.onap.so.logger.MessageEnum; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -74,6 +76,8 @@ public class ResumeOrchestrationRequest { @Autowired private RequestsDbClient requestsDbClient; + @Autowired + private MsoRequest msoRequest; @POST @Path("/{version:[vV][7]}/requests/{requestId}/resume") @@ -106,7 +110,7 @@ public class ResumeOrchestrationRequest { } InfraActiveRequests currentActiveRequest = requestHandlerUtils.createNewRecordCopyFromInfraActiveRequest( - infraActiveRequest, currentRequestId, startTimeStamp, source, requestUri, requestorId); + infraActiveRequest, currentRequestId, startTimeStamp, source, requestUri, requestorId, requestId); if (infraActiveRequest == null) { logger.error("No infraActiveRequest record found for requestId: {} in requesteDb lookup", requestId); @@ -128,24 +132,26 @@ public class ResumeOrchestrationRequest { String requestBody = infraActiveRequest.getRequestBody(); Action action = Action.valueOf(infraActiveRequest.getRequestAction()); String requestId = currentActiveRequest.getRequestId(); - String serviceInstanceName = infraActiveRequest.getServiceInstanceName(); String requestScope = infraActiveRequest.getRequestScope(); - String serviceInstanceId = infraActiveRequest.getServiceInstanceId(); + String instanceName = getInstanceName(infraActiveRequest, requestScope, currentActiveRequest); + HashMap<String, String> instanceIdMap = setInstanceIdMap(infraActiveRequest, requestScope); - checkForInProgressRequest(currentActiveRequest, serviceInstanceId, requestScope, serviceInstanceName, action); + checkForInProgressRequest(currentActiveRequest, instanceIdMap, requestScope, instanceName, action); ServiceInstancesRequest sir = null; sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestBody, action, requestId, requestUri); Boolean aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte(); - if (aLaCarte == null) { - aLaCarte = false; - } String pnfCorrelationId = serviceInstances.getPnfCorrelationId(sir); - RecipeLookupResult recipeLookupResult = serviceRecipeLookup(currentActiveRequest, sir, action, aLaCarte); + RecipeLookupResult recipeLookupResult = serviceInstances.getServiceInstanceOrchestrationURI(sir, action, + msoRequest.getAlacarteFlag(sir), currentActiveRequest); requestDbSave(currentActiveRequest); + if (aLaCarte == null) { + aLaCarte = setALaCarteFlagIfNull(requestScope, action); + } + RequestClientParameter requestClientParameter = setRequestClientParameter(recipeLookupResult, version, infraActiveRequest, currentActiveRequest, pnfCorrelationId, aLaCarte, sir); @@ -153,40 +159,60 @@ public class ResumeOrchestrationRequest { recipeLookupResult.getOrchestrationURI(), requestScope); } - protected void checkForInProgressRequest(InfraActiveRequests currentActiveRequest, String serviceInstanceId, - String requestScope, String serviceInstanceName, Action action) throws ApiException { - boolean inProgress = false; - HashMap<String, String> instanceIdMap = new HashMap<>(); - instanceIdMap.put("serviceInstanceId", serviceInstanceId); - InfraActiveRequests requestInProgress = requestHandlerUtils.duplicateCheck(action, instanceIdMap, - serviceInstanceName, requestScope, currentActiveRequest); - if (requestInProgress != null) { - inProgress = requestHandlerUtils.camundaHistoryCheck(requestInProgress, currentActiveRequest); + protected Boolean setALaCarteFlagIfNull(String requestScope, Action action) { + Boolean aLaCarteFlag; + if (!requestScope.equalsIgnoreCase(ModelType.service.name()) && action != Action.recreateInstance) { + aLaCarteFlag = true; + } else { + aLaCarteFlag = false; } - if (inProgress) { - requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveRequest, action, instanceIdMap, - serviceInstanceName, requestScope, requestInProgress); + return aLaCarteFlag; + } + + protected HashMap<String, String> setInstanceIdMap(InfraActiveRequests infraActiveRequest, String requestScope) { + HashMap<String, String> instanceIdMap = new HashMap<>(); + ModelType type; + try { + type = ModelType.valueOf(requestScope); + instanceIdMap.put(type.name() + "InstanceId", type.getId(infraActiveRequest)); + } catch (IllegalArgumentException e) { + logger.error("requestScope \"{}\" does not match a ModelType enum.", requestScope); } + return instanceIdMap; } - protected RecipeLookupResult serviceRecipeLookup(InfraActiveRequests currentActiveRequest, - ServiceInstancesRequest sir, Action action, Boolean aLaCarte) - throws ValidateException, RequestDbFailureException { - RecipeLookupResult recipeLookupResult = null; + protected String getInstanceName(InfraActiveRequests infraActiveRequest, String requestScope, + InfraActiveRequests currentActiveRequest) throws ValidateException, RequestDbFailureException { + ModelType type; + String instanceName = ""; try { - recipeLookupResult = serviceInstances.getServiceURI(sir, action, aLaCarte); - } catch (IOException e) { - logger.error("IOException while performing service recipe lookup", e); - ErrorLoggerInfo errorLoggerInfo = - new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError) - .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - ValidateException validateException = - new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, - ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); + type = ModelType.valueOf(requestScope); + instanceName = type.getName(infraActiveRequest); + } catch (IllegalArgumentException e) { + logger.error("requestScope \"{}\" does not match a ModelType enum.", requestScope); + ValidateException validateException = new ValidateException.Builder( + "requestScope: \"" + requestScope + "\" from request: " + infraActiveRequest.getRequestId() + + " does not match a ModelType enum.", + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).build(); requestHandlerUtils.updateStatus(currentActiveRequest, Status.FAILED, validateException.getMessage()); throw validateException; } - return recipeLookupResult; + return instanceName; + } + + protected void checkForInProgressRequest(InfraActiveRequests currentActiveRequest, + HashMap<String, String> instanceIdMap, String requestScope, String instanceName, Action action) + throws ApiException { + boolean inProgress = false; + InfraActiveRequests requestInProgress = requestHandlerUtils.duplicateCheck(action, instanceIdMap, instanceName, + requestScope, currentActiveRequest); + if (requestInProgress != null) { + inProgress = requestHandlerUtils.camundaHistoryCheck(requestInProgress, currentActiveRequest); + } + if (inProgress) { + requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveRequest, action, instanceIdMap, instanceName, + requestScope, requestInProgress); + } } protected void requestDbSave(InfraActiveRequests currentActiveRequest) throws RequestDbFailureException { @@ -204,23 +230,37 @@ public class ResumeOrchestrationRequest { protected RequestClientParameter setRequestClientParameter(RecipeLookupResult recipeLookupResult, String version, InfraActiveRequests infraActiveRequest, InfraActiveRequests currentActiveRequest, String pnfCorrelationId, - Boolean aLaCarte, ServiceInstancesRequest sir) throws ValidateException { + Boolean aLaCarte, ServiceInstancesRequest sir) throws ApiException { RequestClientParameter requestClientParameter = null; + Action action = Action.valueOf(infraActiveRequest.getRequestAction()); + ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); + + Boolean isBaseVfModule = false; + if (requestHandlerUtils.getModelType(action, modelInfo).equals(ModelType.vfModule)) { + isBaseVfModule = requestHandlerUtils.getIsBaseVfModule(modelInfo, action, infraActiveRequest.getVnfType(), + msoRequest.getSDCServiceModelVersion(sir), currentActiveRequest); + } + try { - requestClientParameter = new RequestClientParameter.Builder() - .setRequestId(currentActiveRequest.getRequestId()) - .setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) - .setRequestAction(infraActiveRequest.getRequestAction()) - .setServiceInstanceId(infraActiveRequest.getServiceInstanceId()) - .setPnfCorrelationId(pnfCorrelationId).setVnfId(infraActiveRequest.getVnfId()) - .setVfModuleId(infraActiveRequest.getVfModuleId()) - .setVolumeGroupId(infraActiveRequest.getVolumeGroupId()) - .setNetworkId(infraActiveRequest.getNetworkId()).setServiceType(infraActiveRequest.getServiceType()) - .setVnfType(infraActiveRequest.getVnfType()).setNetworkType(infraActiveRequest.getNetworkType()) - .setRequestDetails(requestHandlerUtils.mapJSONtoMSOStyle(infraActiveRequest.getRequestBody(), sir, - aLaCarte, Action.valueOf(infraActiveRequest.getRequestAction()))) - .setApiVersion(version).setALaCarte(aLaCarte).setRequestUri(currentActiveRequest.getRequestUrl()) - .setInstanceGroupId(infraActiveRequest.getInstanceGroupId()).build(); + requestClientParameter = + new RequestClientParameter.Builder().setRequestId(currentActiveRequest.getRequestId()) + .setBaseVfModule(isBaseVfModule).setRecipeTimeout(recipeLookupResult.getRecipeTimeout()) + .setRequestAction(infraActiveRequest.getRequestAction()) + .setServiceInstanceId(infraActiveRequest.getServiceInstanceId()) + .setPnfCorrelationId(pnfCorrelationId).setVnfId(infraActiveRequest.getVnfId()) + .setVfModuleId(infraActiveRequest.getVfModuleId()) + .setVolumeGroupId(infraActiveRequest.getVolumeGroupId()) + .setNetworkId(infraActiveRequest.getNetworkId()) + .setServiceType(infraActiveRequest.getServiceType()) + .setVnfType(infraActiveRequest.getVnfType()) + .setVfModuleType(msoRequest.getVfModuleType(sir, infraActiveRequest.getRequestScope(), + action, Integer.parseInt(version))) + .setNetworkType(infraActiveRequest.getNetworkType()) + .setRequestDetails(requestHandlerUtils + .mapJSONtoMSOStyle(infraActiveRequest.getRequestBody(), sir, aLaCarte, action)) + .setApiVersion(version).setALaCarte(aLaCarte) + .setRequestUri(currentActiveRequest.getRequestUrl()) + .setInstanceGroupId(infraActiveRequest.getInstanceGroupId()).build(); } catch (IOException e) { logger.error("IOException while generating requestClientParameter to send to BPMN", e); ErrorLoggerInfo errorLoggerInfo = diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index 45319de5e8..a397676ee2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -203,7 +203,7 @@ public class ServiceInstances { @PathParam("serviceInstanceId") String serviceInstanceId, @Context ContainerRequestContext requestContext) throws ApiException { String requestId = requestHandlerUtils.getRequestId(requestContext); - HashMap<String, String> instanceIdMap = new HashMap<String, String>(); + HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put("serviceInstanceId", serviceInstanceId); return serviceInstances(request, Action.unassignInstance, instanceIdMap, version, requestId, requestHandlerUtils.getRequestUri(requestContext, uriPrefix)); @@ -759,10 +759,9 @@ public class ServiceInstances { public Response serviceInstances(String requestJSON, Actions action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException { - String serviceInstanceId = (instanceIdMap == null) ? null : instanceIdMap.get("serviceInstanceId"); + String serviceInstanceId; Boolean aLaCarte = null; - long startTime = System.currentTimeMillis(); - ServiceInstancesRequest sir = null; + ServiceInstancesRequest sir; String apiVersion = version.substring(1); sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); @@ -814,64 +813,20 @@ public class ServiceInstances { referencesResponse.setRequestId(requestId); serviceResponse.setRequestReferences(referencesResponse); - Boolean isBaseVfModule = false; - RecipeLookupResult recipeLookupResult = getServiceInstanceOrchestrationURI(sir, action, alaCarteFlag, currentActiveReq); String serviceInstanceType = requestHandlerUtils.getServiceType(requestScope, sir, alaCarteFlag); - ModelType modelType; - ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); - if (action == Action.applyUpdatedConfig || action == Action.inPlaceSoftwareUpdate) { - modelType = ModelType.vnf; - } else if (action == Action.addMembers || action == Action.removeMembers) { - modelType = ModelType.instanceGroup; - } else { - modelType = modelInfo.getModelType(); - } - - if (modelType.equals(ModelType.vfModule)) { - - - // Get VF Module-specific base module indicator - VfModule vfm = null; - - String modelVersionId = modelInfo.getModelVersionId(); - if (modelVersionId != null) { - vfm = catalogDbClient.getVfModuleByModelUUID(modelVersionId); - } else if (modelInfo.getModelInvariantId() != null && modelInfo.getModelVersion() != null) { - vfm = catalogDbClient.getVfModuleByModelInvariantUUIDAndModelVersion(modelInfo.getModelInvariantId(), - modelInfo.getModelVersion()); - } - - if (vfm != null) { - if (vfm.getIsBase()) { - isBaseVfModule = true; - } - } else if (action == Action.createInstance || action == Action.updateInstance) { - // There is no entry for this vfModuleType with this version, if specified, in VF_MODULE table in - // Catalog DB. - // This request cannot proceed - - String serviceVersionText = ""; - if (sdcServiceModelVersion != null && !sdcServiceModelVersion.isEmpty()) { - serviceVersionText = " with version " + sdcServiceModelVersion; - } + ModelInfo modelInfo = sir.getRequestDetails().getModelInfo(); + ModelType modelType = requestHandlerUtils.getModelType(action, modelInfo); - String errorMessage = "VnfType " + vnfType + " and VF Module Model Name " + modelInfo.getModelName() - + serviceVersionText + " not found in MSO Catalog DB"; - ErrorLoggerInfo errorLoggerInfo = - new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, ErrorCode.DataError) - .errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); - VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder(errorMessage, - HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build(); - requestHandlerUtils.updateStatus(currentActiveReq, Status.FAILED, vfModuleException.getMessage()); + Boolean isBaseVfModule = false; - throw vfModuleException; - } + if (modelType.equals(ModelType.vfModule)) { + isBaseVfModule = requestHandlerUtils.getIsBaseVfModule(modelInfo, action, vnfType, sdcServiceModelVersion, + currentActiveReq); } - serviceInstanceId = requestHandlerUtils.setServiceInstanceId(requestScope, sir); String vnfId = ""; String vfModuleId = ""; @@ -958,7 +913,6 @@ public class ServiceInstances { String requestId, String requestUri, ContainerRequestContext requestContext) throws ApiException { String instanceGroupId = instanceIdMap.get(CommonConstants.INSTANCE_GROUP_INSTANCE_ID); Boolean aLaCarte = true; - long startTime = System.currentTimeMillis(); String apiVersion = version.substring(1); ServiceInstancesRequest sir = new ServiceInstancesRequest(); sir.setInstanceGroupId(instanceGroupId); @@ -1030,7 +984,7 @@ public class ServiceInstances { .orElse(""); } - private RecipeLookupResult getServiceInstanceOrchestrationURI(ServiceInstancesRequest sir, Actions action, + protected RecipeLookupResult getServiceInstanceOrchestrationURI(ServiceInstancesRequest sir, Actions action, boolean alaCarteFlag, InfraActiveRequests currentActiveReq) throws ApiException { RecipeLookupResult recipeLookupResult = null; // if the aLaCarte flag is set to TRUE, the API-H should choose the VID_DEFAULT recipe for the requested action @@ -1275,8 +1229,7 @@ public class ServiceInstances { return mapFlatMapToNameValue(userParams); } - private Service serviceMapper(Map<String, Object> params) - throws JsonProcessingException, IOException, JsonParseException, JsonMappingException { + private Service serviceMapper(Map<String, Object> params) throws IOException { ObjectMapper obj = new ObjectMapper(); String input = obj.writeValueAsString(params.get("service")); return obj.readValue(input, Service.class); @@ -1313,7 +1266,7 @@ public class ServiceInstances { instanceList = servInstReq.getRequestDetails().getRelatedInstanceList(); } - Recipe recipe = null; + Recipe recipe; String defaultSource = requestHandlerUtils.getDefaultModel(servInstReq); String modelCustomizationId = modelInfo.getModelCustomizationId(); String modelCustomizationName = modelInfo.getModelCustomizationName(); @@ -1603,13 +1556,11 @@ public class ServiceInstances { private Response configurationRecipeLookup(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version, String requestId, String requestUri) throws ApiException { - String serviceInstanceId = (instanceIdMap == null) ? null : instanceIdMap.get("serviceInstanceId"); + String serviceInstanceId; Boolean aLaCarte = null; String apiVersion = version.substring(1); boolean inProgress = false; - - long startTime = System.currentTimeMillis(); - ServiceInstancesRequest sir = null; + ServiceInstancesRequest sir; sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestJSON, action, requestId, requestUri); String requestScope = requestHandlerUtils.deriveRequestScope(action, sir, requestUri); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java index c480bdfbd3..bba8064f7c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandler.java @@ -50,6 +50,8 @@ import org.onap.so.db.catalog.beans.WorkflowActivitySpecSequence; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonProcessingException; @@ -69,7 +71,9 @@ public class WorkflowSpecificationsHandler { @Autowired private CatalogDbClient catalogDbClient; + private static Logger logger = LoggerFactory.getLogger(WorkflowSpecificationsHandler.class); private static final String ARTIFACT_TYPE_WORKFLOW = "workflow"; + private static final String NATIVE_WORKFLOW = "native"; @Path("/{version:[vV]1}/workflows") @GET @@ -85,6 +89,12 @@ public class WorkflowSpecificationsHandler { mapper1.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); List<Workflow> workflows = catalogDbClient.findWorkflowByModelUUID(vnfModelVersionId); + + List<Workflow> nativeWorkflows = catalogDbClient.findWorkflowBySource(NATIVE_WORKFLOW); + if (nativeWorkflows != null && nativeWorkflows.size() != 0) { + workflows.addAll(nativeWorkflows); + } + WorkflowSpecifications workflowSpecifications = mapWorkflowsToWorkflowSpecifications(workflows); String jsonResponse = null; @@ -153,6 +163,7 @@ public class WorkflowSpecificationsHandler { if (activitySpec != null) { ActivitySequence activitySequence = new ActivitySequence(); activitySequence.setName(activitySpec.getName()); + logger.debug("Adding activity: " + activitySpec.getName()); activitySequence.setDescription(activitySpec.getDescription()); activitySequences.add(activitySequence); } @@ -164,7 +175,7 @@ public class WorkflowSpecificationsHandler { private List<WorkflowInputParameter> buildWorkflowInputParameters(Workflow workflow) { List<WorkflowActivitySpecSequence> workflowActivitySpecSequences = workflow.getWorkflowActivitySpecSequence(); if (workflowActivitySpecSequences == null || workflowActivitySpecSequences.size() == 0) { - return null; + return new ArrayList<WorkflowInputParameter>(); } Map<String, WorkflowInputParameter> workflowInputParameterMap = new HashMap<String, WorkflowInputParameter>(); for (WorkflowActivitySpecSequence workflowActivitySpecSequence : workflowActivitySpecSequences) { @@ -188,7 +199,7 @@ public class WorkflowSpecificationsHandler { } if (workflowInputParameterMap.size() == 0) { - return null; + return new ArrayList<WorkflowInputParameter>(); } List<WorkflowInputParameter> workflowInputParameterList = workflowInputParameterMap.values().stream().collect(Collectors.toList()); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java index d79d73c036..e8d00ed52b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java @@ -38,6 +38,7 @@ import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.onap.so.logger.LoggingAnchor; import org.apache.http.HttpStatus; import org.onap.so.apihandler.common.ErrorNumbers; import org.onap.so.apihandlerinfra.Constants; @@ -125,7 +126,7 @@ public class CloudOrchestration { private Response cloudOrchestration(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version, String requestId) throws ApiException { - logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); + logger.info(LoggingAnchor.TWO, MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); long startTime = System.currentTimeMillis(); CloudOrchestrationRequest cor = null; tenantIsolationRequest.setRequestId(requestId); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java index be6d5b06ca..20e8fed32d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java @@ -92,7 +92,7 @@ public class CloudResourcesOrchestration { CloudOrchestrationRequest cor = null; - logger.debug("requestId is: " + requestId); + logger.debug("requestId is: {}", requestId); try { ObjectMapper mapper = new ObjectMapper(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java index 696616099f..007ea938a2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java @@ -45,8 +45,6 @@ import org.onap.so.apihandlerinfra.vnfbeans.RequestStatusType; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; -import org.onap.so.logger.ErrorCode; -import org.onap.so.logger.MessageEnum; import org.onap.so.utils.UUIDChecker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -356,8 +354,7 @@ public class TenantIsolationRequest { request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); requestsDbClient.save(request); } catch (Exception e) { - logger.error("{} {} {} {}", MessageEnum.APIH_DB_UPDATE_EXC.toString(), e.getMessage(), - ErrorCode.DataError.getValue(), "Exception when updating record in DB"); + logger.error("Exception when updating record in DB", e); logger.debug("Exception: ", e); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java index d9db5713a7..6942d441e6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java @@ -34,8 +34,6 @@ import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.entities.uri.Depth; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @@ -63,7 +61,7 @@ public class AAIClientHelper { * Update managing ECOMP Environment Info from A&AI * * @param id = operationalEnvironmentId - * @param AAIOperationalEnvironment object + * @param aaiRequest object */ public void updateAaiOperationalEnvironment(String id, OperationalEnvironment aaiRequest) { @@ -75,7 +73,7 @@ public class AAIClientHelper { public void updateAaiOperationalEnvironment(String operationalEnvironmentId, Map<String, String> payload) - throws Exception { + throws AAIClientCallFailed { try { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.OPERATIONAL_ENVIRONMENT, operationalEnvironmentId); @@ -90,7 +88,7 @@ public class AAIClientHelper { /** * Create an Operational Environment object in A&AI * - * @param AAIOperationalEnvironment object + * @param operationalEnvironment object */ public void createOperationalEnvironment(OperationalEnvironment operationalEnvironment) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java index b02bd95d97..3b87d91d3f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java @@ -119,12 +119,25 @@ public class RelatedInstancesValidation implements ValidationRule { isRelatedServiceInstancePresent = true; } + if (requestScope.equalsIgnoreCase(ModelType.service.name())) { + if (empty(relatedInstance.getInstanceName()) + && ModelType.vpnBinding.equals(relatedInstanceModelInfo.getModelType())) { + throw new ValidationException("instanceName in relatedInstance for vpnBinding modelType", true); + } + if (empty(relatedInstance.getInstanceName()) + && ModelType.network.equals(relatedInstanceModelInfo.getModelType())) { + throw new ValidationException("instanceName in relatedInstance for network modelType", true); + } + } + if (action != Action.deleteInstance && !requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString())) { if (!(relatedInstanceModelInfo.getModelType().equals(ModelType.volumeGroup) || relatedInstanceModelInfo.getModelType().equals(ModelType.connectionPoint) || relatedInstanceModelInfo.getModelType().equals(ModelType.pnf) - || relatedInstanceModelInfo.getModelType().equals(ModelType.networkInstanceGroup))) { + || relatedInstanceModelInfo.getModelType().equals(ModelType.networkInstanceGroup) + || relatedInstanceModelInfo.getModelType().equals(ModelType.network) + || relatedInstanceModelInfo.getModelType().equals(ModelType.vpnBinding))) { if (empty(relatedInstanceModelInfo.getModelInvariantId())) { throw new ValidationException("modelInvariantId in relatedInstance"); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml index e709758223..03934edf20 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml +++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml @@ -7,7 +7,7 @@ server: mso: infra: - auditInventory: true + auditInventory: false default: versions: apiMinorVersion: 0 @@ -70,4 +70,4 @@ org: so: adapters: network: - encryptionKey: aa3871669d893c7fb8abbcda31b88b4f
\ No newline at end of file + encryptionKey: aa3871669d893c7fb8abbcda31b88b4f diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java index c30b9dedf2..bc10aa744e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/MsoRequestTest.java @@ -83,6 +83,12 @@ public class MsoRequestTest extends BaseTest { return input; } + public String inputStreamVpnBonding(String JsonInput) throws IOException { + JsonInput = "src/test/resources/Validation" + JsonInput; + String input = new String(Files.readAllBytes(Paths.get(JsonInput))); + return input; + } + // Tests for successful validation of incoming JSON requests through the parse method @Test @Parameters(method = "successParameters") @@ -188,6 +194,8 @@ public class MsoRequestTest extends BaseTest { instanceIdMapTest, Action.addRelationships, "5"}, {mapper.readValue(inputStream("/SuccessfulValidation/ServiceAssign.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.assignInstance, "7"}, + {mapper.readValue(inputStream("/RelatedInstances/ServiceInstanceVpnBondingService.json"), + ServiceInstancesRequest.class), instanceIdMapTest, Action.createInstance, "7"}, {mapper.readValue(inputStream("/SuccessfulValidation/ServiceUnassign.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.unassignInstance, "7"}}); } @@ -546,6 +554,22 @@ public class MsoRequestTest extends BaseTest { mapper.readValue(inputStream("/RelatedInstances/v6AddRelationshipsInstanceName.json"), ServiceInstancesRequest.class), instanceIdMapTest, Action.addRelationships, 6}, + {"No valid modelType in relatedInstance is specified", + mapper.readValue(inputStreamVpnBonding("/VpnBondingValidation/NoModelType.json"), + ServiceInstancesRequest.class), + instanceIdMapTest, Action.createInstance, 7}, + {"No valid instanceId in relatedInstance is specified", + mapper.readValue(inputStreamVpnBonding("/VpnBondingValidation/NoInstanceId.json"), + ServiceInstancesRequest.class), + instanceIdMapTest, Action.createInstance, 7}, + {"No valid instanceName in relatedInstance for vpnBinding modelType is specified", + mapper.readValue(inputStreamVpnBonding("/VpnBondingValidation/NoInstanceNameVpnBinding.json"), + ServiceInstancesRequest.class), + instanceIdMapTest, Action.createInstance, 7}, + {"No valid instanceName in relatedInstance for network modelType is specified", + mapper.readValue(inputStreamVpnBonding("/VpnBondingValidation/NoInstanceNameNetwork.json"), + ServiceInstancesRequest.class), + instanceIdMapTest, Action.createInstance, 7}, {"No valid modelCustomizationName or modelCustomizationId in relatedInstance of vnf is specified", mapper.readValue(inputStream("/RelatedInstances/RelatedInstancesModelCustomizationId.json"), ServiceInstancesRequest.class), diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java new file mode 100644 index 0000000000..19b9d7ea1e --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsUnitTest.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.apihandlerinfra; + +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertThat; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.apihandlerinfra.exceptions.ApiException; +import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.serviceinstancebeans.InstanceReferences; +import org.onap.so.serviceinstancebeans.Request; +import org.onap.so.serviceinstancebeans.RequestStatus; + +@RunWith(MockitoJUnitRunner.class) +public class OrchestrationRequestsUnitTest { + + @Spy + private OrchestrationRequests orchestrationRequests; + + private static final String REQUEST_ID = "7cb9aa56-dd31-41e5-828e-d93027d4ebba"; + private static final String SERVICE_INSTANCE_ID = "7cb9aa56-dd31-41e5-828e-d93027d4ebbb"; + private static final String ORIGINAL_REQUEST_ID = "8f2d38a6-7c20-465a-bd7e-075645f1394b"; + private static final String SERVICE = "service"; + private InfraActiveRequests iar; + boolean includeCloudRequest = false; + + @Before + public void setup() { + iar = new InfraActiveRequests(); + iar.setRequestScope(SERVICE); + iar.setRequestId(REQUEST_ID); + iar.setServiceInstanceId(SERVICE_INSTANCE_ID); + } + + @Test + public void mapInfraActiveRequestToRequestWithOriginalRequestIdTest() throws ApiException { + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + RequestStatus requestStatus = new RequestStatus(); + Request expected = new Request(); + expected.setRequestId(REQUEST_ID); + expected.setOriginalRequestId(ORIGINAL_REQUEST_ID); + expected.setInstanceReferences(instanceReferences); + expected.setRequestStatus(requestStatus); + expected.setRequestScope(SERVICE); + + iar.setOriginalRequestId(ORIGINAL_REQUEST_ID); + + Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest); + assertThat(result, sameBeanAs(expected)); + } + + @Test + public void mapInfraActiveRequestToRequestOriginalRequestIdNullTest() throws ApiException { + InstanceReferences instanceReferences = new InstanceReferences(); + instanceReferences.setServiceInstanceId(SERVICE_INSTANCE_ID); + RequestStatus requestStatus = new RequestStatus(); + Request expected = new Request(); + expected.setRequestId(REQUEST_ID); + expected.setInstanceReferences(instanceReferences); + expected.setRequestStatus(requestStatus); + expected.setRequestScope(SERVICE); + + Request result = orchestrationRequests.mapInfraActiveRequestToRequest(iar, includeCloudRequest); + assertThat(result, sameBeanAs(expected)); + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java index e80fd9e690..3cb4e0c9c2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsUnitTest.java @@ -21,32 +21,69 @@ package org.onap.so.apihandlerinfra; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.sql.Timestamp; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.apihandlerinfra.exceptions.ApiException; +import org.onap.so.apihandlerinfra.exceptions.VfModuleNotFoundException; +import org.onap.so.db.catalog.beans.VfModule; +import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.ModelType; @RunWith(MockitoJUnitRunner.class) public class RequestHandlerUtilsUnitTest { + @Mock + private CatalogDbClient catDbClient; + + @InjectMocks @Spy private RequestHandlerUtils requestHandler; + @Rule + public ExpectedException thrown = ExpectedException.none(); + private static final String CURRENT_REQUEST_ID = "eca3a1b1-43ab-457e-ab1c-367263d148b4"; + private static final String RESUMED_REQUEST_ID = "59c7247f-839f-4923-90c3-05faa3ab354d"; private static final String SERVICE_INSTANCE_ID = "00032ab7-na18-42e5-965d-8ea592502018"; + private static final String SERVICE_INSTANCE_NAME = "serviceInstanceName"; + private static final String VNF_ID = "00032ab7-na18-42e5-965d-8ea592502017"; + private static final String VFMODULE_ID = "00032ab7-na18-42e5-965d-8ea592502016"; + private static final String NETWORK_ID = "00032ab7-na18-42e5-965d-8ea592502015"; + private static final String VOLUME_GROUP_ID = "00032ab7-na18-42e5-965d-8ea592502014"; + private static final String VNF_NAME = "vnfName"; + private static final String VFMODULE_NAME = "vfModuleName"; + private static final String NETWORK_NAME = "networkName"; + private static final String VOLUME_GROUP_NAME = "volumeGroupName"; + private static final String MODEL_VERSION_ID = "883f4a7a-b5a5-44e0-8738-361c6413d24c"; + private static final String MODEL_VERSION = "1.0"; + private static final String MODEL_INVARIANT_ID = "d358b828-e7f8-4833-ac96-2782bed1a9a9"; + private static final String MODEL_NAME = "modelName"; private final Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); private String requestUri = "http:localhost:6746/onap/so/infra/orchestrationRequests/v7/00032ab7-na18-42e5-965d-8ea592502019/resume"; private InfraActiveRequests infraActiveRequest = new InfraActiveRequests(); private InfraActiveRequests currentActiveRequest = new InfraActiveRequests(); private InfraActiveRequests currentActiveRequestIARNull = new InfraActiveRequests(); + private Action action = Action.createInstance; + private String vnfType = "vnfType"; + private String sdcServiceModelVersion = "7"; public String getRequestBody(String request) throws IOException { request = "src/test/resources/ResumeOrchestrationRequest" + request; @@ -66,7 +103,7 @@ public class RequestHandlerUtilsUnitTest { infraActiveRequest.setAicCloudRegion("cloudRegion"); infraActiveRequest.setRequestScope("service"); infraActiveRequest.setServiceInstanceId(SERVICE_INSTANCE_ID); - infraActiveRequest.setServiceInstanceName("serviceInstanceName"); + infraActiveRequest.setServiceInstanceName(SERVICE_INSTANCE_NAME); infraActiveRequest.setRequestStatus(Status.IN_PROGRESS.toString()); infraActiveRequest.setRequestAction(Action.createInstance.toString()); infraActiveRequest.setServiceType("serviceType"); @@ -77,17 +114,16 @@ public class RequestHandlerUtilsUnitTest { currentActiveRequest.setSource("VID"); currentActiveRequest.setStartTime(startTimeStamp); currentActiveRequest.setTenantId("tenant-id"); - currentActiveRequest.setRequestBody(getRequestBody("/RequestBody.json")); + currentActiveRequest.setRequestBody(getRequestBody("/RequestBodyNewRequestorId.json")); currentActiveRequest.setAicCloudRegion("cloudRegion"); currentActiveRequest.setRequestScope("service"); - currentActiveRequest.setServiceInstanceId(SERVICE_INSTANCE_ID); - currentActiveRequest.setServiceInstanceName("serviceInstanceName"); currentActiveRequest.setRequestStatus(Status.IN_PROGRESS.toString()); currentActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); currentActiveRequest.setRequestAction(Action.createInstance.toString()); currentActiveRequest.setRequestUrl(requestUri); - currentActiveRequest.setRequestorId("xxxxxx"); + currentActiveRequest.setRequestorId("yyyyyy"); currentActiveRequest.setProgress(new Long(5)); + currentActiveRequest.setOriginalRequestId(RESUMED_REQUEST_ID); } private void setCurrentActiveRequestNullInfraActive() throws IOException { @@ -99,20 +135,275 @@ public class RequestHandlerUtilsUnitTest { currentActiveRequestIARNull.setRequestUrl(requestUri); currentActiveRequestIARNull.setRequestorId("xxxxxx"); currentActiveRequestIARNull.setProgress(new Long(5)); + currentActiveRequestIARNull.setOriginalRequestId(RESUMED_REQUEST_ID); } @Test - public void createNewRecordCopyFromInfraActiveRequestTest() { + public void createNewRecordCopyFromInfraActiveRequestTest() throws IOException { + doNothing().when(requestHandler).setInstanceIdAndName(infraActiveRequest, currentActiveRequest); + doReturn(getRequestBody("/RequestBodyNewRequestorId.json")).when(requestHandler) + .updateRequestorIdInRequestBody(infraActiveRequest, "yyyyyy"); InfraActiveRequests result = requestHandler.createNewRecordCopyFromInfraActiveRequest(infraActiveRequest, - CURRENT_REQUEST_ID, startTimeStamp, "VID", requestUri, "xxxxxx"); + CURRENT_REQUEST_ID, startTimeStamp, "VID", requestUri, "yyyyyy", RESUMED_REQUEST_ID); assertThat(currentActiveRequest, sameBeanAs(result)); } @Test public void createNewRecordCopyFromInfraActiveRequestNullIARTest() { InfraActiveRequests result = requestHandler.createNewRecordCopyFromInfraActiveRequest(null, CURRENT_REQUEST_ID, - startTimeStamp, "VID", requestUri, "xxxxxx"); + startTimeStamp, "VID", requestUri, "xxxxxx", RESUMED_REQUEST_ID); assertThat(currentActiveRequestIARNull, sameBeanAs(result)); } + + @Test + public void setInstanceIdAndNameServiceTest() { + InfraActiveRequests serviceRequest = new InfraActiveRequests(); + + InfraActiveRequests expected = new InfraActiveRequests(); + expected.setServiceInstanceId(SERVICE_INSTANCE_ID); + expected.setServiceInstanceName(SERVICE_INSTANCE_NAME); + + requestHandler.setInstanceIdAndName(infraActiveRequest, serviceRequest); + assertThat(serviceRequest, sameBeanAs(expected)); + } + + @Test + public void setInstanceIdAndNameRequestScopeNotValidTest() { + InfraActiveRequests originalServiceRequest = new InfraActiveRequests(); + originalServiceRequest.setRequestScope("test"); + InfraActiveRequests serviceRequest = new InfraActiveRequests(); + + InfraActiveRequests expected = new InfraActiveRequests(); + + requestHandler.setInstanceIdAndName(originalServiceRequest, serviceRequest); + assertThat(serviceRequest, sameBeanAs(expected)); + } + + @Test + public void setInstanceIdAndNameVnfTest() { + InfraActiveRequests vnfRequestOriginal = new InfraActiveRequests(); + vnfRequestOriginal.setRequestScope("vnf"); + vnfRequestOriginal.setVnfId(VNF_ID); + vnfRequestOriginal.setVnfName(VNF_NAME); + InfraActiveRequests vnfRequest = new InfraActiveRequests(); + + InfraActiveRequests expected = new InfraActiveRequests(); + expected.setVnfId(VNF_ID); + expected.setVnfName(VNF_NAME); + + requestHandler.setInstanceIdAndName(vnfRequestOriginal, vnfRequest); + assertThat(vnfRequest, sameBeanAs(expected)); + } + + @Test + public void setInstanceIdAndNameVfModuleTest() { + InfraActiveRequests vfModuleRequestOriginal = new InfraActiveRequests(); + vfModuleRequestOriginal.setRequestScope("vfModule"); + vfModuleRequestOriginal.setVfModuleId(VFMODULE_ID); + vfModuleRequestOriginal.setVfModuleName(VFMODULE_NAME); + InfraActiveRequests vfModuleRequest = new InfraActiveRequests(); + + InfraActiveRequests expected = new InfraActiveRequests(); + expected.setVfModuleId(VFMODULE_ID); + expected.setVfModuleName(VFMODULE_NAME); + + requestHandler.setInstanceIdAndName(vfModuleRequestOriginal, vfModuleRequest); + assertThat(vfModuleRequest, sameBeanAs(expected)); + } + + @Test + public void setInstanceIdAndNameNetworkTest() { + InfraActiveRequests networkRequestOriginal = new InfraActiveRequests(); + networkRequestOriginal.setRequestScope("network"); + networkRequestOriginal.setNetworkId(NETWORK_ID); + networkRequestOriginal.setNetworkName(NETWORK_NAME); + InfraActiveRequests networkRequest = new InfraActiveRequests(); + + InfraActiveRequests expected = new InfraActiveRequests(); + expected.setNetworkId(NETWORK_ID); + expected.setNetworkName(NETWORK_NAME); + + requestHandler.setInstanceIdAndName(networkRequestOriginal, networkRequest); + assertThat(networkRequest, sameBeanAs(expected)); + } + + @Test + public void setInstanceIdAndNameVolumeGroupTest() { + InfraActiveRequests volumeGroupRequestOriginal = new InfraActiveRequests(); + volumeGroupRequestOriginal.setRequestScope("volumeGroup"); + volumeGroupRequestOriginal.setVolumeGroupId(VOLUME_GROUP_ID); + volumeGroupRequestOriginal.setVolumeGroupName(VOLUME_GROUP_NAME); + InfraActiveRequests volumeGroupRequest = new InfraActiveRequests(); + + InfraActiveRequests expected = new InfraActiveRequests(); + expected.setVolumeGroupId(VOLUME_GROUP_ID); + expected.setVolumeGroupName(VOLUME_GROUP_NAME); + + requestHandler.setInstanceIdAndName(volumeGroupRequestOriginal, volumeGroupRequest); + assertThat(volumeGroupRequest, sameBeanAs(expected)); + } + + @Test + public void getIsBaseVfModuleTrueTest() throws ApiException { + VfModule vfModule = new VfModule(); + vfModule.setIsBase(true); + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelVersionId(MODEL_VERSION_ID); + + doReturn(vfModule).when(catDbClient).getVfModuleByModelUUID(MODEL_VERSION_ID); + Boolean expected = true; + + Boolean result = requestHandler.getIsBaseVfModule(modelInfo, action, vnfType, sdcServiceModelVersion, + currentActiveRequest); + assertEquals(result, expected); + } + + @Test + public void getIsBaseVfModuleFalseTest() throws ApiException { + VfModule vfModule = new VfModule(); + vfModule.setIsBase(false); + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelVersionId(MODEL_VERSION_ID); + + doReturn(vfModule).when(catDbClient).getVfModuleByModelUUID(MODEL_VERSION_ID); + Boolean expected = false; + + Boolean result = requestHandler.getIsBaseVfModule(modelInfo, action, vnfType, sdcServiceModelVersion, + currentActiveRequest); + assertEquals(result, expected); + } + + @Test + public void getIsBaseVfModuleNullTest() throws ApiException { + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelVersionId(MODEL_VERSION_ID); + modelInfo.setModelName(MODEL_NAME); + String errorMessage = + "VnfType vnfType and VF Module Model Name modelName with version 7 not found in MSO Catalog DB"; + + doNothing().when(requestHandler).updateStatus(currentActiveRequest, Status.FAILED, errorMessage); + doReturn(null).when(catDbClient).getVfModuleByModelUUID(MODEL_VERSION_ID); + + thrown.expect(VfModuleNotFoundException.class); + thrown.expectMessage(errorMessage); + requestHandler.getIsBaseVfModule(modelInfo, action, vnfType, sdcServiceModelVersion, currentActiveRequest); + } + + @Test + public void getIsBaseVfModuleModelVersionIdNullTest() throws ApiException { + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelInvariantId(MODEL_INVARIANT_ID); + modelInfo.setModelVersion(MODEL_VERSION); + modelInfo.setModelName(MODEL_NAME); + Boolean expected = false; + + doReturn(null).when(catDbClient).getVfModuleByModelInvariantUUIDAndModelVersion(MODEL_INVARIANT_ID, + MODEL_VERSION); + + Boolean result = requestHandler.getIsBaseVfModule(modelInfo, Action.deleteInstance, vnfType, + sdcServiceModelVersion, currentActiveRequest); + assertEquals(result, expected); + } + + @Test + public void getIsBaseVfModuleModelInfoNotSetTest() throws ApiException { + ModelInfo modelInfo = new ModelInfo(); + Boolean expected = false; + + Boolean result = requestHandler.getIsBaseVfModule(modelInfo, Action.deleteInstance, vnfType, + sdcServiceModelVersion, currentActiveRequest); + assertEquals(result, expected); + } + + @Test + public void getIsBaseVfModuleModelVersionNullTest() throws ApiException { + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelInvariantId(MODEL_INVARIANT_ID); + modelInfo.setModelName(MODEL_NAME); + Boolean expected = false; + + Boolean result = requestHandler.getIsBaseVfModule(modelInfo, Action.deleteInstance, vnfType, + sdcServiceModelVersion, currentActiveRequest); + assertEquals(result, expected); + } + + @Test + public void getIsBaseVfModuleModelVersionNullUpdateTest() throws ApiException { + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelInvariantId(MODEL_INVARIANT_ID); + modelInfo.setModelName(MODEL_NAME); + String errorMessage = "VnfType vnfType and VF Module Model Name modelName not found in MSO Catalog DB"; + + doNothing().when(requestHandler).updateStatus(currentActiveRequest, Status.FAILED, errorMessage); + + thrown.expect(VfModuleNotFoundException.class); + thrown.expectMessage(errorMessage); + requestHandler.getIsBaseVfModule(modelInfo, Action.updateInstance, vnfType, null, currentActiveRequest); + } + + @Test + public void getIsBaseVfModulesdcModelVersionEmptyTest() throws ApiException { + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelInvariantId(MODEL_INVARIANT_ID); + modelInfo.setModelName(MODEL_NAME); + String errorMessage = "VnfType vnfType and VF Module Model Name modelName not found in MSO Catalog DB"; + + doNothing().when(requestHandler).updateStatus(currentActiveRequest, Status.FAILED, errorMessage); + + thrown.expect(VfModuleNotFoundException.class); + thrown.expectMessage(errorMessage); + requestHandler.getIsBaseVfModule(modelInfo, Action.updateInstance, vnfType, "", currentActiveRequest); + } + + @Test + public void getModelTypeApplyUpdatedConfigTest() { + ModelType modelTypeExpected = ModelType.vnf; + + ModelType modelTypeResult = requestHandler.getModelType(Action.applyUpdatedConfig, null); + assertEquals(modelTypeResult, modelTypeExpected); + } + + @Test + public void getModelTypeInPlaceSoftwareUpdateTest() { + ModelType modelTypeExpected = ModelType.vnf; + + ModelType modelTypeResult = requestHandler.getModelType(Action.inPlaceSoftwareUpdate, null); + assertEquals(modelTypeResult, modelTypeExpected); + } + + @Test + public void getModelTypeAddMembersTest() { + ModelType modelTypeExpected = ModelType.instanceGroup; + + ModelType modelTypeResult = requestHandler.getModelType(Action.addMembers, null); + assertEquals(modelTypeResult, modelTypeExpected); + } + + @Test + public void getModelTypeRemoveMembersTest() { + ModelType modelTypeExpected = ModelType.instanceGroup; + + ModelType modelTypeResult = requestHandler.getModelType(Action.removeMembers, null); + assertEquals(modelTypeResult, modelTypeExpected); + } + + @Test + public void getModelTypeTest() { + ModelType modelTypeExpected = ModelType.service; + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelType(ModelType.service); + + ModelType modelTypeResult = requestHandler.getModelType(Action.createInstance, modelInfo); + assertEquals(modelTypeResult, modelTypeExpected); + } + + @Test + public void updateRequestorIdInRequestBodyTest() throws IOException { + String newRequestorId = "yyyyyy"; + String expected = getRequestBody("/RequestBodyNewRequestorId.json"); + String result = requestHandler.updateRequestorIdInRequestBody(infraActiveRequest, newRequestorId); + assertEquals(expected, result); + } + } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java index 92490a66b8..398966b0b3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ResumeOrchestrationRequestTest.java @@ -30,6 +30,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.junit.Assert.assertEquals; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; @@ -53,9 +54,11 @@ import org.onap.so.apihandlerinfra.exceptions.RequestDbFailureException; import org.onap.so.apihandlerinfra.exceptions.ValidateException; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.springframework.web.client.HttpClientErrorException; import com.fasterxml.jackson.databind.ObjectMapper; +import org.onap.so.serviceinstancebeans.ModelType; @RunWith(MockitoJUnitRunner.class) public class ResumeOrchestrationRequestTest { @@ -81,8 +84,20 @@ public class ResumeOrchestrationRequestTest { private static final String CURRENT_REQUEST_ID = "eca3a1b1-43ab-457e-ab1c-367263d148b4"; private static final String REQUEST_ID = "00032ab7-na18-42e5-965d-8ea592502019"; private static final String SERVICE_INSTANCE_ID = "00032ab7-na18-42e5-965d-8ea592502018"; + private static final String VNF_ID = "00032ab7-na18-42e5-965d-8ea592502017"; + private static final String VFMODULE_ID = "00032ab7-na18-42e5-965d-8ea592502016"; + private static final String NETWORK_ID = "00032ab7-na18-42e5-965d-8ea592502015"; + private static final String VOLUME_GROUP_ID = "00032ab7-na18-42e5-965d-8ea592502014"; private static final String SERVICE_INSTANCE_NAME = "serviceInstanceName"; - private static final String REQUEST_SCOPE = "service"; + private static final String VNF_NAME = "vnfName"; + private static final String VFMODULE_NAME = "vfModuleName"; + private static final String NETWORK_NAME = "networkName"; + private static final String VOLUME_GROUP_NAME = "volumeGroupName"; + private static final String SERVICE = "service"; + private static final String VNF = "vnf"; + private static final String VFMODULE = "vfModule"; + private static final String NETWORK = "network"; + private static final String VOLUME_GROUP = "volumeGroup"; private final Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis()); private final Action action = Action.createInstance; private final Boolean aLaCarte = false; @@ -91,15 +106,18 @@ public class ResumeOrchestrationRequestTest { "http:localhost:6746/onap/so/infra/orchestrationRequests/v7/00032ab7-na18-42e5-965d-8ea592502019/resume"; private final RecipeLookupResult lookupResult = new RecipeLookupResult("/mso/async/services/WorkflowActionBB", 80); private RequestClientParameter requestClientParameter = null; + private RequestClientParameter requestClientParameterVfModule = null; private ObjectMapper mapper = new ObjectMapper(); private InfraActiveRequests infraActiveRequest = new InfraActiveRequests(); private InfraActiveRequests currentActiveRequest = new InfraActiveRequests(); + private InfraActiveRequests infraActiveRequestVfModule = new InfraActiveRequests(); private ServiceInstancesRequest sir = new ServiceInstancesRequest(); private ServiceInstancesRequest sirNullALaCarte = new ServiceInstancesRequest(); private String requestBody = null; private String requestBodyNullALaCarte = null; private ContainerRequestContext requestContext = null; private HashMap<String, String> instanceIdMap = new HashMap<>(); + ModelInfo modelInfo; @Before @@ -110,13 +128,16 @@ public class ResumeOrchestrationRequestTest { // Setup InfraActiveRequests setInfraActiveRequest(); setCurrentActiveRequest(); + setInfraActiveRequestVfModule(); requestBody = infraActiveRequest.getRequestBody(); sir = mapper.readValue(requestBody, ServiceInstancesRequest.class); requestBodyNullALaCarte = getRequestBody("/ALaCarteNull.json"); - sirNullALaCarte = sir = mapper.readValue(requestBodyNullALaCarte, ServiceInstancesRequest.class); + sirNullALaCarte = mapper.readValue(requestBodyNullALaCarte, ServiceInstancesRequest.class); setRequestClientParameter(); + setRequestClientParameterVfModule(); instanceIdMap.put("serviceInstanceId", SERVICE_INSTANCE_ID); + modelInfo = sir.getRequestDetails().getModelInfo(); } public String getRequestBody(String request) throws IOException { @@ -128,12 +149,21 @@ public class ResumeOrchestrationRequestTest { infraActiveRequest.setTenantId("tenant-id"); infraActiveRequest.setRequestBody(getRequestBody("/RequestBody.json")); infraActiveRequest.setAicCloudRegion("cloudRegion"); - infraActiveRequest.setRequestScope(REQUEST_SCOPE); + infraActiveRequest.setRequestScope(SERVICE); infraActiveRequest.setServiceInstanceId(SERVICE_INSTANCE_ID); infraActiveRequest.setServiceInstanceName(SERVICE_INSTANCE_NAME); infraActiveRequest.setRequestStatus(Status.IN_PROGRESS.toString()); infraActiveRequest.setRequestAction(Action.createInstance.toString()); infraActiveRequest.setServiceType("serviceType"); + infraActiveRequest.setVnfId(VNF_ID); + infraActiveRequest.setVfModuleId(VFMODULE_ID); + infraActiveRequest.setNetworkId(NETWORK_ID); + infraActiveRequest.setVolumeGroupId(VOLUME_GROUP_ID); + infraActiveRequest.setVnfName(VNF_NAME); + infraActiveRequest.setVfModuleName(VFMODULE_NAME); + infraActiveRequest.setNetworkName(NETWORK_NAME); + infraActiveRequest.setVolumeGroupName(VOLUME_GROUP_NAME); + infraActiveRequest.setRequestId(REQUEST_ID); } private void setCurrentActiveRequest() throws IOException { @@ -143,7 +173,7 @@ public class ResumeOrchestrationRequestTest { currentActiveRequest.setTenantId("tenant-id"); currentActiveRequest.setRequestBody(getRequestBody("/RequestBody.json")); currentActiveRequest.setAicCloudRegion("cloudRegion"); - currentActiveRequest.setRequestScope(REQUEST_SCOPE); + currentActiveRequest.setRequestScope(SERVICE); currentActiveRequest.setServiceInstanceId(SERVICE_INSTANCE_ID); currentActiveRequest.setServiceInstanceName(SERVICE_INSTANCE_NAME); currentActiveRequest.setRequestStatus(Status.IN_PROGRESS.toString()); @@ -154,13 +184,33 @@ public class ResumeOrchestrationRequestTest { currentActiveRequest.setProgress(new Long(5)); } + private void setInfraActiveRequestVfModule() throws IOException { + infraActiveRequestVfModule.setRequestBody(getRequestBody("/RequestBody.json")); + infraActiveRequestVfModule.setRequestScope(VFMODULE); + infraActiveRequestVfModule.setRequestStatus(Status.IN_PROGRESS.toString()); + infraActiveRequestVfModule.setRequestAction(Action.createInstance.toString()); + infraActiveRequestVfModule.setVnfId(VNF_ID); + infraActiveRequestVfModule.setVfModuleId(VFMODULE_ID); + infraActiveRequestVfModule.setVnfName(VNF_NAME); + infraActiveRequestVfModule.setVfModuleName(VFMODULE_NAME); + } + private void setRequestClientParameter() { - requestClientParameter = new RequestClientParameter.Builder().setRequestId(CURRENT_REQUEST_ID) - .setRecipeTimeout(80).setRequestAction(Action.createInstance.toString()) - .setServiceInstanceId(SERVICE_INSTANCE_ID).setPnfCorrelationId("pnfCorrelationId").setVnfId(null) - .setVfModuleId(null).setVolumeGroupId(null).setNetworkId(null).setServiceType("serviceType") - .setVnfType(null).setNetworkType(null).setRequestDetails(requestBody).setApiVersion(version) - .setALaCarte(aLaCarte).setRequestUri(requestUri).setInstanceGroupId(null).build(); + requestClientParameter = + new RequestClientParameter.Builder().setRequestId(CURRENT_REQUEST_ID).setRecipeTimeout(80) + .setRequestAction(Action.createInstance.toString()).setServiceInstanceId(SERVICE_INSTANCE_ID) + .setPnfCorrelationId("pnfCorrelationId").setVnfId(VNF_ID).setVfModuleId(VFMODULE_ID) + .setVolumeGroupId(VOLUME_GROUP_ID).setNetworkId(NETWORK_ID).setServiceType("serviceType") + .setVnfType(null).setNetworkType(null).setRequestDetails(requestBody).setApiVersion(version) + .setALaCarte(aLaCarte).setRequestUri(requestUri).setInstanceGroupId(null).build(); + } + + private void setRequestClientParameterVfModule() { + requestClientParameterVfModule = + new RequestClientParameter.Builder().setRequestId(CURRENT_REQUEST_ID).setRecipeTimeout(80) + .setRequestAction(Action.createInstance.toString()).setPnfCorrelationId("pnfCorrelationId") + .setVnfId(VNF_ID).setVfModuleId(VFMODULE_ID).setRequestDetails(requestBody) + .setApiVersion(version).setALaCarte(aLaCarte).setRequestUri(requestUri).build(); } @Test @@ -169,7 +219,7 @@ public class ResumeOrchestrationRequestTest { when(requestDbClient.getInfraActiveRequestbyRequestId(REQUEST_ID)).thenReturn(infraActiveRequest); doReturn(currentActiveRequest).when(requestHandler).createNewRecordCopyFromInfraActiveRequest( any(InfraActiveRequests.class), nullable(String.class), any(Timestamp.class), nullable(String.class), - nullable(String.class), nullable(String.class)); + nullable(String.class), nullable(String.class), anyString()); doReturn(response).when(resumeReq).resumeRequest(any(InfraActiveRequests.class), any(InfraActiveRequests.class), anyString(), nullable(String.class)); @@ -201,16 +251,20 @@ public class ResumeOrchestrationRequestTest { @Test public void resumeRequestTest() throws ApiException, IOException { Response response = null; + doReturn(instanceIdMap).when(resumeReq).setInstanceIdMap(infraActiveRequest, ModelType.service.toString()); + doReturn(SERVICE_INSTANCE_NAME).when(resumeReq).getInstanceName(infraActiveRequest, + ModelType.service.toString(), currentActiveRequest); when(requestHandler.convertJsonToServiceInstanceRequest(anyString(), any(Actions.class), anyString(), anyString())).thenReturn(sir); when(serviceInstances.getPnfCorrelationId(any(ServiceInstancesRequest.class))).thenReturn("pnfCorrelationId"); - doReturn(lookupResult).when(resumeReq).serviceRecipeLookup(currentActiveRequest, sir, action, aLaCarte); + doReturn(lookupResult).when(serviceInstances).getServiceInstanceOrchestrationURI(sir, action, aLaCarte, + currentActiveRequest); doReturn(requestClientParameter).when(resumeReq).setRequestClientParameter(lookupResult, version, infraActiveRequest, currentActiveRequest, "pnfCorrelationId", aLaCarte, sir); doNothing().when(resumeReq).requestDbSave(currentActiveRequest); when(requestHandler.postBPELRequest(any(InfraActiveRequests.class), any(RequestClientParameter.class), anyString(), anyString())).thenReturn(response); - doNothing().when(resumeReq).checkForInProgressRequest(currentActiveRequest, SERVICE_INSTANCE_ID, REQUEST_SCOPE, + doNothing().when(resumeReq).checkForInProgressRequest(currentActiveRequest, instanceIdMap, SERVICE, SERVICE_INSTANCE_NAME, action); resumeReq.resumeRequest(infraActiveRequest, currentActiveRequest, version, @@ -220,15 +274,8 @@ public class ResumeOrchestrationRequestTest { } @Test - public void serviceRecipeLookupTest() throws ApiException, IOException { - when(serviceInstances.getServiceURI(any(ServiceInstancesRequest.class), any(Action.class), anyBoolean())) - .thenReturn(lookupResult); - RecipeLookupResult result = resumeReq.serviceRecipeLookup(currentActiveRequest, sir, action, aLaCarte); - assertThat(result, sameBeanAs(lookupResult)); - } - - @Test public void setRequestClientParameterTest() throws ApiException, IOException { + doReturn(ModelType.service).when(requestHandler).getModelType(action, modelInfo); when(requestHandler.mapJSONtoMSOStyle(anyString(), any(ServiceInstancesRequest.class), anyBoolean(), any(Action.class))).thenReturn(requestBody); RequestClientParameter result = resumeReq.setRequestClientParameter(lookupResult, version, infraActiveRequest, @@ -237,6 +284,16 @@ public class ResumeOrchestrationRequestTest { } @Test + public void setRequestClientParameterVfModuleTest() throws ApiException, IOException { + when(requestHandler.mapJSONtoMSOStyle(anyString(), any(ServiceInstancesRequest.class), anyBoolean(), + any(Action.class))).thenReturn(requestBody); + doReturn(ModelType.vfModule).when(requestHandler).getModelType(action, modelInfo); + RequestClientParameter result = resumeReq.setRequestClientParameter(lookupResult, version, + infraActiveRequestVfModule, currentActiveRequest, "pnfCorrelationId", aLaCarte, sir); + assertThat(requestClientParameterVfModule, sameBeanAs(result)); + } + + @Test public void requestDbSaveTest() throws RequestDbFailureException { doNothing().when(requestDbClient).save(currentActiveRequest); resumeReq.requestDbSave(currentActiveRequest); @@ -246,17 +303,22 @@ public class ResumeOrchestrationRequestTest { @Test public void resumeRequestTestALaCarteNull() throws ApiException, IOException { Response response = null; - + doReturn(instanceIdMap).when(resumeReq).setInstanceIdMap(infraActiveRequest, ModelType.service.toString()); + doReturn(SERVICE_INSTANCE_NAME).when(resumeReq).getInstanceName(infraActiveRequest, + ModelType.service.toString(), currentActiveRequest); when(requestHandler.convertJsonToServiceInstanceRequest(anyString(), any(Actions.class), anyString(), anyString())).thenReturn(sirNullALaCarte); when(serviceInstances.getPnfCorrelationId(any(ServiceInstancesRequest.class))).thenReturn("pnfCorrelationId"); - doReturn(lookupResult).when(resumeReq).serviceRecipeLookup(currentActiveRequest, sir, action, aLaCarte); + doReturn(false).when(msoRequest).getAlacarteFlag(sirNullALaCarte); + doReturn(lookupResult).when(serviceInstances).getServiceInstanceOrchestrationURI(sirNullALaCarte, action, false, + currentActiveRequest); doReturn(requestClientParameter).when(resumeReq).setRequestClientParameter(lookupResult, version, - infraActiveRequest, currentActiveRequest, "pnfCorrelationId", aLaCarte, sir); + infraActiveRequest, currentActiveRequest, "pnfCorrelationId", aLaCarte, sirNullALaCarte); + doReturn(false).when(resumeReq).setALaCarteFlagIfNull(SERVICE, action); doNothing().when(resumeReq).requestDbSave(currentActiveRequest); when(requestHandler.postBPELRequest(any(InfraActiveRequests.class), any(RequestClientParameter.class), anyString(), anyString())).thenReturn(response); - doNothing().when(resumeReq).checkForInProgressRequest(currentActiveRequest, SERVICE_INSTANCE_ID, REQUEST_SCOPE, + doNothing().when(resumeReq).checkForInProgressRequest(currentActiveRequest, instanceIdMap, SERVICE, SERVICE_INSTANCE_NAME, action); resumeReq.resumeRequest(infraActiveRequest, currentActiveRequest, version, @@ -266,18 +328,8 @@ public class ResumeOrchestrationRequestTest { } @Test - public void serviceRecipeLookupErrorTest() throws IOException, ApiException { - when(serviceInstances.getServiceURI(sir, action, aLaCarte)) - .thenThrow(new IOException("Error occurred on recipe lookup")); - doNothing().when(requestHandler).updateStatus(any(InfraActiveRequests.class), any(Status.class), anyString()); - - thrown.expect(ValidateException.class); - thrown.expectMessage("Error occurred on recipe lookup"); - resumeReq.serviceRecipeLookup(currentActiveRequest, sir, action, aLaCarte); - } - - @Test public void setRequestClientParameterErrorTest() throws ApiException, IOException { + doReturn(ModelType.service).when(requestHandler).getModelType(action, modelInfo); when(requestHandler.mapJSONtoMSOStyle(anyString(), any(ServiceInstancesRequest.class), anyBoolean(), any(Action.class))).thenThrow(new IOException("IOException")); @@ -290,39 +342,141 @@ public class ResumeOrchestrationRequestTest { @Test public void checkForInProgressRequest() throws ApiException { doReturn(infraActiveRequest).when(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME, - REQUEST_SCOPE, currentActiveRequest); + SERVICE, currentActiveRequest); doReturn(true).when(requestHandler).camundaHistoryCheck(infraActiveRequest, currentActiveRequest); doThrow(DuplicateRequestException.class).when(requestHandler).buildErrorOnDuplicateRecord(currentActiveRequest, - action, instanceIdMap, SERVICE_INSTANCE_NAME, REQUEST_SCOPE, infraActiveRequest); + action, instanceIdMap, SERVICE_INSTANCE_NAME, SERVICE, infraActiveRequest); thrown.expect(DuplicateRequestException.class); - resumeReq.checkForInProgressRequest(currentActiveRequest, SERVICE_INSTANCE_ID, REQUEST_SCOPE, - SERVICE_INSTANCE_NAME, action); + resumeReq.checkForInProgressRequest(currentActiveRequest, instanceIdMap, SERVICE, SERVICE_INSTANCE_NAME, + action); } @Test public void checkForInProgressRequestNoInProgressRequests() throws ApiException { - doReturn(null).when(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME, REQUEST_SCOPE, + doReturn(null).when(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME, SERVICE, currentActiveRequest); - resumeReq.checkForInProgressRequest(currentActiveRequest, SERVICE_INSTANCE_ID, REQUEST_SCOPE, - SERVICE_INSTANCE_NAME, action); - verify(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME, REQUEST_SCOPE, + resumeReq.checkForInProgressRequest(currentActiveRequest, instanceIdMap, SERVICE, SERVICE_INSTANCE_NAME, + action); + verify(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME, SERVICE, currentActiveRequest); } @Test public void checkForInProgressRequestCamundaHistoryCheckReturnsNoInProgress() throws ApiException { doReturn(infraActiveRequest).when(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME, - REQUEST_SCOPE, currentActiveRequest); + SERVICE, currentActiveRequest); doReturn(false).when(requestHandler).camundaHistoryCheck(infraActiveRequest, currentActiveRequest); - resumeReq.checkForInProgressRequest(currentActiveRequest, SERVICE_INSTANCE_ID, REQUEST_SCOPE, - SERVICE_INSTANCE_NAME, action); - verify(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME, REQUEST_SCOPE, + resumeReq.checkForInProgressRequest(currentActiveRequest, instanceIdMap, SERVICE, SERVICE_INSTANCE_NAME, + action); + verify(requestHandler).duplicateCheck(action, instanceIdMap, SERVICE_INSTANCE_NAME, SERVICE, currentActiveRequest); verify(requestHandler).camundaHistoryCheck(infraActiveRequest, currentActiveRequest); } + @Test + public void setInstanceIdMapServiceTest() { + HashMap<String, String> expected = new HashMap<>(); + expected.put("serviceInstanceId", SERVICE_INSTANCE_ID); + HashMap<String, String> result = resumeReq.setInstanceIdMap(infraActiveRequest, SERVICE); + assertEquals(result, expected); + } + + @Test + public void setInstanceIdMapRequestScopeNotValidTest() { + HashMap<String, String> expected = new HashMap<>(); + HashMap<String, String> result = resumeReq.setInstanceIdMap(infraActiveRequest, "test"); + assertEquals(result, expected); + } + + @Test + public void setInstanceIdMapVnfTest() { + HashMap<String, String> expected = new HashMap<>(); + expected.put("vnfInstanceId", VNF_ID); + HashMap<String, String> result = resumeReq.setInstanceIdMap(infraActiveRequest, VNF); + assertEquals(result, expected); + } + + @Test + public void setInstanceIdMapVfModuleTest() { + HashMap<String, String> expected = new HashMap<>(); + expected.put("vfModuleInstanceId", VFMODULE_ID); + HashMap<String, String> result = resumeReq.setInstanceIdMap(infraActiveRequest, VFMODULE); + assertEquals(result, expected); + } + + @Test + public void setInstanceIdMapNetworkTest() { + HashMap<String, String> expected = new HashMap<>(); + expected.put("networkInstanceId", NETWORK_ID); + HashMap<String, String> result = resumeReq.setInstanceIdMap(infraActiveRequest, NETWORK); + assertEquals(result, expected); + } + + @Test + public void setInstanceIdMapVolumeGroupTest() { + HashMap<String, String> expected = new HashMap<>(); + expected.put("volumeGroupInstanceId", VOLUME_GROUP_ID); + HashMap<String, String> result = resumeReq.setInstanceIdMap(infraActiveRequest, VOLUME_GROUP); + assertEquals(result, expected); + } + + @Test + public void setInstanceNameServiceTest() throws ValidateException, RequestDbFailureException { + String result = resumeReq.getInstanceName(infraActiveRequest, SERVICE, currentActiveRequest); + assertEquals(result, SERVICE_INSTANCE_NAME); + } + + @Test + public void setInstanceNameRequestScopeNotValidTest() throws ValidateException, RequestDbFailureException { + thrown.expect(ValidateException.class); + thrown.expectMessage( + "requestScope: \"test\" from request: 00032ab7-na18-42e5-965d-8ea592502019 does not match a ModelType enum."); + + resumeReq.getInstanceName(infraActiveRequest, "test", currentActiveRequest); + } + + @Test + public void setInstanceNameVnfTest() throws ValidateException, RequestDbFailureException { + String result = resumeReq.getInstanceName(infraActiveRequest, VNF, currentActiveRequest); + assertEquals(result, VNF_NAME); + } + @Test + public void setInstanceNameVfModuleTest() throws ValidateException, RequestDbFailureException { + String result = resumeReq.getInstanceName(infraActiveRequest, VFMODULE, currentActiveRequest); + assertEquals(result, VFMODULE_NAME); + } + + @Test + public void setInstanceNameNetworkTest() throws ValidateException, RequestDbFailureException { + String result = resumeReq.getInstanceName(infraActiveRequest, NETWORK, currentActiveRequest); + assertEquals(result, NETWORK_NAME); + } + + @Test + public void setInstanceNameVolumeGroupTest() throws ValidateException, RequestDbFailureException { + String result = resumeReq.getInstanceName(infraActiveRequest, VOLUME_GROUP, currentActiveRequest); + assertEquals(result, VOLUME_GROUP_NAME); + } + + @Test + public void setALaCarteFlagIfNullTest() { + Boolean aLaCarteFlag = resumeReq.setALaCarteFlagIfNull(SERVICE, action); + assertEquals(aLaCarteFlag, false); + } + + @Test + public void setALaCarteFlagIfNullVnfTest() { + Boolean aLaCarteFlag = resumeReq.setALaCarteFlagIfNull(VNF, action); + assertEquals(aLaCarteFlag, true); + } + + @Test + public void setALaCarteFlagIfNullRecreateTest() { + Boolean aLaCarteFlag = resumeReq.setALaCarteFlagIfNull(VNF, Action.recreateInstance); + assertEquals(aLaCarteFlag, false); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java index 48abeacbc5..0beab1bd13 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/WorkflowSpecificationsHandlerTest.java @@ -87,6 +87,66 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { .withBody(getWiremockResponseForCatalogdb("WorkflowActivitySpecSequence_Response.json")) .withStatus(org.apache.http.HttpStatus.SC_OK))); + wireMockServer.stubFor(get(urlMatching("/workflowActivitySpecSequence/1/activitySpec")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("ActivitySpecSequence1_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching("/workflowActivitySpecSequence/2/activitySpec")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("ActivitySpecSequence2_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching("/workflowActivitySpecSequence/3/activitySpec")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("ActivitySpecSequence3_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching("/activitySpec/1/activitySpecUserParameters")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("ActivitySpecUserParameters1_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching("/activitySpec/2/activitySpecUserParameters")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("ActivitySpecUserParameters2_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching("/activitySpec/3/activitySpecUserParameters")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("ActivitySpecUserParameters3_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching("/activitySpecUserParameters/1/userParameters")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("UserParameters1_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching("/activitySpecUserParameters/2/userParameters")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("UserParameters2_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching("/activitySpecUserParameters/3/userParameters")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("UserParameters3_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching("/activitySpecUserParameters/4/userParameters")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("UserParameters4_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching("/activitySpecUserParameters/5/userParameters")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("UserParameters5_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlMatching("/activitySpecUserParameters/6/userParameters")) + .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) + .withBody(getWiremockResponseForCatalogdb("UserParameters6_Response.json")) + .withStatus(org.apache.http.HttpStatus.SC_OK))); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(basePath)) .queryParam("vnfModelVersionId", "b5fa707a-f55a-11e7-a796-005056856d52"); @@ -237,6 +297,17 @@ public class WorkflowSpecificationsHandlerTest extends BaseTest { workflow.setWorkflowActivitySpecSequence(workflowActivitySpecSequences); workflows.add(workflow); + Workflow workflowNative = new Workflow(); + workflowNative.setArtifactUUID("da6478e4-ea33-3346-ac12-ab121284a333"); + workflowNative.setArtifactName("VnfInPlaceUpdate.bpmn"); + workflowNative.setVersion(1.0); + workflowNative.setDescription("native workflow"); + workflowNative.setName("VnfInPlaceUpdate"); + workflowNative.setOperationName("inPlaceSoftwareUpdate"); + workflowNative.setSource("native"); + workflowNative.setResourceTarget("vnf"); + workflows.add(workflowNative); + WorkflowSpecifications workflowSpecifications = workflowSpecificationsHandler.mapWorkflowsToWorkflowSpecifications(workflows); ObjectMapper mapper = new ObjectMapper(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java index 54da0baa92..93a19a9531 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidationTest.java @@ -25,15 +25,38 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.HashMap; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.BaseTest; import org.onap.so.exceptions.ValidationException; +import org.onap.so.serviceinstancebeans.RelatedInstanceList; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import com.fasterxml.jackson.databind.ObjectMapper; public class RelatedInstancesValidationTest extends BaseTest { + RelatedInstancesValidation validation = new RelatedInstancesValidation(); + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + public ValidationInformation setupValidationInformation(String path) throws IOException { + String jsonInput = new String(Files.readAllBytes(Paths.get(path))); + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesRequest sir = mapper.readValue(jsonInput, ServiceInstancesRequest.class); + ValidationInformation info = new ValidationInformation(sir, null, Action.createInstance, 7, false, + sir.getRequestDetails().getRequestParameters()); + + info.setRequestScope("service"); + sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b"); + sir.getRequestDetails().getModelInfo().setModelCustomizationName("name"); + + info.setRequestInfo(sir.getRequestDetails().getRequestInfo()); + return info; + } + @Test public void testCreateVnfNetworkInstanceGroup() throws IOException, ValidationException { String requestJson = new String(Files.readAllBytes( @@ -50,4 +73,64 @@ public class RelatedInstancesValidationTest extends BaseTest { assertEquals(info.getVnfType(), "Test/name"); } + + @Test + public void testCreateSIVpnBonding() throws IOException, ValidationException { + String requestJson = new String(Files.readAllBytes( + Paths.get("src/test/resources/MsoRequestTest/RelatedInstances/ServiceInstanceVpnBondingService.json"))); + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class); + ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), + Action.createInstance, 7, false, sir.getRequestDetails().getRequestParameters()); + info.setRequestScope("service"); + sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b"); + sir.getRequestDetails().getModelInfo().setModelCustomizationName("name"); + RelatedInstancesValidation validation = new RelatedInstancesValidation(); + validation.validate(info); + RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); + + assertEquals(info.getRequestScope(), "service"); + assertEquals(instanceList[0].getRelatedInstance().getModelInfo().getModelType().toString(), "vpnBinding"); + assertEquals(instanceList[1].getRelatedInstance().getModelInfo().getModelType().toString(), "network"); + } + + @Test + public void validateModelTypeExceptionTest() throws IOException, ValidationException { + thrown.expect(ValidationException.class); + thrown.expectMessage("No valid modelType in relatedInstance is specified"); + validation.validate( + setupValidationInformation("src/test/resources/Validation/VpnBondingValidation/NoModelType.json")); + } + + @Test + public void validateInstanceNameVpnBindingExceptionTest() throws IOException, ValidationException { + thrown.expect(ValidationException.class); + thrown.expectMessage("No valid instanceName in relatedInstance for vpnBinding modelType is specified"); + validation.validate(setupValidationInformation( + "src/test/resources/Validation/VpnBondingValidation/NoInstanceNameVpnBinding.json")); + } + + @Test + public void validateInstanceNameNetworkExceptionTest() throws IOException, ValidationException { + thrown.expect(ValidationException.class); + thrown.expectMessage("No valid instanceName in relatedInstance for network modelType is specified"); + validation.validate(setupValidationInformation( + "src/test/resources/Validation/VpnBondingValidation/NoInstanceNameNetwork.json")); + } + + @Test + public void validateInstanceIdExceptionTest() throws IOException, ValidationException { + thrown.expect(ValidationException.class); + thrown.expectMessage("No valid instanceId in relatedInstance is specified"); + validation.validate( + setupValidationInformation("src/test/resources/Validation/VpnBondingValidation/NoInstanceId.json")); + } + + @Test + public void validatemodelInvariantIdExceptionTest() throws IOException, ValidationException { + thrown.expect(ValidationException.class); + thrown.expectMessage("No valid modelInvariantId in relatedInstance is specified"); + validation.validate(setupValidationInformation( + "src/test/resources/Validation/VpnBondingValidation/NoModelInvariantId.json")); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ServiceInstanceVpnBondingService.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ServiceInstanceVpnBondingService.json new file mode 100644 index 0000000000..573b7a3ebb --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/RelatedInstances/ServiceInstanceVpnBondingService.json @@ -0,0 +1,57 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21", + "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb", + "modelName": "Test", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "cloudOwner": "test-mgr", + "lcpCloudRegionId": "abc1", + "tenantId": "19123c2924c648eb8e42a3c1f14b7682" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "PACKET CORE" + }, + "project": { + "projectName": "projectName" + }, + "subscriberInfo": { + "globalSubscriberId": "TEST_123", + "subscriberName": "TEST_123" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "requestorId": "xxxxxx", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "instanceName": "vpn-name", + "modelInfo": { + "modelType": "vpnBinding" + } + } + }, + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "instanceName": "network-name", + "modelInfo": { + "modelType": "network" + } + } + } + ], + "requestParameters": { + "subscriptionServiceType": "dev-service-type", + "aLaCarte": false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json index 5cd31427a0..d6406338a0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBody.json @@ -1,5 +1,11 @@ { "requestDetails":{ + "modelInfo":{ + "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7965", + "modelVersion": "1.0", + "modelType":"service", + "modelName":"serviceModel" + }, "requestInfo":{ "source":"VID", "requestorId":"xxxxxx", diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBodyNewRequestorId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBodyNewRequestorId.json new file mode 100644 index 0000000000..740d4e2ec2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ResumeOrchestrationRequest/RequestBodyNewRequestorId.json @@ -0,0 +1,19 @@ +{ + "requestDetails":{ + "modelInfo":{ + "modelInvariantId": "f7ce78bb-423b-11e7-93f8-0050569a7965", + "modelVersion": "1.0", + "modelType":"service", + "modelName":"serviceModel" + }, + "requestInfo":{ + "source":"VID", + "requestorId":"yyyyyy", + "instanceName":"testService", + "productFamilyId":"test" + }, + "requestParameters":{ + "aLaCarte":"false" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceVpnBondingService.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceVpnBondingService.json new file mode 100644 index 0000000000..573b7a3ebb --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/ServiceInstanceTest/ServiceInstanceVpnBondingService.json @@ -0,0 +1,57 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21", + "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb", + "modelName": "Test", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "cloudOwner": "test-mgr", + "lcpCloudRegionId": "abc1", + "tenantId": "19123c2924c648eb8e42a3c1f14b7682" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "PACKET CORE" + }, + "project": { + "projectName": "projectName" + }, + "subscriberInfo": { + "globalSubscriberId": "TEST_123", + "subscriberName": "TEST_123" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "requestorId": "xxxxxx", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "instanceName": "vpn-name", + "modelInfo": { + "modelType": "vpnBinding" + } + } + }, + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "instanceName": "network-name", + "modelInfo": { + "modelType": "network" + } + } + } + ], + "requestParameters": { + "subscriptionServiceType": "dev-service-type", + "aLaCarte": false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceId.json new file mode 100644 index 0000000000..97e480c8d8 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceId.json @@ -0,0 +1,56 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21", + "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb", + "modelName": "Test", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "cloudOwner": "test-mgr", + "lcpCloudRegionId": "abc1", + "tenantId": "19123c2924c648eb8e42a3c1f14b7682" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "PACKET CORE" + }, + "project": { + "projectName": "projectName" + }, + "subscriberInfo": { + "globalSubscriberId": "TEST_123", + "subscriberName": "TEST_123" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "requestorId": "xxxxxx", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceName": "vpn-name", + "modelInfo": { + "modelType": "vpnBinding" + } + } + }, + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "instanceName": "network-name", + "modelInfo": { + "modelType": "network" + } + } + } + ], + "requestParameters": { + "subscriptionServiceType": "dev-service-type", + "aLaCarte": false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameNetwork.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameNetwork.json new file mode 100644 index 0000000000..f7ba4761b6 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameNetwork.json @@ -0,0 +1,56 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21", + "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb", + "modelName": "Test", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "cloudOwner": "test-mgr", + "lcpCloudRegionId": "abc1", + "tenantId": "19123c2924c648eb8e42a3c1f14b7682" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "PACKET CORE" + }, + "project": { + "projectName": "projectName" + }, + "subscriberInfo": { + "globalSubscriberId": "TEST_123", + "subscriberName": "TEST_123" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "requestorId": "xxxxxx", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "instanceName": "vpn-name", + "modelInfo": { + "modelType": "vpnBinding" + } + } + }, + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "modelInfo": { + "modelType": "network" + } + } + } + ], + "requestParameters": { + "subscriptionServiceType": "dev-service-type", + "aLaCarte": false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameVpnBinding.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameVpnBinding.json new file mode 100644 index 0000000000..ac570b3830 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoInstanceNameVpnBinding.json @@ -0,0 +1,56 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21", + "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb", + "modelName": "Test", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "cloudOwner": "test-mgr", + "lcpCloudRegionId": "abc1", + "tenantId": "19123c2924c648eb8e42a3c1f14b7682" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "PACKET CORE" + }, + "project": { + "projectName": "projectName" + }, + "subscriberInfo": { + "globalSubscriberId": "TEST_123", + "subscriberName": "TEST_123" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "requestorId": "xxxxxx", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "modelInfo": { + "modelType": "vpnBinding" + } + } + }, + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "instanceName": "network-name", + "modelInfo": { + "modelType": "network" + } + } + } + ], + "requestParameters": { + "subscriptionServiceType": "dev-service-type", + "aLaCarte": false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelInvariantId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelInvariantId.json new file mode 100644 index 0000000000..ca02c5371a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelInvariantId.json @@ -0,0 +1,57 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21", + "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb", + "modelName": "Test", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "cloudOwner": "test-mgr", + "lcpCloudRegionId": "abc1", + "tenantId": "19123c2924c648eb8e42a3c1f14b7682" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "PACKET CORE" + }, + "project": { + "projectName": "projectName" + }, + "subscriberInfo": { + "globalSubscriberId": "TEST_123", + "subscriberName": "TEST_123" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "requestorId": "xxxxxx", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "instanceName": "vpn-name", + "modelInfo": { + "modelType": "vnf" + } + } + }, + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "instanceName": "network-name", + "modelInfo": { + "modelType": "service" + } + } + } + ], + "requestParameters": { + "subscriptionServiceType": "dev-service-type", + "aLaCarte": false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelType.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelType.json new file mode 100644 index 0000000000..1d46ce2ccd --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/Validation/VpnBondingValidation/NoModelType.json @@ -0,0 +1,56 @@ +{ + "requestDetails": { + "modelInfo": { + "modelType": "service", + "modelInvariantId": "1710f6e8-1c29-4990-9aea-e943a2ec3d21", + "modelVersionId": "1710966e-097c-4d63-afda-e0d3bb7015fb", + "modelName": "Test", + "modelVersion": "1.0" + }, + "cloudConfiguration": { + "cloudOwner": "test-mgr", + "lcpCloudRegionId": "abc1", + "tenantId": "19123c2924c648eb8e42a3c1f14b7682" + }, + "owningEntity": { + "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489", + "owningEntityName": "PACKET CORE" + }, + "project": { + "projectName": "projectName" + }, + "subscriberInfo": { + "globalSubscriberId": "TEST_123", + "subscriberName": "TEST_123" + }, + "requestInfo": { + "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", + "requestorId": "xxxxxx", + "source": "VID", + "suppressRollback": false + }, + "relatedInstanceList": [ + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "instanceName": "vpn-name", + "modelInfo": { + } + } + }, + { + "relatedInstance": { + "instanceId": "ff305d54-75b4-431b-adb2-eb6b9e5ff000", + "instanceName": "network-name", + "modelInfo": { + "modelType": "network" + } + } + } + ], + "requestParameters": { + "subscriptionServiceType": "dev-service-type", + "aLaCarte": false + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecSequence1_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecSequence1_Response.json new file mode 100644 index 0000000000..37e32631fb --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecSequence1_Response.json @@ -0,0 +1,20 @@ +{ + "name": "VNFQuiesceTrafficActivity", + "description": "Activity to QuiesceTraffic on VNF", + "version": null, + "created": null, + "activitySpecActivitySpecCategories": null, + "activitySpecActivitySpecParameters": null, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpec/1" + }, + "activitySpec": { + "href": "http://localhost:8090/activitySpec/1" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpec/1/activitySpecUserParameters" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecSequence2_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecSequence2_Response.json new file mode 100644 index 0000000000..ee2a02ba33 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecSequence2_Response.json @@ -0,0 +1,20 @@ +{ + "name": "VNFHealthCheckActivity", + "description": "Activity to HealthCheck VNF", + "version": null, + "created": null, + "activitySpecActivitySpecCategories": null, + "activitySpecActivitySpecParameters": null, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpec/2" + }, + "activitySpec": { + "href": "http://localhost:8090/activitySpec/2" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpec/2/activitySpecUserParameters" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecSequence3_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecSequence3_Response.json new file mode 100644 index 0000000000..69390eea6b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecSequence3_Response.json @@ -0,0 +1,20 @@ +{ + "name": "FlowCompleteActivity", + "description": "Activity to Complete the BPMN Flow", + "version": null, + "created": null, + "activitySpecActivitySpecCategories": null, + "activitySpecActivitySpecParameters": null, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpec/3" + }, + "activitySpec": { + "href": "http://localhost:8090/activitySpec/3" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpec/3/activitySpecUserParameters" + } + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecUserParameters1_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecUserParameters1_Response.json new file mode 100644 index 0000000000..e88691b4d8 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecUserParameters1_Response.json @@ -0,0 +1,103 @@ +{ + "_embedded": { + "activitySpecUserParameters": [ + { + "activitySpecId": 1, + "userParametersId": 1, + "activitySpec": null, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/1" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/1" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/1/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 2, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/2" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/2" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/2/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 3, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/3" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/3" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/3/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 4, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/4" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/4" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/4/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 5, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/5" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/5" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/5/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 6, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/6" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/6" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/6/userParameters" + } + } + } + ] + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecUserParameters2_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecUserParameters2_Response.json new file mode 100644 index 0000000000..e88691b4d8 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecUserParameters2_Response.json @@ -0,0 +1,103 @@ +{ + "_embedded": { + "activitySpecUserParameters": [ + { + "activitySpecId": 1, + "userParametersId": 1, + "activitySpec": null, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/1" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/1" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/1/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 2, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/2" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/2" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/2/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 3, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/3" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/3" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/3/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 4, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/4" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/4" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/4/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 5, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/5" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/5" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/5/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 6, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/6" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/6" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/6/userParameters" + } + } + } + ] + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecUserParameters3_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecUserParameters3_Response.json new file mode 100644 index 0000000000..e88691b4d8 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/ActivitySpecUserParameters3_Response.json @@ -0,0 +1,103 @@ +{ + "_embedded": { + "activitySpecUserParameters": [ + { + "activitySpecId": 1, + "userParametersId": 1, + "activitySpec": null, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/1" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/1" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/1/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 2, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/2" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/2" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/2/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 3, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/3" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/3" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/3/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 4, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/4" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/4" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/4/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 5, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/5" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/5" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/5/userParameters" + } + } + }, + { + "activitySpecId": 1, + "userParametersId": 6, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/activitySpecUserParameters/6" + }, + "activitySpecUserParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/6" + }, + "userParameters": { + "href": "http://localhost:8090/activitySpecUserParameters/6/userParameters" + } + } + } + ] + } +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters1_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters1_Response.json new file mode 100644 index 0000000000..017add4cd5 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters1_Response.json @@ -0,0 +1,13 @@ +{ + "name": "operations_timeout", + "payloadLocation": "userParams", + "label": "Operations Timeout", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 50, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters2_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters2_Response.json new file mode 100644 index 0000000000..655d659c16 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters2_Response.json @@ -0,0 +1,13 @@ +{ + "name": "existing_software_version", + "payloadLocation": "userParams", + "label": "Existing Software Version", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 50, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters3_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters3_Response.json new file mode 100644 index 0000000000..13e02e7dd6 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters3_Response.json @@ -0,0 +1,13 @@ +{ + "name": "cloudOwner", + "payloadLocation": "cloudConfiguration", + "label": "Cloud Owner", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 7, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters4_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters4_Response.json new file mode 100644 index 0000000000..e30ec0da88 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters4_Response.json @@ -0,0 +1,13 @@ +{ + "name": "tenantId", + "payloadLocation": "cloudConfiguration", + "label": "Tenant/Project ID", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 36, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters5_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters5_Response.json new file mode 100644 index 0000000000..98b18522da --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters5_Response.json @@ -0,0 +1,13 @@ +{ + "name": "new_software_version", + "payloadLocation": "userParams", + "label": "New Software Version", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 50, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters6_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters6_Response.json new file mode 100644 index 0000000000..4d8d03b6a7 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/UserParameters6_Response.json @@ -0,0 +1,13 @@ +{ + "name": "lcpCloudRegionId", + "payloadLocation": "cloudConfiguration", + "label": "Cloud Region ID", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 7, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null +}
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowActivitySpecSequence_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowActivitySpecSequence_Response.json index 3192865b52..3df17380d6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowActivitySpecSequence_Response.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowActivitySpecSequence_Response.json @@ -1,432 +1,54 @@ { "_embedded": { - - "workflowActivitySpecSequence": [ - { - "activitySpecId": null, - "workflowId": null, - "activitySpec": { - "name": "VNFQuiesceTrafficActivity", - "description": "Activity to QuiesceTraffic on VNF", - "version": null, - "created": null, - "workflowActivitySpecSequence": null, - "activitySpecActivitySpecCategories": null, - "activitySpecUserParameters": [ - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "operations_timeout", - "payloadLocation": "userParams", - "label": "Operations Timeout", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "existing_software_version", - "payloadLocation": "userParams", - "label": "Existing Software Version", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "cloudOwner", - "payloadLocation": "cloudConfiguration", - "label": "Cloud Owner", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 7, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "tenantId", - "payloadLocation": "cloudConfiguration", - "label": "Tenant/Project ID", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 36, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "new_software_version", - "payloadLocation": "userParams", - "label": "New Software Version", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "lcpCloudRegionId", - "payloadLocation": "cloudConfiguration", - "label": "Cloud Region ID", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 7, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - } - ], - "activitySpecActivitySpecParameters": null, - "id": null - }, - "workflow": null, - "id": null, - "_links": { - "self": { - "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" - }, - "workflowActivitySpecSequence": { - "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence" - } - - } - - }, - { - "activitySpecId": null, - "workflowId": null, - "activitySpec": { - "name": "VNFHealthCheckActivity", - "description": "Activity to HealthCheck VNF", - "version": null, - "created": null, - "workflowActivitySpecSequence": null, - "activitySpecActivitySpecCategories": null, - "activitySpecUserParameters": [ - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "operations_timeout", - "payloadLocation": "userParams", - "label": "Operations Timeout", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "existing_software_version", - "payloadLocation": "userParams", - "label": "Existing Software Version", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "cloudOwner", - "payloadLocation": "cloudConfiguration", - "label": "Cloud Owner", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 7, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "tenantId", - "payloadLocation": "cloudConfiguration", - "label": "Tenant/Project ID", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 36, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "new_software_version", - "payloadLocation": "userParams", - "label": "New Software Version", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "lcpCloudRegionId", - "payloadLocation": "cloudConfiguration", - "label": "Cloud Region ID", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 7, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - } - ], - "activitySpecActivitySpecParameters": null, - "id": null - }, - "workflow": null, - "id": null, - "_links": { - "self": { - "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" - }, - "workflowActivitySpecSequence": { - "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence" - } - - } - }, - { - "activitySpecId": null, - "workflowId": null, - "activitySpec": { - "name": "FlowCompleteActivity", - "description": "Activity to Complete the BPMN Flow", - "version": null, - "created": null, - "workflowActivitySpecSequence": null, - "activitySpecActivitySpecCategories": null, - "activitySpecUserParameters": [ - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "operations_timeout", - "payloadLocation": "userParams", - "label": "Operations Timeout", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "existing_software_version", - "payloadLocation": "userParams", - "label": "Existing Software Version", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "cloudOwner", - "payloadLocation": "cloudConfiguration", - "label": "Cloud Owner", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 7, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "tenantId", - "payloadLocation": "cloudConfiguration", - "label": "Tenant/Project ID", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 36, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "new_software_version", - "payloadLocation": "userParams", - "label": "New Software Version", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "lcpCloudRegionId", - "payloadLocation": "cloudConfiguration", - "label": "Cloud Region ID", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 7, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - } - ], - "activitySpecActivitySpecParameters": null, - "id": null - }, - "workflow": null, - "id": null, - "_links": { - "self": { - "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" - }, - "workflowActivitySpecSequence": { - "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence" - } - - } - } - ] - -} + "workflowActivitySpecSequence": [ + { + "activitySpecId": 1, + "workflowId": 1, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/workflowActivitySpecSequence//1/workflowActivitySpecSequence" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflowActivitySpecSequence/1/workflowActivitySpecSequence" + }, + "activitySpec": { + "href": "http://localhost:8090/workflowActivitySpecSequence/1/activitySpec" + } + } + }, + { + "activitySpecId": 2, + "workflowId": 1, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/workflowActivitySpecSequence/2/workflowActivitySpecSequence" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflowActivitySpecSequence/2/workflowActivitySpecSequence" + }, + "activitySpec": { + "href": "http://localhost:8090/workflowActivitySpecSequence/2/activitySpec" + } + } + }, + { + "activitySpecId": 3, + "workflowId": 1, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/workflowActivitySpecSequence/3" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflowActivitySpecSequence/3/workflowActivitySpecSequence" + }, + "activitySpec": { + "href": "http://localhost:8090/workflowActivitySpecSequence/3/activitySpec" + } + } + } + ] + } }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecifications.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecifications.json index 5556c602be..59bc12d92d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecifications.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecifications.json @@ -108,6 +108,23 @@ } ] } + }, + { + "workflowSpecification": { + + "artifactInfo": { + "artifactType": "workflow", + "artifactUuid": "da6478e4-ea33-3346-ac12-ab121284a333", + "artifactName": "VnfInPlaceUpdate.bpmn", + "artifactVersion": "1.0", + "artifactDescription": "native workflow", + "workflowName": "VnfInPlaceUpdate", + "operationName": "inPlaceSoftwareUpdate", + "workflowSource": "native", + "workflowResourceTarget": "vnf" + }, + "workflowInputParameters": [] + } } ] } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsQuery_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsQuery_Response.json index c12365649e..8919dbbf2c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsQuery_Response.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/WorkflowSpecificationsQuery_Response.json @@ -1,468 +1,504 @@ { "_embedded": { - "workflows" :[ - { - "artifactUUID": "ab6478e4-ea33-3346-ac12-ab121484a333", - "artifactName": "inPlaceSoftwareUpdate-1_0.bpmn", - "name": "inPlaceSoftwareUpdate", - "operationName": "inPlaceSoftwareUpdate", - "version": 1, - "description": "xyz xyz", - "body": null, - "resourceTarget": "vnf", - "source": "sdc", - "timeoutMinutes": null, - "artifactChecksum": null, - "created": null, - "vnfResourceWorkflow": null, - "workflowActivitySpecSequence": [ - { - "activitySpecId": null, - "workflowId": null, - "activitySpec": { - "name": "VNFQuiesceTrafficActivity", - "description": "Activity to QuiesceTraffic on VNF", - "version": null, - "created": null, - "workflowActivitySpecSequence": null, - "activitySpecActivitySpecCategories": null, - "activitySpecUserParameters": [ - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "operations_timeout", - "payloadLocation": "userParams", - "label": "Operations Timeout", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "existing_software_version", - "payloadLocation": "userParams", - "label": "Existing Software Version", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "cloudOwner", - "payloadLocation": "cloudConfiguration", - "label": "Cloud Owner", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 7, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "tenantId", - "payloadLocation": "cloudConfiguration", - "label": "Tenant/Project ID", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 36, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "new_software_version", - "payloadLocation": "userParams", - "label": "New Software Version", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "lcpCloudRegionId", - "payloadLocation": "cloudConfiguration", - "label": "Cloud Region ID", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 7, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - } - ], - "activitySpecActivitySpecParameters": null, - "id": null - }, - "workflow": null, - "id": null, - "_links": { - "self": { - "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID[?]vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" - }, - "workflowActivitySpecSequence": { - "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence" - } - - } - - }, - { - "activitySpecId": null, - "workflowId": null, - "activitySpec": { - "name": "VNFHealthCheckActivity", - "description": "Activity to HealthCheck VNF", - "version": null, - "created": null, - "workflowActivitySpecSequence": null, - "activitySpecActivitySpecCategories": null, - "activitySpecUserParameters": [ - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "operations_timeout", - "payloadLocation": "userParams", - "label": "Operations Timeout", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "existing_software_version", - "payloadLocation": "userParams", - "label": "Existing Software Version", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "cloudOwner", - "payloadLocation": "cloudConfiguration", - "label": "Cloud Owner", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 7, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "tenantId", - "payloadLocation": "cloudConfiguration", - "label": "Tenant/Project ID", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 36, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "new_software_version", - "payloadLocation": "userParams", - "label": "New Software Version", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "lcpCloudRegionId", - "payloadLocation": "cloudConfiguration", - "label": "Cloud Region ID", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 7, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - } - ], - "activitySpecActivitySpecParameters": null, - "id": null - }, - "workflow": null, - "id": null, - "_links": { - "self": { - "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" - }, - "workflowActivitySpecSequence": { - "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence" - } - - } - }, - { - "activitySpecId": null, - "workflowId": null, - "activitySpec": { - "name": "FlowCompleteActivity", - "description": "Activity to Complete the BPMN Flow", - "version": null, - "created": null, - "workflowActivitySpecSequence": null, - "activitySpecActivitySpecCategories": null, - "activitySpecUserParameters": [ - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "operations_timeout", - "payloadLocation": "userParams", - "label": "Operations Timeout", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "existing_software_version", - "payloadLocation": "userParams", - "label": "Existing Software Version", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "cloudOwner", - "payloadLocation": "cloudConfiguration", - "label": "Cloud Owner", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 7, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "tenantId", - "payloadLocation": "cloudConfiguration", - "label": "Tenant/Project ID", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 36, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "new_software_version", - "payloadLocation": "userParams", - "label": "New Software Version", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 50, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - }, - { - "activitySpecId": null, - "userParametersId": null, - "activitySpec": null, - "userParameters": { - "name": "lcpCloudRegionId", - "payloadLocation": "cloudConfiguration", - "label": "Cloud Region ID", - "type": "text", - "description": null, - "isRequried": true, - "maxLength": 7, - "allowableChars": "someRegEx", - "created": null, - "activitySpecUserParameters": null, - "id": null - }, - "id": null - } - ], - "activitySpecActivitySpecParameters": null, - "id": null - }, - "workflow": null, - "id": null, - "_links": { - "self": { - "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" - }, - "workflowActivitySpecSequence": { - "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence" - } - - } - } - ], - "id": null, - - "_links": { - "self": { - "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" - }, - "workflowActivitySpecSequence": { - "href": "http://localhost:8090/workflow/1/workflowActivitySpecSequence" - } - - } - - } -] -}, -"_links": { - "self": { - "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" - }, - "workflowActivitySpecSequence": { - "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence" - } - - } + "workflows": [ + { + "artifactUUID": "ab6478e4-ea33-3346-ac12-ab121484a333", + "artifactName": "inPlaceSoftwareUpdate-1_0.bpmn", + "name": "inPlaceSoftwareUpdate", + "operationName": "inPlaceSoftwareUpdate", + "version": 1, + "description": "xyz xyz", + "body": null, + "resourceTarget": "vnf", + "source": "sdc", + "timeoutMinutes": null, + "artifactChecksum": null, + "created": null, + "vnfResourceWorkflow": null, + "workflowActivitySpecSequence": [ + { + "activitySpecId": null, + "workflowId": null, + "activitySpec": { + "name": "VNFQuiesceTrafficActivity", + "description": "Activity to QuiesceTraffic on VNF", + "version": null, + "created": null, + "workflowActivitySpecSequence": null, + "activitySpecActivitySpecCategories": null, + "activitySpecUserParameters": [ + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "operations_timeout", + "payloadLocation": "userParams", + "label": "Operations Timeout", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 50, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "existing_software_version", + "payloadLocation": "userParams", + "label": "Existing Software Version", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 50, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "cloudOwner", + "payloadLocation": "cloudConfiguration", + "label": "Cloud Owner", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 7, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "tenantId", + "payloadLocation": "cloudConfiguration", + "label": "Tenant/Project ID", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 36, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "new_software_version", + "payloadLocation": "userParams", + "label": "New Software Version", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 50, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "lcpCloudRegionId", + "payloadLocation": "cloudConfiguration", + "label": "Cloud Region ID", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 7, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + } + ], + "activitySpecActivitySpecParameters": null, + "id": null + }, + "workflow": null, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID[?]vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence" + }, + "activitySpec": { + "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/activitySpec" + } + } + }, + { + "activitySpecId": null, + "workflowId": null, + "activitySpec": { + "name": "VNFHealthCheckActivity", + "description": "Activity to HealthCheck VNF", + "version": null, + "created": null, + "workflowActivitySpecSequence": null, + "activitySpecActivitySpecCategories": null, + "activitySpecUserParameters": [ + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "operations_timeout", + "payloadLocation": "userParams", + "label": "Operations Timeout", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 50, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "existing_software_version", + "payloadLocation": "userParams", + "label": "Existing Software Version", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 50, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "cloudOwner", + "payloadLocation": "cloudConfiguration", + "label": "Cloud Owner", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 7, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "tenantId", + "payloadLocation": "cloudConfiguration", + "label": "Tenant/Project ID", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 36, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "new_software_version", + "payloadLocation": "userParams", + "label": "New Software Version", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 50, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "lcpCloudRegionId", + "payloadLocation": "cloudConfiguration", + "label": "Cloud Region ID", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 7, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + } + ], + "activitySpecActivitySpecParameters": null, + "id": null + }, + "workflow": null, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence" + }, + "activitySpec": { + "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/activitySpec" + } + } + }, + { + "activitySpecId": null, + "workflowId": null, + "activitySpec": { + "name": "FlowCompleteActivity", + "description": "Activity to Complete the BPMN Flow", + "version": null, + "created": null, + "workflowActivitySpecSequence": null, + "activitySpecActivitySpecCategories": null, + "activitySpecUserParameters": [ + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "operations_timeout", + "payloadLocation": "userParams", + "label": "Operations Timeout", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 50, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "existing_software_version", + "payloadLocation": "userParams", + "label": "Existing Software Version", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 50, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "cloudOwner", + "payloadLocation": "cloudConfiguration", + "label": "Cloud Owner", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 7, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "tenantId", + "payloadLocation": "cloudConfiguration", + "label": "Tenant/Project ID", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 36, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "new_software_version", + "payloadLocation": "userParams", + "label": "New Software Version", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 50, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + }, + { + "activitySpecId": null, + "userParametersId": null, + "activitySpec": null, + "userParameters": { + "name": "lcpCloudRegionId", + "payloadLocation": "cloudConfiguration", + "label": "Cloud Region ID", + "type": "text", + "description": null, + "isRequried": true, + "maxLength": 7, + "allowableChars": "someRegEx", + "created": null, + "activitySpecUserParameters": null, + "id": null + }, + "id": null + } + ], + "activitySpecActivitySpecParameters": null, + "id": null + }, + "workflow": null, + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence" + }, + "activitySpec": { + "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/activitySpec" + } + } + } + ], + "id": null, + "_links": { + "self": { + "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflow/1/workflowActivitySpecSequence" + }, + "activitySpec": { + "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/activitySpec" + } + } + }, + { + "artifactUUID": "da6478e4-ea33-3346-ac12-ab121284a333", + "artifactName": "VnfInPlaceUpdate.bpmn", + "name": "VnfInPlaceUpdate", + "operationName": "inPlaceSoftwareUpdate", + "version": 1, + "description": "native workflow", + "body": null, + "resourceTarget": "vnf", + "source": "native", + "timeoutMinutes": null, + "artifactChecksum": null, + "created": null, + "vnfResourceWorkflow": null, + "workflowActivitySpecSequence": [], + "id": null, + "workflow": null, + "_links": { + "self": { + "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence" + }, + "activitySpec": { + "href": "http://localhost:8090/workflows/b5fa707a-f55a-11e7-a796-005056856d52/activitySpec" + } + } + } + ] + }, + "_links": { + "self": { + "href": "http://localhost:8090/workflow/search/findWorkflowByModelUUID?vnfResourceModelUUID=b5fa707a-f55a-11e7-a796-005056856d52" + }, + "workflowActivitySpecSequence": { + "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/workflowActivitySpecSequence" + }, + "activitySpec": { + "href": "http://localhost:8090/workflow/b5fa707a-f55a-11e7-a796-005056856d52/activitySpec" + } + } }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json index 6e358f7e17..d6ed585537 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/__files/catalogdb/workflow_Response.json @@ -1,4 +1,5 @@ { "artifactUUID": "71526781-e55c-4cb7-adb3-97e09d9c76be", - "artifactName": "testingWorkflow" + "artifactName": "testingWorkflow.bpmn", + "name": "testingWorkflow" }
\ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql index c2eb21b18e..948283453b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql @@ -806,6 +806,9 @@ CREATE TABLE `service` ( `WORKLOAD_CONTEXT` varchar(200) DEFAULT NULL, `SERVICE_CATEGORY` varchar(200) DEFAULT NULL, `RESOURCE_ORDER` varchar(200) default NULL, + `OVERALL_DISTRIBUTION_STATUS` varchar(45), + `ONAP_GENERATED_NAMING` TINYINT(1) DEFAULT NULL, + `NAMING_POLICY` varchar(200) DEFAULT NULL, PRIMARY KEY (`MODEL_UUID`), KEY `fk_service__tosca_csar1_idx` (`TOSCA_CSAR_ARTIFACT_UUID`), CONSTRAINT `fk_service__tosca_csar1` FOREIGN KEY (`TOSCA_CSAR_ARTIFACT_UUID`) REFERENCES `tosca_csar` (`ARTIFACT_UUID`) ON DELETE CASCADE ON UPDATE CASCADE |