diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
22 files changed, 242 insertions, 59 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java index 8dd55d9eac..760f623812 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAICreateTasks.java @@ -62,8 +62,8 @@ import org.onap.so.client.orchestration.AAIVfModuleResources; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.client.orchestration.AAIVolumeGroupResources; import org.onap.so.client.orchestration.AAIVpnBindingResources; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -121,7 +121,7 @@ public class AAICreateTasks { String errorMessage = "Exception in creating ServiceSubscription. Customer not present for ServiceInstanceID: " + serviceInstance.getServiceInstanceId(); logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), errorMessage, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), errorMessage); + ErrorCode.UnknownError.getValue(), errorMessage); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, errorMessage); } aaiSIResources.createServiceSubscription(customer); @@ -166,13 +166,13 @@ public class AAICreateTasks { if (owningEntityName == null || "".equals(owningEntityName)) { String msg = "Exception in AAICreateOwningEntity. Can't create an owningEntity with no owningEntityName."; logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), msg); + ErrorCode.UnknownError.getValue(), msg); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } else { if(aaiSIResources.existsOwningEntityName(owningEntityName)){ String msg = "Exception in AAICreateOwningEntity. Can't create OwningEntity as name already exists in AAI associated with a different owning-entity-id (name must be unique)"; logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), msg); + ErrorCode.UnknownError.getValue(), msg); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); }else{ aaiSIResources.createOwningEntityandConnectServiceInstance(owningEntity, serviceInstance); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java index 94529f915b..ccc9fb0e43 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIFlagTasks.java @@ -73,4 +73,45 @@ public class AAIFlagTasks { } } + public void checkVnfClosedLoopDisabledFlag(BuildingBlockExecution execution) { + boolean isClosedLoopDisabled = false; + try { + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + String vnfId = vnf.getVnfId(); + isClosedLoopDisabled = aaiVnfResources.checkVnfClosedLoopDisabledFlag(vnfId); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + if (isClosedLoopDisabled) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VNF Close Loop Disabled in A&AI"); + } + } + + public void modifyVnfClosedLoopDisabledFlag(BuildingBlockExecution execution, boolean closedLoopDisabled) { + try { + GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + + GenericVnf copiedGenericVnf = genericVnf.shallowCopyId(); + copiedGenericVnf.setClosedLoopDisabled(closedLoopDisabled); + genericVnf.setClosedLoopDisabled(closedLoopDisabled); + + aaiVnfResources.updateObjectVnf(copiedGenericVnf); + } catch(Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + + public void checkVnfPserversLockedFlag(BuildingBlockExecution execution) { + boolean inPserversLocked = false; + try { + GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID, execution.getLookupMap().get(ResourceKey.GENERIC_VNF_ID)); + String vnfId = vnf.getVnfId(); + inPserversLocked = aaiVnfResources.checkVnfPserversLockedFlag(vnfId); + } catch (Exception ex) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + if (inPserversLocked) { + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "VNF PServers in Locked in A&AI"); + } + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java index dc8f72c7a5..821dfc18b0 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java @@ -36,8 +36,8 @@ import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.onap.so.serviceinstancebeans.RequestDetails; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.slf4j.Logger; @@ -136,7 +136,7 @@ public class ExecuteActivity implements JavaDelegate { protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), msg, ex); + ErrorCode.UnknownError.getValue(), msg, ex); execution.setVariable("ExecuteActivityErrorMessage", msg); exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java index 41dabf9302..5eab6110f9 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterDeleteTasks.java @@ -29,7 +29,6 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper; import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java index 47357d8ef3..05ddb2e417 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnf/tasks/VnfAdapterImpl.java @@ -37,8 +37,8 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.exceptions.MarshallerException; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -167,9 +167,9 @@ public class VnfAdapterImpl { SAXSource source = new SAXSource(xmlReader, inputSource); return jaxbUnmarshaller.unmarshal(source); } catch (Exception e) { - logger.error("{} {} {}", MessageEnum.GENERAL_EXCEPTION.toString(), MsoLogger.ErrorCode.SchemaError.getValue(), + logger.error("{} {} {}", MessageEnum.GENERAL_EXCEPTION.toString(), ErrorCode.SchemaError.getValue(), e.getMessage(), e); - throw new MarshallerException("Error parsing VNF Adapter response. " + e.getMessage(), MsoLogger.ErrorCode.SchemaError.getValue(), e); + throw new MarshallerException("Error parsing VNF Adapter response. " + e.getMessage(), ErrorCode.SchemaError.getValue(), e); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java index 4b4b3eca23..876a555b10 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java @@ -37,8 +37,8 @@ import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -137,7 +137,7 @@ public class AppcRunTasks { catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "Caught exception in runAppcCommand", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "APPC Error", e); + ErrorCode.UnknownError.getValue(), "APPC Error", e); appcMessage = e.getMessage(); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java index 6c0cdb39f6..717d0deff6 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/ConfigurationScaleOut.java @@ -39,8 +39,8 @@ import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -155,7 +155,7 @@ public class ConfigurationScaleOut { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "Caught exception in runAppcCommand in ConfigurationScaleOut", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "APPC Error", e); + ErrorCode.UnknownError.getValue(), "APPC Error", e); appcMessage = e.getMessage(); } logger.error("Error Message: " + appcMessage); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java index feb9fb81b4..ce14bde0b3 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheck.java @@ -34,8 +34,8 @@ import org.onap.so.client.appc.ApplicationControllerAction; import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.catalog.beans.ControllerSelectionReference; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -111,7 +111,7 @@ public class GenericVnfHealthCheck { appcMessage = appCClient.getErrorMessage(); } catch (BpmnError ex) { logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - "Caught exception in GenericVnfHealthCheck", "BPMN", MsoLogger.ErrorCode.UnknownError.getValue(), ex); + "Caught exception in GenericVnfHealthCheck", "BPMN", ErrorCode.UnknownError.getValue(), ex); appcMessage = ex.getMessage(); exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } catch (Exception e) { @@ -120,13 +120,13 @@ public class GenericVnfHealthCheck { appcMessage = "Request to APPC timed out. "; logger.error("{} {} {} {} {}", MessageEnum.RA_CONNECTION_EXCEPTION.toString(), "Caught timedOut exception in runAppcCommand in GenericVnfHealthCheck", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "APPC Error", e); + ErrorCode.UnknownError.getValue(), "APPC Error", e); throw e; } else { logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "Caught exception in runAppcCommand in GenericVnfHealthCheck", "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), "APPC Error", e); + ErrorCode.UnknownError.getValue(), "APPC Error", e); appcMessage = e.getMessage(); exceptionUtil.buildAndThrowWorkflowException(execution, Integer.parseInt(appcCode), appcMessage); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtils.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtils.java index 945c693d47..217a60b60a 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtils.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/NetworkBBUtils.java @@ -26,7 +26,6 @@ import java.util.Optional; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; -import org.onap.so.logger.MsoLogger; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java index 2fba3b3b25..9214635602 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasks.java @@ -11,14 +11,16 @@ import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.ticket.ExternalTicket; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class ManualHandlingTasks { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, ManualHandlingTasks.class); + private static final Logger logger = LoggerFactory.getLogger(ManualHandlingTasks.class); private static final String TASK_TYPE_PAUSE = "pause"; private static final String TASK_TYPE_FALLOUT = "fallout"; @@ -34,7 +36,7 @@ public class ManualHandlingTasks { DelegateExecution execution = task.getExecution(); try { String taskId = task.getId(); - msoLogger.debug("taskId is: " + taskId); + logger.debug("taskId is: " + taskId); String type = TASK_TYPE_FALLOUT; String nfRole = (String) execution.getVariable("vnfType"); String subscriptionServiceType = (String) execution.getVariable("serviceType"); @@ -66,13 +68,13 @@ public class ManualHandlingTasks { TaskService taskService = execution.getProcessEngineServices().getTaskService(); taskService.setVariables(taskId, taskVariables); - msoLogger.debug("successfully created fallout task: "+ taskId); + logger.debug("successfully created fallout task: "+ taskId); } catch (BpmnError e) { - msoLogger.debug("BPMN exception: " + e.getMessage()); + logger.debug("BPMN exception: " + e.getMessage()); throw e; } catch (Exception ex){ String msg = "Exception in setFalloutTaskVariables " + ex.getMessage(); - msoLogger.debug(msg); + logger.debug(msg); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } } @@ -83,7 +85,7 @@ public class ManualHandlingTasks { try { String taskId = task.getId(); - msoLogger.debug("taskId is: " + taskId); + logger.debug("taskId is: " + taskId); String type = TASK_TYPE_PAUSE; String nfRole = (String) execution.getVariable("vnfType"); String subscriptionServiceType = (String) execution.getVariable("serviceType"); @@ -115,13 +117,13 @@ public class ManualHandlingTasks { TaskService taskService = execution.getProcessEngineServices().getTaskService(); taskService.setVariables(taskId, taskVariables); - msoLogger.debug("successfully created pause task: "+ taskId); + logger.debug("successfully created pause task: "+ taskId); } catch (BpmnError e) { - msoLogger.debug("BPMN exception: " + e.getMessage()); + logger.debug("BPMN exception: " + e.getMessage()); throw e; } catch (Exception ex){ String msg = "Exception in setPauseTaskVariables " + ex.getMessage(); - msoLogger.debug(msg); + logger.debug(msg); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } @@ -134,24 +136,24 @@ public class ManualHandlingTasks { try { String taskId = task.getId(); - msoLogger.debug("taskId is: " + taskId); + logger.debug("taskId is: " + taskId); TaskService taskService = execution.getProcessEngineServices().getTaskService(); Map<String, Object> taskVariables = taskService.getVariables(taskId); String responseValue = (String) taskVariables.get("responseValue"); - msoLogger.debug("Received responseValue on completion: "+ responseValue); + logger.debug("Received responseValue on completion: "+ responseValue); // Have to set the first letter of the response to upper case String responseValueUppercaseStart = responseValue.substring(0, 1).toUpperCase() + responseValue.substring(1); - msoLogger.debug("ResponseValue to taskListener: "+ responseValueUppercaseStart); + logger.debug("ResponseValue to taskListener: "+ responseValueUppercaseStart); execution.setVariable("responseValueTask", responseValueUppercaseStart); } catch (BpmnError e) { - msoLogger.debug("BPMN exception: " + e.getMessage()); + logger.debug("BPMN exception: " + e.getMessage()); throw e; } catch (Exception ex){ String msg = "Exception in completeManualTask " + ex.getMessage(); - msoLogger.debug(msg); + logger.debug(msg); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg); } @@ -177,10 +179,10 @@ public class ManualHandlingTasks { ticket.createTicket(); } catch (BpmnError e) { String msg = "BPMN error in createAOTSTicket " + e.getMessage(); - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.ErrorCode.UnknownError, ""); + logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", ErrorCode.UnknownError.getValue()); } catch (Exception ex){ String msg = "Exception in createExternalTicket " + ex.getMessage(); - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.ErrorCode.UnknownError, ""); + logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", ErrorCode.UnknownError.getValue()); } } @@ -195,7 +197,7 @@ public class ManualHandlingTasks { requestDbclient.updateInfraActiveRequests(request); } catch (Exception e) { - msoLogger.error("Unable to save the updated request status to the DB",e); + logger.error("Unable to save the updated request status to the DB",e); } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 877a0dded7..482957e006 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -368,7 +368,8 @@ public class WorkflowActionBBTasks { ExecuteBuildingBlock ebb, List<ExecuteBuildingBlock> flowsToExecute) { try { String vnfId = ebb.getWorkflowResourceIds().getVnfId(); - String vfModuleId = ebb.getWorkflowResourceIds().getVfModuleId(); + String vfModuleId = ebb.getResourceId(); + ebb.getWorkflowResourceIds().setVfModuleId(vfModuleId); String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(); String vfModuleCustomizationUUID = bbInputSetupUtils.getAAIVfModule(vnfId, vfModuleId).getModelCustomizationId(); List<Vnfc> vnfcs = workflowAction.getRelatedResourcesInVfModule(vnfId, vfModuleId, Vnfc.class, AAIObjectType.VNFC); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java index c8eeaa7a2b..518da1fa5f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/aai/mapper/AAIObjectMapper.java @@ -254,6 +254,9 @@ public class AAIObjectMapper { map().setModelCustomizationId(source.getModelInfoConfiguration().getModelCustomizationId()); map().setModelVersionId(source.getModelInfoConfiguration().getModelVersionId()); map().setModelInvariantId(source.getModelInfoConfiguration().getModelInvariantId()); + map().setConfigurationType(source.getModelInfoConfiguration().getConfigurationType()); + map().setConfigurationSubType(source.getModelInfoConfiguration().getConfigurationRole()); + map().setConfigPolicyName(source.getModelInfoConfiguration().getPolicyName()); } }); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java index f917aed39e..8c774d8677 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/network/mapper/NetworkAdapterObjectMapper.java @@ -51,7 +51,6 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoNetwork; import org.onap.so.entity.MsoRequest; -import org.onap.so.logger.MsoLogger; import org.onap.so.openstack.beans.NetworkRollback; import org.onap.so.openstack.beans.RouteTarget; import org.onap.so.openstack.beans.Subnet; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java index 17fa10a186..8456f26239 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/namingservice/NamingClientResponseValidator.java @@ -31,8 +31,8 @@ import org.onap.namingservice.model.NameGenResponse; import org.onap.namingservice.model.NameGenResponseError; import org.onap.namingservice.model.Respelement; import org.onap.so.client.exception.BadResponseException; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; @@ -52,7 +52,7 @@ public class NamingClientResponseValidator { public String validateNameGenResponse(ResponseEntity<NameGenResponse> response) throws BadResponseException { if (response == null) { logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), NO_RESPONSE_FROM_NAMING_SERVICE, - "BPMN", MsoLogger.ErrorCode.UnknownError.getValue(), + "BPMN", ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_NAMING_SERVICE); throw new BadResponseException(NO_RESPONSE_FROM_NAMING_SERVICE); } @@ -62,7 +62,7 @@ public class NamingClientResponseValidator { NameGenResponse responseBody = response.getBody(); if (responseBody == null) { logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), NULL_RESPONSE_FROM_NAMING_SERVICE, - "BPMN", MsoLogger.ErrorCode.UnknownError.getValue(), + "BPMN", ErrorCode.UnknownError.getValue(), NULL_RESPONSE_FROM_NAMING_SERVICE); throw new BadResponseException(NULL_RESPONSE_FROM_NAMING_SERVICE); } @@ -92,7 +92,7 @@ public class NamingClientResponseValidator { } String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString); logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN", - MsoLogger.ErrorCode.DataError.getValue(), errorMessage); + ErrorCode.DataError.getValue(), errorMessage); throw new BadResponseException(errorMessage); } } @@ -100,7 +100,7 @@ public class NamingClientResponseValidator { public String validateNameGenDeleteResponse(ResponseEntity<NameGenDeleteResponse> response) throws BadResponseException { if (response == null) { logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), NO_RESPONSE_FROM_NAMING_SERVICE, - "BPMN", MsoLogger.ErrorCode.UnknownError.getValue(), + "BPMN", ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_NAMING_SERVICE); throw new BadResponseException(NO_RESPONSE_FROM_NAMING_SERVICE); } @@ -110,7 +110,7 @@ public class NamingClientResponseValidator { NameGenDeleteResponse responseBody = response.getBody(); if (responseBody == null) { logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), NULL_RESPONSE_FROM_NAMING_SERVICE, - "BPMN", MsoLogger.ErrorCode.UnknownError.getValue(), + "BPMN", ErrorCode.UnknownError.getValue(), NULL_RESPONSE_FROM_NAMING_SERVICE); throw new BadResponseException(NULL_RESPONSE_FROM_NAMING_SERVICE); } @@ -123,7 +123,7 @@ public class NamingClientResponseValidator { String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString); logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN", - MsoLogger.ErrorCode.DataError.getValue(), errorMessage); + ErrorCode.DataError.getValue(), errorMessage); throw new BadResponseException(errorMessage); } } @@ -143,7 +143,7 @@ public class NamingClientResponseValidator { } String errorMessage = String.format(NAMING_SERVICE_ERROR, errorMessageString); logger.error("{} {} {} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), errorMessage, "BPMN", - MsoLogger.ErrorCode.DataError.getValue(), errorMessage); + ErrorCode.DataError.getValue(), errorMessage); return errorMessage; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java index 3bb1d81e27..138a20b609 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIConfigurationResources.java @@ -165,7 +165,7 @@ public class AAIConfigurationResources { injectionHelper.getAaiClient().connect(configurationURI, vpnBindingURI); } - public void connectConfigurationToVfModule(String configurationId, String vfModuleId, String vnfId){ + public void connectConfigurationToVfModule(String configurationId, String vnfId, String vfModuleId){ AAIResourceUri configurationURI = AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId); AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId); injectionHelper.getAaiClient().connect(configurationURI, vfModuleURI); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java index 0c65abfe0c..48a1c1e558 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIVnfResources.java @@ -22,6 +22,7 @@ package org.onap.so.client.orchestration; +import java.io.IOException; import java.util.Optional; import org.onap.so.bpmn.common.InjectionHelper; @@ -31,6 +32,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.client.aai.AAIObjectType; +import org.onap.so.client.aai.AAIValidatorImpl; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; @@ -50,6 +52,8 @@ public class AAIVnfResources { @Autowired private AAIObjectMapper aaiObjectMapper; + private AAIValidatorImpl aaiValidatorImpl= new AAIValidatorImpl(); + public void createVnfandConnectServiceInstance(GenericVnf vnf, ServiceInstance serviceInstance) { AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); vnf.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); @@ -125,4 +129,19 @@ public class AAIVnfResources { AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnf.getVnfId()); injectionHelper.getAaiClient().connect(tenantURI, vnfURI); } + + public boolean checkVnfClosedLoopDisabledFlag(String vnfId) { + org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient() + .get(org.onap.aai.domain.yang.GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)) + .orElse(new org.onap.aai.domain.yang.GenericVnf()); + return vnf.isIsClosedLoopDisabled(); + } + + public boolean checkVnfPserversLockedFlag (String vnfId) throws IOException { + org.onap.aai.domain.yang.GenericVnf vnf = injectionHelper.getAaiClient() + .get(org.onap.aai.domain.yang.GenericVnf.class, AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)) + .orElse(new org.onap.aai.domain.yang.GenericVnf()); + return aaiValidatorImpl.isPhysicalServerLocked(vnf.getVnfId()); + + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java index 6867cb8ebb..8f3445529e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/NetworkAdapterResources.java @@ -43,7 +43,6 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.adapter.network.NetworkAdapterClientException; import org.onap.so.client.adapter.network.NetworkAdapterClientImpl; import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper; -import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java index 8513b26a5d..418e70a09e 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/SdnCommonTasks.java @@ -30,8 +30,8 @@ import org.apache.commons.lang.StringUtils; import org.apache.http.HttpStatus; import org.onap.so.client.exception.BadResponseException; import org.onap.so.client.exception.MapperException; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpHeaders; @@ -69,7 +69,7 @@ public class SdnCommonTasks { } catch (JsonProcessingException e) { logger.error("{} {} {} {} {}", MessageEnum.JAXB_EXCEPTION.toString(), COULD_NOT_CONVERT_SDNC_POJO_TO_JSON, - "BPMN", MsoLogger.ErrorCode.DataError.getValue(), e.getMessage()); + "BPMN", ErrorCode.DataError.getValue(), e.getMessage()); throw new MapperException(COULD_NOT_CONVERT_SDNC_POJO_TO_JSON); } jsonRequest = "{\"input\":" + jsonRequest + "}"; @@ -101,7 +101,7 @@ public class SdnCommonTasks { public String validateSDNResponse(LinkedHashMap<String, Object> output) throws BadResponseException { if (CollectionUtils.isEmpty(output)) { logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC); + ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC); throw new BadResponseException(NO_RESPONSE_FROM_SDNC); } LinkedHashMap<String, Object> embeddedResponse =(LinkedHashMap<String, Object>) output.get("output"); @@ -128,7 +128,7 @@ public class SdnCommonTasks { } else { String errorMessage = String.format(SDNC_CODE_NOT_0_OR_IN_200_299, responseMessage); logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), errorMessage, "BPMN", - MsoLogger.ErrorCode.DataError.getValue(), errorMessage); + ErrorCode.DataError.getValue(), errorMessage); throw new BadResponseException(errorMessage); } } @@ -142,7 +142,7 @@ public class SdnCommonTasks { public String validateSDNGetResponse(LinkedHashMap<String, Object> output) throws BadResponseException { if (CollectionUtils.isEmpty(output)) { logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), NO_RESPONSE_FROM_SDNC, "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC); + ErrorCode.UnknownError.getValue(), NO_RESPONSE_FROM_SDNC); throw new BadResponseException(NO_RESPONSE_FROM_SDNC); } ObjectMapper objMapper = new ObjectMapper(); @@ -153,7 +153,7 @@ public class SdnCommonTasks { } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), BAD_RESPONSE_FROM_SDNC, - "BPMN", MsoLogger.ErrorCode.UnknownError.getValue(), + "BPMN", ErrorCode.UnknownError.getValue(), BAD_RESPONSE_FROM_SDNC); throw new BadResponseException(BAD_RESPONSE_FROM_SDNC); } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java index 5124435a79..b8c5fad41d 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/mapper/VfModuleTopologyOperationRequestMapper.java @@ -47,8 +47,8 @@ import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.client.exception.MapperException; import org.onap.so.client.sdnc.beans.SDNCSvcAction; import org.onap.so.client.sdnc.beans.SDNCSvcOperation; +import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; -import org.onap.so.logger.MsoLogger; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -174,7 +174,7 @@ public class VfModuleTopologyOperationRequestMapper { objectPath = assignResponseInfo.getVfModuleResponseInformation().getObjectPath(); } catch (Exception e) { logger.error("{} {} {} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), e.getMessage(), "BPMN", - MsoLogger.ErrorCode.UnknownError.getValue(), e.getMessage()); + ErrorCode.UnknownError.getValue(), e.getMessage()); } } return objectPath; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java index cf28c114e8..cad97cad6e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/common/aai/tasks/AAIFlagTasksTest.java @@ -29,6 +29,8 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.io.IOException; + import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; import org.junit.Test; @@ -119,4 +121,89 @@ public class AAIFlagTasksTest extends BaseTaskTest { verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class)); } } + + @Test + public void checkVnfClosedLoopDisabledTestTrue() throws Exception { + doThrow(new BpmnError("VNF Closed Loop Disabled in A&AI")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class)); + doReturn(false).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class)); + try { + aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution); + } catch (Exception e) { + verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class)); + verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), eq("VNF Closed Loop Disabled in A&AI")); + } + } + + @Test + public void checkVnfClosedLoopDisabledTestFalse() throws Exception { + doReturn(false).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class)); + aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution); + verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), any(int.class), any(String.class)); + } + + @Test + public void checkVnfClosedLoopDisabledFlagExceptionTest() { + + doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class)); + doThrow(RuntimeException.class).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class)); + try { + aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution); + } catch (Exception e) { + verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class)); + verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class)); + } + } + + @Test + public void modifyVnfClosedLoopDisabledFlagTest() throws Exception { + doNothing().when(aaiVnfResources).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class)); + aaiFlagTasks.modifyVnfClosedLoopDisabledFlag(execution, true); + verify(aaiVnfResources, times(1)).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class)); + } + + @Test + public void modifyVnfClosedLoopDisabledFlagExceptionTest() { + + doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class)); + doThrow(RuntimeException.class).when(aaiVnfResources).updateObjectVnf(isA(GenericVnf.class)); + try { + aaiFlagTasks.modifyVnfClosedLoopDisabledFlag(execution, true); + } catch (Exception e) { + verify(aaiVnfResources, times(1)).checkVnfClosedLoopDisabledFlag(any(String.class)); + verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class)); + } + } + + + @Test + public void checkVnfPserversLockedFlagTestTrue() throws Exception { + doThrow(new BpmnError("VNF PServers in Locked in A&AI")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class)); + doReturn(true).when(aaiVnfResources).checkVnfPserversLockedFlag(isA(String.class)); + try { + aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution); + } catch (Exception e) { + verify(aaiVnfResources, times(1)).checkVnfPserversLockedFlag(any(String.class)); + verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), eq("VNF PServers in Locked in A&AI")); + } + } + + @Test + public void checkVnfPserversLockedFlagTestFalse() throws Exception { + doReturn(false).when(aaiVnfResources).checkVnfPserversLockedFlag(isA(String.class)); + aaiFlagTasks.checkVnfPserversLockedFlag(execution); + verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), any(int.class), any(String.class)); + } + + @Test + public void checkVnfPserversLockedFlagExceptionTest() throws IOException { + + doThrow(new BpmnError("Unknown Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class)); + doThrow(RuntimeException.class).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class)); + try { + aaiFlagTasks.checkVnfPserversLockedFlag(execution); + } catch (Exception e) { + verify(aaiVnfResources, times(1)).checkVnfPserversLockedFlag(any(String.class)); + verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class)); + } + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java index a8e9a7e57e..d5b529288f 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/aai/mapper/AAIObjectMapperTest.java @@ -74,24 +74,27 @@ public class AAIObjectMapperTest { Configuration configuration = new Configuration(); configuration.setConfigurationId("configId"); configuration.setConfigurationName("VNR"); - configuration.setConfigurationType("VNR-TYPE"); configuration.setOrchestrationStatus(OrchestrationStatus.ASSIGNED); configuration.setManagementOption("managementOption"); ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration(); modelInfoConfiguration.setModelCustomizationId("modelCustId"); modelInfoConfiguration.setModelInvariantId("modelInvariantId"); modelInfoConfiguration.setModelVersionId("modelVersionId"); + modelInfoConfiguration.setConfigurationType("5G"); + modelInfoConfiguration.setConfigurationRole("ConfigurationRole"); configuration.setModelInfoConfiguration(modelInfoConfiguration); org.onap.aai.domain.yang.Configuration expectedConfiguration = new org.onap.aai.domain.yang.Configuration(); expectedConfiguration.setConfigurationId(configuration.getConfigurationId()); expectedConfiguration.setConfigurationName(configuration.getConfigurationName()); - expectedConfiguration.setConfigurationType(configuration.getConfigurationType()); + expectedConfiguration.setConfigurationType(configuration.getModelInfoConfiguration().getConfigurationType()); expectedConfiguration.setOrchestrationStatus(configuration.getOrchestrationStatus().toString()); expectedConfiguration.setManagementOption(configuration.getManagementOption()); expectedConfiguration.setModelInvariantId(configuration.getModelInfoConfiguration().getModelInvariantId()); expectedConfiguration.setModelVersionId(configuration.getModelInfoConfiguration().getModelVersionId()); expectedConfiguration.setModelCustomizationId(configuration.getModelInfoConfiguration().getModelCustomizationId()); + expectedConfiguration.setConfigurationSubType(configuration.getModelInfoConfiguration().getConfigurationRole()); + expectedConfiguration.setConfigPolicyName(configuration.getModelInfoConfiguration().getPolicyName()); org.onap.aai.domain.yang.Configuration actualConfiguration = aaiObjectMapper.mapConfiguration(configuration); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java index b87b5e4166..d499bcd36e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIVnfResourcesTest.java @@ -21,6 +21,7 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; @@ -29,6 +30,7 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import java.io.IOException; import java.util.Optional; import org.junit.Before; @@ -47,6 +49,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.AAIResourcesClient; +import org.onap.so.client.aai.AAIValidatorImpl; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.aai.mapper.AAIObjectMapper; @@ -70,6 +73,9 @@ public class AAIVnfResourcesTest extends TestDataSetup { @Mock protected InjectionHelper MOCK_injectionHelper; + @Mock + protected AAIValidatorImpl MOCK_aaiValidatorImpl; + @InjectMocks AAIVnfResources aaiVnfResources = new AAIVnfResources(); @@ -182,4 +188,29 @@ public class AAIVnfResourcesTest extends TestDataSetup { eq(AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudRegion.getCloudOwner(), cloudRegion.getLcpCloudRegionId()))); } + + + @Test + public void checkVnfClosedLoopDisabledFlagTest () { + Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf()); + vnf.get().setVnfId("vnfId"); + vnf.get().setIsClosedLoopDisabled(true); + doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class)); + boolean isCheckVnfClosedLoopDisabledFlag = aaiVnfResources.checkVnfClosedLoopDisabledFlag("vnfId"); + verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class)); + assertEquals(isCheckVnfClosedLoopDisabledFlag, true); + } + + @Test + public void checkVnfPserversLockedFlagTest () throws IOException { + + Optional<org.onap.aai.domain.yang.GenericVnf> vnf = Optional.of(new org.onap.aai.domain.yang.GenericVnf()); + vnf.get().setVnfId("vnfId"); + doReturn(vnf).when(MOCK_aaiResourcesClient).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class)); + doReturn(true).when(MOCK_aaiValidatorImpl).isPhysicalServerLocked("vnfId"); + boolean isVnfPserversLockedFlag = aaiVnfResources.checkVnfPserversLockedFlag("vnfId"); + verify(MOCK_aaiResourcesClient, times(1)).get(eq(org.onap.aai.domain.yang.GenericVnf.class),isA(AAIResourceUri.class)); + verify(MOCK_aaiValidatorImpl, times(1)).isPhysicalServerLocked(isA(String.class)); + assertTrue(isVnfPserversLockedFlag); + } } |