diff options
40 files changed, 1124 insertions, 920 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index f5c7cd65c2..ede499f9ee 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -873,3 +873,25 @@ VALUES UPDATE vnf_recipe SET ORCHESTRATION_URI = '/mso/async/services/WorkflowActionBB' WHERE NF_ROLE = 'GR-API-DEFAULT' AND ACTION = 'inPlaceSoftwareUpdate'; + +INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY, SECONDARY_POLICY, REG_EX_ERROR_MESSAGE, SERVICE_ROLE) +VALUES +('VNFCheckPserversLockedFlagActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFCheckInMaintFlagActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFSetInMaintFlagActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFCheckClosedLoopDisabledFlagActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFSetClosedLoopDisabledFlagActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFLockActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFUpgradePreCheckActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFQuiesceTrafficActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFStopActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFSnapShotActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFStartActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFUpgradeBackupActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFUpgradeSoftwareActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFUpgradePostCheckActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFResumeTrafficActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFUnlockActivity','*','*','*','*','Manual','Abort','*', '*'), +('SDNOVnfHealthCheckBB','*','*','*','*','Manual','Abort','*', '*'), +('VNFUnsetInMaintFlagActivity','*','*','*','*','Manual','Abort','*', '*'), +('VNFUnsetClosedLoopDisabledActivity','*','*','*','*','Manual','Abort','*', '*'); diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java index 32c2559d7b..cc56048262 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java @@ -21,15 +21,38 @@ package org.onap.so.adapters.vevnfm.configuration; import org.onap.so.security.SoBasicWebSecurityConfigurerAdapter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.crypto.password.PasswordEncoder; @Configuration +@EnableWebSecurity public class SecurityConfiguration extends SoBasicWebSecurityConfigurerAdapter { + @Value("${notification.url}") + private String notificationUrl; + + @Value("${notification.username}") + private String notificationUsername; + + @Value("${notification.password}") + private String notificationPassword; + + @Autowired + private PasswordEncoder passwordEncoder; + + @Override + protected void configure(final HttpSecurity https) throws Exception { + https.csrf().disable().authorizeRequests().antMatchers(notificationUrl).authenticated().and().httpBasic(); + } + @Override - protected void configure(final HttpSecurity http) throws Exception { - http.authorizeRequests().antMatchers().permitAll().and().requestMatchers().antMatchers("/").and() - .authorizeRequests().anyRequest().authenticated(); + protected void configure(final AuthenticationManagerBuilder auth) throws Exception { + auth.inMemoryAuthentication().withUser(notificationUsername) + .password(passwordEncoder.encode(notificationPassword)).authorities("ROLE_USER"); } } diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java index e413124b4b..aa07ed65a2 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java @@ -20,6 +20,7 @@ package org.onap.so.adapters.vevnfm.service; +import java.util.Collections; import org.onap.so.adapters.vevnfm.subscription.SubscribeSender; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthentication; @@ -33,14 +34,20 @@ public class SubscriberService { private static final char COLON = ':'; - @Value("${notification.url}") - private String notificationUrl; + @Value("${system.url}") + private String systemUrl; @Value("${server.port}") private String serverPort; - @Value("${system.url}") - private String systemUrl; + @Value("${notification.url}") + private String notificationUrl; + + @Value("${notification.username}") + private String notificationUsername; + + @Value("${notification.password}") + private String notificationPassword; @Autowired private SubscribeSender sender; @@ -55,6 +62,9 @@ public class SubscriberService { request.callbackUri(getCallbackUri()); final SubscriptionsAuthenticationParamsBasic paramsBasic = new SubscriptionsAuthenticationParamsBasic(); final SubscriptionsAuthentication authentication = new SubscriptionsAuthentication(); + paramsBasic.setUserName(notificationUsername); + paramsBasic.setPassword(notificationPassword); + authentication.setAuthType(Collections.singletonList(SubscriptionsAuthentication.AuthTypeEnum.BASIC)); authentication.setParamsBasic(paramsBasic); request.authentication(authentication); diff --git a/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml b/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml index 12197d737d..b16fa6348f 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml +++ b/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml @@ -22,6 +22,8 @@ system: notification: url: /lcm/v1/vnf/instances/notifications + username: admin + password: a4b3c2d1 mso: key: 07a7159d3bf51a0e53be7a8f89699be7 diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java index 181d114cc0..db70a6b5cb 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java @@ -4,6 +4,7 @@ import org.camunda.bpm.client.task.ExternalTask; import org.camunda.bpm.client.task.ExternalTaskService; import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback; import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport; +import org.onap.so.adapters.appc.orchestrator.client.StatusCategory; import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest; import org.onap.so.externaltasks.logging.AuditMDCSetup; import org.onap.so.utils.ExternalTaskUtils; @@ -42,8 +43,16 @@ public class ApplicationControllerTask extends ExternalTaskUtils { try { status = applicationControllerTaskImpl.execute(msoRequestId, request, listener); + if (status != null && status.getCode() != 0 + && !applicationControllerSupport.getCategoryOf(status).equals(StatusCategory.NORMAL)) { + logger.error("The External Task Id: {} Failed locally with status {}", externalTask.getId(), + status.getMessage()); + externalTaskService.handleBpmnError(externalTask, "MSOWorkflowException", status.getMessage()); + } } catch (Exception e) { - logger.error("Error while calling appc", e.getMessage()); + logger.error("The External Task Id: {} Failed while calling appc with exception", externalTask.getId(), + e.getMessage()); + externalTaskService.handleBpmnError(externalTask, "MSOWorkflowException", e.getMessage()); } } diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy index ef4291d18f..615964b2a9 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/ManualHandling.groovy @@ -45,7 +45,6 @@ import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.domain.ServiceDecomposition import org.onap.so.bpmn.core.json.JsonUtils -import org.onap.so.client.ruby.* import org.onap.so.logger.MessageEnum import org.slf4j.Logger import org.slf4j.LoggerFactory @@ -299,59 +298,4 @@ public class ManualHandling extends AbstractServiceTaskProcessor { logger.trace("Exit prepareRequestsDBStatusUpdate of ManualHandling ") } - public void createAOTSTicket (DelegateExecution execution) { - String msg = "" - logger.trace("createAOTSTicket of ManualHandling ") - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - // This method will not be throwing an exception, but rather log the error - - try { - execution.setVariable("prefix", Prefix) - setBasicDBAuthHeader(execution,isDebugLogEnabled) - // check for required input - String requestId = execution.getVariable("msoRequestId") - logger.debug("requestId is: " + requestId) - def currentActivity = execution.getVariable("currentActivity") - logger.debug("currentActivity is: " + currentActivity) - def workStep = execution.getVariable("workStep") - logger.debug("workStep is: " + workStep) - def failedActivity = execution.getVariable("failedActivity") - logger.debug("failedActivity is: " + failedActivity) - def errorCode = execution.getVariable("errorCode") - logger.debug("errorCode is: " + errorCode) - def errorText = execution.getVariable("errorText") - logger.debug("errorText is: " + errorText) - def vnfName = execution.getVariable("vnfName") - logger.debug("vnfName is: " + vnfName) - - String rubyRequestId = UUID.randomUUID() - logger.debug("rubyRequestId: " + rubyRequestId) - String sourceName = vnfName - logger.debug("sourceName: " + sourceName) - String reason = "VID Workflow failed at " + failedActivity + " " + workStep + " call with error " + errorCode - logger.debug("reason: " + reason) - String workflowId = requestId - logger.debug("workflowId: " + workflowId) - String notification = "Request originated from VID | Workflow fallout on " + vnfName + " | Workflow step failure: " + workStep + " failed | VID workflow ID: " + workflowId - logger.debug("notification: " + notification) - - logger.debug("Creating AOTS Ticket request") - - RubyClient rubyClient = new RubyClient() - rubyClient.rubyCreateTicketCheckRequest(rubyRequestId, sourceName, reason, workflowId, notification) - - } catch (BpmnError e) { - msg = "BPMN error in createAOTSTicket " + ex.getMessage() - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - } catch (Exception ex){ - msg = "Exception in createAOTSTicket " + ex.getMessage() - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - } - logger.trace("Exit createAOTSTicket of ManualHandling ") - } - - - } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java index ae7addcc57..99767b0405 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildingBlockRainyDay.java @@ -49,6 +49,9 @@ public class ExecuteBuildingBlockRainyDay { private static final Logger logger = LoggerFactory.getLogger(ExecuteBuildingBlockRainyDay.class); public static final String HANDLING_CODE = "handlingCode"; public static final String ROLLBACK_TARGET_STATE = "rollbackTargetState"; + public static final String RAINY_DAY_SERVICE_TYPE = "rainyDayServiceType"; + public static final String RAINY_DAY_VNF_TYPE = "rainyDayVnfType"; + public static final String RAINY_DAY_VNF_NAME = "rainyDayVnfName"; @Autowired private CatalogDbClient catalogDbClient; @@ -97,8 +100,10 @@ public class ExecuteBuildingBlockRainyDay { handlingCode = "Abort"; } else { try { - serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) - .getModelInfoServiceInstance().getServiceType(); + if (gBBInput.getCustomer().getServiceSubscription() != null) { + serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) + .getModelInfoServiceInstance().getServiceType(); + } if (serviceType == null || serviceType.isEmpty()) { serviceType = ASTERISK; } @@ -106,19 +111,32 @@ public class ExecuteBuildingBlockRainyDay { // keep default serviceType value logger.error("Exception in serviceType retrieval", ex); } + execution.setVariable(RAINY_DAY_SERVICE_TYPE, serviceType); String vnfType = ASTERISK; + String vnfName = ASTERISK; try { - for (GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) - .getVnfs()) { - if (vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { - vnfType = vnf.getVnfType(); + if (gBBInput.getCustomer().getServiceSubscription() != null) { + for (GenericVnf vnf : gBBInput.getCustomer().getServiceSubscription().getServiceInstances() + .get(0).getVnfs()) { + if (vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + vnfType = vnf.getVnfType(); + vnfName = vnf.getVnfName(); + } + } + } else { + for (GenericVnf vnf : gBBInput.getServiceInstance().getVnfs()) { + if (vnf.getVnfId().equalsIgnoreCase(lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID))) { + vnfType = vnf.getVnfType(); + vnfName = vnf.getVnfName(); + } } } } catch (Exception ex) { // keep default vnfType value logger.error("Exception in vnfType retrieval", ex); } - + execution.setVariable(RAINY_DAY_VNF_TYPE, vnfType); + execution.setVariable(RAINY_DAY_VNF_NAME, vnfName); String errorCode = ASTERISK; if (workflowException != null) { errorCode = "" + workflowException.getErrorCode(); @@ -151,8 +169,10 @@ public class ExecuteBuildingBlockRainyDay { String serviceRole = ASTERISK; try { - serviceRole = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) - .getModelInfoServiceInstance().getServiceRole(); + if (gBBInput.getCustomer().getServiceSubscription() != null) { + serviceRole = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) + .getModelInfoServiceInstance().getServiceRole(); + } if (serviceRole == null || serviceRole.isEmpty()) { serviceRole = ASTERISK; } diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/ManualHandling.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/ManualHandling.bpmn index cec3e249ea..0115c078f3 100644 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/ManualHandling.bpmn +++ b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/BuildingBlock/ManualHandling.bpmn @@ -43,11 +43,11 @@ def mh = new ManualHandling() mh.setTaskVariables(task)]]></camunda:script> </camunda:taskListener> </bpmn2:extensionElements> - <bpmn2:incoming>SequenceFlow_0igra4l</bpmn2:incoming> + <bpmn2:incoming>SequenceFlow_0b84ki5</bpmn2:incoming> <bpmn2:outgoing>SequenceFlow_192yimz</bpmn2:outgoing> </bpmn2:userTask> <bpmn2:sequenceFlow id="SequenceFlow_0mbjrvr" sourceRef="Task_137bzdi" targetRef="Task_1kuxfdu" /> - <bpmn2:sequenceFlow id="SequenceFlow_0b84ki5" sourceRef="Task_1kuxfdu" targetRef="CreateAOTSRubyTicket" /> + <bpmn2:sequenceFlow id="SequenceFlow_0b84ki5" sourceRef="Task_1kuxfdu" targetRef="ManualHandlingUserTask" /> <bpmn2:sequenceFlow id="SequenceFlow_0zer29a" sourceRef="Task_0r60vxk" targetRef="Task_02xybqx" /> <bpmn2:sequenceFlow id="SequenceFlow_14cyk9v" sourceRef="Task_02xybqx" targetRef="EndEvent_3" /> <bpmn2:serviceTask id="Task_1kuxfdu" name="Update Infra DB Status to PENDING_MANUAL_TASK"> @@ -116,14 +116,6 @@ def mh = new ManualHandling() mh.preProcessRequest(execution)]]></bpmn2:script> </bpmn2:scriptTask> <bpmn2:sequenceFlow id="SequenceFlow_0zgg47r" sourceRef="Task_1qrt7xw" targetRef="Task_137bzdi" /> - <bpmn2:sequenceFlow id="SequenceFlow_0igra4l" sourceRef="CreateAOTSRubyTicket" targetRef="ManualHandlingUserTask" /> - <bpmn2:scriptTask id="CreateAOTSRubyTicket" name="Create AOTS Ruby Ticket" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_0b84ki5</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_0igra4l</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -def mh = new ManualHandling() -mh.createAOTSTicket(execution)]]></bpmn2:script> - </bpmn2:scriptTask> </bpmn2:process> <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" /> @@ -136,9 +128,9 @@ mh.createAOTSTicket(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="_BPMNShape_EndEvent_177" bpmnElement="EndEvent_3"> - <dc:Bounds x="1286" y="79" width="36" height="36" /> + <dc:Bounds x="1173" y="79" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1304" y="120" width="0" height="0" /> + <dc:Bounds x="1191" y="120" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="SubProcess_06d8lk8_di" bpmnElement="SubProcess_06d8lk8" isExpanded="true"> @@ -181,14 +173,14 @@ mh.createAOTSTicket(execution)]]></bpmn2:script> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_192yimz_di" bpmnElement="SequenceFlow_192yimz"> - <di:waypoint xsi:type="dc:Point" x="944" y="97" /> - <di:waypoint xsi:type="dc:Point" x="982" y="97" /> + <di:waypoint xsi:type="dc:Point" x="778" y="97" /> + <di:waypoint xsi:type="dc:Point" x="839" y="97" /> <bpmndi:BPMNLabel> - <dc:Bounds x="963" y="82" width="0" height="0" /> + <dc:Bounds x="809" y="82" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="UserTask_1krqrz1_di" bpmnElement="ManualHandlingUserTask"> - <dc:Bounds x="844" y="57" width="100" height="80" /> + <dc:Bounds x="678" y="57" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0mbjrvr_di" bpmnElement="SequenceFlow_0mbjrvr"> <di:waypoint xsi:type="dc:Point" x="483" y="97" /> @@ -199,23 +191,25 @@ mh.createAOTSTicket(execution)]]></bpmn2:script> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0b84ki5_di" bpmnElement="SequenceFlow_0b84ki5"> <di:waypoint xsi:type="dc:Point" x="627" y="97" /> - <di:waypoint xsi:type="dc:Point" x="689" y="97" /> + <di:waypoint xsi:type="dc:Point" x="656" y="97" /> + <di:waypoint xsi:type="dc:Point" x="656" y="97" /> + <di:waypoint xsi:type="dc:Point" x="678" y="97" /> <bpmndi:BPMNLabel> - <dc:Bounds x="658" y="82" width="0" height="0" /> + <dc:Bounds x="671" y="97" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0zer29a_di" bpmnElement="SequenceFlow_0zer29a"> - <di:waypoint xsi:type="dc:Point" x="1082" y="97" /> - <di:waypoint xsi:type="dc:Point" x="1128" y="97" /> + <di:waypoint xsi:type="dc:Point" x="939" y="97" /> + <di:waypoint xsi:type="dc:Point" x="995" y="97" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1105" y="82" width="0" height="0" /> + <dc:Bounds x="967" y="82" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_14cyk9v_di" bpmnElement="SequenceFlow_14cyk9v"> - <di:waypoint xsi:type="dc:Point" x="1228" y="97" /> - <di:waypoint xsi:type="dc:Point" x="1286" y="97" /> + <di:waypoint xsi:type="dc:Point" x="1095" y="97" /> + <di:waypoint xsi:type="dc:Point" x="1173" y="97" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1257" y="82" width="0" height="0" /> + <dc:Bounds x="1134" y="82" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_0c0yopb_di" bpmnElement="Task_1kuxfdu"> @@ -225,10 +219,10 @@ mh.createAOTSTicket(execution)]]></bpmn2:script> <dc:Bounds x="383" y="57" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_1mjq23a_di" bpmnElement="Task_0r60vxk"> - <dc:Bounds x="982" y="57" width="100" height="80" /> + <dc:Bounds x="839" y="57" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_1hc2ewj_di" bpmnElement="Task_02xybqx"> - <dc:Bounds x="1128" y="57" width="100" height="80" /> + <dc:Bounds x="995" y="57" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ScriptTask_055s81f_di" bpmnElement="Task_1qrt7xw"> <dc:Bounds x="238" y="57" width="100" height="80" /> @@ -240,16 +234,6 @@ mh.createAOTSTicket(execution)]]></bpmn2:script> <dc:Bounds x="361" y="82" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="SequenceFlow_0igra4l_di" bpmnElement="SequenceFlow_0igra4l"> - <di:waypoint xsi:type="dc:Point" x="789" y="97" /> - <di:waypoint xsi:type="dc:Point" x="844" y="97" /> - <bpmndi:BPMNLabel> - <dc:Bounds x="817" y="82" width="0" height="0" /> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="ScriptTask_0yhlgfw_di" bpmnElement="CreateAOTSRubyTicket"> - <dc:Bounds x="689" y="57" width="100" height="80" /> - </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn2:definitions> diff --git a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml index afdb800ffe..ba2d19b626 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml +++ b/bpmn/MSOCommonBPMN/src/test/resources/application-test.yaml @@ -111,6 +111,9 @@ mso: rainyDay: retryDurationMultiplier: '2' defaultCode: Abort + manualTask: + taskTimeout: PT1M + validResponses: retry,abort,rollback,skip site-name: localDevEnv workflow: default: @@ -189,15 +192,6 @@ sniro: headers.patchVersion: 1 headers.minorVersion: 1 headers.latestVersion: 2 -ruby: - create-ticket-request: - dmaap: - username: m04768@mso.ecomp.att.com - password: alRyMzJ3NUNeakxl - publisher: - topic: com.att.pdas.exp.msoCMFallout-v1 - host: https://olsd004.wnsnet.attws.com:3905 - auth: 81B7E3533B91A6706830611FB9A8ECE529BBCCE754B1F1520FA7C8698B42F97235BEFA993A387E664D6352C63A6185D68DA7F0B1D360637CBA102CB166E3E62C11EB1F75386D3506BCECE51E54 spring: datasource: jdbc-url: jdbc:mariadb://localhost:3307/camundabpmn diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java index 42c6ef059f..869c917cc2 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/WorkflowExceptionPlugin.java @@ -58,6 +58,7 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { private static final Logger logger = LoggerFactory.getLogger(WorkflowExceptionPlugin.class); private static final String WORKFLOW_EXCEPTION = "WorkflowException"; + private static final String PAUSE_FOR_MANUAL_TASK_RAINY_DAY_ID = "PauseForManualTaskRainyDay"; @Override public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) { @@ -89,7 +90,8 @@ public class WorkflowExceptionPlugin extends AbstractProcessEnginePlugin { for (ActivityImpl activity : activities) { String type = (String) activity.getProperty("type"); - if ("callActivity".equals(type)) { + if ("callActivity".equals(type) + && !PAUSE_FOR_MANUAL_TASK_RAINY_DAY_ID.equals(activity.getActivityId())) { // Add a WorkflowExceptionResetListener to clear the WorkflowException // variable when each Call Activity starts. diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivatePnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivatePnfBB.bpmn new file mode 100644 index 0000000000..02675c6127 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ActivatePnfBB.bpmn @@ -0,0 +1,56 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1a52v2f" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.5.0"> + <bpmn:collaboration id="Collaboration_0go8wi3"> + <bpmn:participant id="Participant_1dwc5st" name="SO Activate PNF" processRef="ActivatePnfBB" /> + <bpmn:participant id="Participant_0gycee4" name="AAI" /> + <bpmn:messageFlow id="MessageFlow_0xh6bkn" sourceRef="UpdatePnfOrchestrationStatusToActive" targetRef="Participant_0gycee4" /> + </bpmn:collaboration> + <bpmn:process id="ActivatePnfBB" name="ActivatePnfBB" isExecutable="true"> + <bpmn:sequenceFlow id="SequenceFlow_0l6rtzy" sourceRef="UpdatePnfOrchestrationStatusToActive" targetRef="PnfActive" /> + <bpmn:sequenceFlow id="SequenceFlow_1fu9o4x" sourceRef="AssignPnf_StartEvent" targetRef="UpdatePnfOrchestrationStatusToActive" /> + <bpmn:endEvent id="PnfActive" name="Pnf Active"> + <bpmn:incoming>SequenceFlow_0l6rtzy</bpmn:incoming> + </bpmn:endEvent> + <bpmn:serviceTask id="UpdatePnfOrchestrationStatusToActive" name="Update Pnf Orchestration Status to Active" camunda:expression="${AAIUpdateTasks.updateOrchestrationStatusActivePnf(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn:incoming>SequenceFlow_1fu9o4x</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0l6rtzy</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:startEvent id="AssignPnf_StartEvent"> + <bpmn:outgoing>SequenceFlow_1fu9o4x</bpmn:outgoing> + </bpmn:startEvent> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0go8wi3"> + <bpmndi:BPMNShape id="Participant_1dwc5st_di" bpmnElement="Participant_1dwc5st" isHorizontal="true"> + <dc:Bounds x="160" y="80" width="646" height="391" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Participant_0gycee4_di" bpmnElement="Participant_0gycee4" isHorizontal="true"> + <dc:Bounds x="260" y="567" width="502" height="60" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1ix8822_di" bpmnElement="UpdatePnfOrchestrationStatusToActive"> + <dc:Bounds x="461" y="247" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="StartEvent_1g3euow_di" bpmnElement="AssignPnf_StartEvent"> + <dc:Bounds x="219" y="269" width="36" height="36" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="MessageFlow_0xh6bkn_di" bpmnElement="MessageFlow_0xh6bkn"> + <di:waypoint x="511" y="327" /> + <di:waypoint x="511" y="567" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_1wfgsdz_di" bpmnElement="PnfActive"> + <dc:Bounds x="722" y="269" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="717" y="312" width="50" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0l6rtzy_di" bpmnElement="SequenceFlow_0l6rtzy"> + <di:waypoint x="561" y="287" /> + <di:waypoint x="722" y="287" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1fu9o4x_di" bpmnElement="SequenceFlow_1fu9o4x"> + <di:waypoint x="255" y="287" /> + <di:waypoint x="461" y="287" /> + </bpmndi:BPMNEdge> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn index e64c44eb94..443a571312 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ExecuteBuildingBlock.bpmn @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.10.0"> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0"> <bpmn:process id="ExecuteBuildingBlock" name="ExecuteBuildingBlock" isExecutable="true"> <bpmn:startEvent id="Start_ExecuteBuildingBlock" name="start"> <bpmn:outgoing>SequenceFlow_0rq4c5r</bpmn:outgoing> @@ -44,8 +44,12 @@ </bpmn:serviceTask> <bpmn:exclusiveGateway id="ExclusiveGateway_1aonzik" name="Check HandlingCode" default="SequenceFlow_0h8v45y"> <bpmn:incoming>SequenceFlow_0a62t4c</bpmn:incoming> + <bpmn:incoming>SequenceFlow_05le7o3</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0fwsjva</bpmn:outgoing> <bpmn:outgoing>SequenceFlow_0h8v45y</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1xh5ngw</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_0xyd2zl</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1g7oq3t</bpmn:outgoing> </bpmn:exclusiveGateway> <bpmn:intermediateCatchEvent id="IntermediateCatchEvent_RetryTimer" name="RetryTimer"> <bpmn:incoming>SequenceFlow_0ndt8ft</bpmn:incoming> @@ -87,6 +91,7 @@ </bpmn:endEvent> <bpmn:serviceTask id="Task_QuerySecondaryPolicy" name="Query Secondary Policy" camunda:expression="${ExecuteBuildingBlockRainyDay.queryRainyDayTable(execution,false)}"> <bpmn:incoming>SequenceFlow_0541bid</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1g7oq3t</bpmn:incoming> <bpmn:outgoing>SequenceFlow_12ps9at</bpmn:outgoing> </bpmn:serviceTask> <bpmn:sequenceFlow id="SequenceFlow_0vdeqxv" sourceRef="Task_UpdateExtErrorSource" targetRef="Task_QueryRainyDayTable" /> @@ -99,6 +104,36 @@ <bpmn:incoming>SequenceFlow_09synl9</bpmn:incoming> <bpmn:outgoing>SequenceFlow_0vdeqxv</bpmn:outgoing> </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_05le7o3" sourceRef="PauseForManualTaskRainyDay" targetRef="ExclusiveGateway_1aonzik" /> + <bpmn:sequenceFlow id="SequenceFlow_1xh5ngw" name="Manual" sourceRef="ExclusiveGateway_1aonzik" targetRef="PauseForManualTaskRainyDay"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("handlingCode")=="Manual"}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:sequenceFlow id="SequenceFlow_0xyd2zl" name="Skip" sourceRef="ExclusiveGateway_1aonzik" targetRef="Task_setHandlingCodeSuccessOnSkip"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("handlingCode")=="Skip"}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> + <bpmn:serviceTask id="Task_setHandlingCodeSuccessOnSkip" name="Set Handling Code to Success" camunda:expression="${ExecuteBuildingBlockRainyDay.setHandlingStatusSuccess(execution)}"> + <bpmn:incoming>SequenceFlow_0xyd2zl</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1ynai9j</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:callActivity id="PauseForManualTaskRainyDay" name="Pause for Manual Task Rainy Day" calledElement="PauseForManualTaskRainyDay"> + <bpmn:extensionElements> + <camunda:out source="responseValueTask" target="handlingCode" /> + <camunda:in source="gBuildingBlockExecution" target="gBuildingBlockExecution" /> + <camunda:in source="rainyDayServiceType" target="rainyDayServiceType" /> + <camunda:in source="rainyDayVnfType" target="rainyDayVnfType" /> + <camunda:in source="WorkflowException" target="WorkflowException" /> + <camunda:in source="rainyDayVnfName" target="rainyDayVnfName" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1xh5ngw</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_05le7o3</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:endEvent id="EndEvent_1py1er4" name="end"> + <bpmn:incoming>SequenceFlow_1ynai9j</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1ynai9j" sourceRef="Task_setHandlingCodeSuccessOnSkip" targetRef="EndEvent_1py1er4" /> + <bpmn:sequenceFlow id="SequenceFlow_1g7oq3t" name="Timeout" sourceRef="ExclusiveGateway_1aonzik" targetRef="Task_QuerySecondaryPolicy"> + <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[${execution.getVariable("handlingCode")=="Timeout"}]]></bpmn:conditionExpression> + </bpmn:sequenceFlow> </bpmn:subProcess> <bpmn:sequenceFlow id="SequenceFlow_16lmcxp" sourceRef="Task_setHandlingCodeSuccess" targetRef="End_ExecuteBuildingBlock" /> <bpmn:sequenceFlow id="SequenceFlow_1j0vskt" name="Silent Success" sourceRef="CheckOrchestrationStatusValidationResults" targetRef="Task_setHandlingCodeSuccess"> @@ -169,63 +204,63 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ExclusiveGateway_0ey4zpt_di" bpmnElement="ExclusiveGateway_0ey4zpt" isMarkerVisible="true"> - <dc:Bounds x="692" y="389" width="50" height="50" /> + <dc:Bounds x="695" y="478" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="686" y="364" width="65" height="12" /> + <dc:Bounds x="691" y="453" width="62" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="IntermediateCatchEvent_0qjyidb_di" bpmnElement="IntermediateCatchEvent_RetryTimer"> - <dc:Bounds x="936" y="396" width="36" height="36" /> + <dc:Bounds x="939" y="485" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="927" y="371" width="56" height="12" /> + <dc:Bounds x="930" y="460" width="55" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ExclusiveGateway_1aonzik_di" bpmnElement="ExclusiveGateway_1aonzik" isMarkerVisible="true"> - <dc:Bounds x="539" y="389" width="50" height="50" /> + <dc:Bounds x="542" y="478" width="50" height="50" /> <bpmndi:BPMNLabel> - <dc:Bounds x="528" y="351" width="72" height="24" /> + <dc:Bounds x="533" y="440" width="68" height="24" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_1wbevp0_di" bpmnElement="SequenceFlow_1wbevp0"> - <di:waypoint xsi:type="dc:Point" x="742" y="414" /> - <di:waypoint xsi:type="dc:Point" x="807" y="414" /> + <di:waypoint xsi:type="dc:Point" x="745" y="503" /> + <di:waypoint xsi:type="dc:Point" x="810" y="503" /> <bpmndi:BPMNLabel> - <dc:Bounds x="759" y="389" width="19" height="12" /> + <dc:Bounds x="763" y="478" width="18" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0fwsjva_di" bpmnElement="SequenceFlow_0fwsjva"> - <di:waypoint xsi:type="dc:Point" x="589" y="414" /> - <di:waypoint xsi:type="dc:Point" x="692" y="414" /> + <di:waypoint xsi:type="dc:Point" x="592" y="503" /> + <di:waypoint xsi:type="dc:Point" x="695" y="503" /> <bpmndi:BPMNLabel> - <dc:Bounds x="627" y="422" width="28" height="12" /> + <dc:Bounds x="630" y="511" width="27" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0h8v45y_di" bpmnElement="SequenceFlow_0h8v45y"> - <di:waypoint xsi:type="dc:Point" x="564" y="439" /> - <di:waypoint xsi:type="dc:Point" x="564" y="495" /> + <di:waypoint xsi:type="dc:Point" x="567" y="528" /> + <di:waypoint xsi:type="dc:Point" x="567" y="584" /> <bpmndi:BPMNLabel> - <dc:Bounds x="570" y="460" width="88" height="12" /> + <dc:Bounds x="575" y="549" width="84" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1tifgqh_di" bpmnElement="Task_QueryRainyDayTable"> - <dc:Bounds x="396" y="374" width="100" height="80" /> + <dc:Bounds x="399" y="463" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0ndt8ft_di" bpmnElement="SequenceFlow_0ndt8ft"> - <di:waypoint xsi:type="dc:Point" x="907" y="414" /> - <di:waypoint xsi:type="dc:Point" x="936" y="414" /> + <di:waypoint xsi:type="dc:Point" x="910" y="503" /> + <di:waypoint xsi:type="dc:Point" x="939" y="503" /> <bpmndi:BPMNLabel> - <dc:Bounds x="877" y="393" width="90" height="12" /> + <dc:Bounds x="925" y="482" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_07a1ytc_di" bpmnElement="SequenceFlow_07a1ytc"> - <di:waypoint xsi:type="dc:Point" x="972" y="414" /> - <di:waypoint xsi:type="dc:Point" x="1010" y="414" /> + <di:waypoint xsi:type="dc:Point" x="975" y="503" /> + <di:waypoint xsi:type="dc:Point" x="1013" y="503" /> <bpmndi:BPMNLabel> - <dc:Bounds x="946" y="393" width="90" height="12" /> + <dc:Bounds x="994" y="482" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_1obvxht_di" bpmnElement="Task_SetRetryTimer"> - <dc:Bounds x="807" y="374" width="100" height="80" /> + <dc:Bounds x="810" y="463" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0kdjsnx_di" bpmnElement="Continue"> <di:waypoint xsi:type="dc:Point" x="508" y="180" /> @@ -251,25 +286,25 @@ </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_0a62t4c_di" bpmnElement="SequenceFlow_0a62t4c"> - <di:waypoint xsi:type="dc:Point" x="496" y="414" /> - <di:waypoint xsi:type="dc:Point" x="539" y="414" /> + <di:waypoint xsi:type="dc:Point" x="499" y="503" /> + <di:waypoint xsi:type="dc:Point" x="542" y="503" /> <bpmndi:BPMNLabel> - <dc:Bounds x="473" y="393" width="90" height="13" /> + <dc:Bounds x="521" y="482" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="SubProcess_0tv8zda_di" bpmnElement="SubProcess_0tv8zda" isExpanded="true"> - <dc:Bounds x="171" y="298" width="922" height="295" /> + <dc:Bounds x="171" y="299" width="1020" height="432" /> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_0mvmk3i_di" bpmnElement="EndEvent_0mvmk3i"> - <dc:Bounds x="546" y="495" width="36" height="36" /> + <dc:Bounds x="549" y="584" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="519" y="535" width="90" height="12" /> + <dc:Bounds x="567" y="624" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="EndEvent_1aww7yx_di" bpmnElement="EndEvent_1sez2lh"> - <dc:Bounds x="1010" y="396" width="36" height="36" /> + <dc:Bounds x="1013" y="485" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="1020" y="436" width="20" height="12" /> + <dc:Bounds x="1024" y="525" width="18" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_16lmcxp_di" bpmnElement="SequenceFlow_16lmcxp"> @@ -312,51 +347,102 @@ <dc:Bounds x="906" y="140" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0541bid_di" bpmnElement="SequenceFlow_0541bid"> - <di:waypoint xsi:type="dc:Point" x="717" y="439" /> - <di:waypoint xsi:type="dc:Point" x="717" y="463" /> + <di:waypoint xsi:type="dc:Point" x="720" y="528" /> + <di:waypoint xsi:type="dc:Point" x="720" y="552" /> <bpmndi:BPMNLabel> - <dc:Bounds x="728" y="440" width="13" height="12" /> + <dc:Bounds x="732" y="529" width="12" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="SequenceFlow_12ps9at_di" bpmnElement="SequenceFlow_12ps9at"> - <di:waypoint xsi:type="dc:Point" x="767" y="503" /> - <di:waypoint xsi:type="dc:Point" x="839" y="503" /> + <di:waypoint xsi:type="dc:Point" x="770" y="592" /> + <di:waypoint xsi:type="dc:Point" x="842" y="592" /> <bpmndi:BPMNLabel> - <dc:Bounds x="758" y="482" width="90" height="12" /> + <dc:Bounds x="806" y="571" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="EndEvent_05vw85n_di" bpmnElement="EndEvent_0ex9298"> - <dc:Bounds x="839" y="485" width="36" height="36" /> + <dc:Bounds x="842" y="574" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="848" y="525" width="20" height="12" /> + <dc:Bounds x="852" y="614" width="18" height="12" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="ServiceTask_11f2c91_di" bpmnElement="Task_QuerySecondaryPolicy"> - <dc:Bounds x="667" y="463" width="100" height="80" /> + <dc:Bounds x="670" y="552" width="100" height="80" /> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_0vdeqxv_di" bpmnElement="SequenceFlow_0vdeqxv"> - <di:waypoint xsi:type="dc:Point" x="361" y="414" /> - <di:waypoint xsi:type="dc:Point" x="396" y="414" /> + <di:waypoint xsi:type="dc:Point" x="364" y="503" /> + <di:waypoint xsi:type="dc:Point" x="399" y="503" /> <bpmndi:BPMNLabel> - <dc:Bounds x="378.5" y="393" width="0" height="12" /> + <dc:Bounds x="382" y="482" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="StartEvent_0tmcs9g_di" bpmnElement="StartEvent_0tmcs9g"> - <dc:Bounds x="196" y="396" width="36" height="36" /> + <dc:Bounds x="199" y="485" width="36" height="36" /> <bpmndi:BPMNLabel> - <dc:Bounds x="79" y="432" width="90" height="12" /> + <dc:Bounds x="127" y="521" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="SequenceFlow_09synl9_di" bpmnElement="SequenceFlow_09synl9"> - <di:waypoint xsi:type="dc:Point" x="232" y="414" /> - <di:waypoint xsi:type="dc:Point" x="261" y="414" /> + <di:waypoint xsi:type="dc:Point" x="235" y="503" /> + <di:waypoint xsi:type="dc:Point" x="264" y="503" /> <bpmndi:BPMNLabel> - <dc:Bounds x="201.5" y="393" width="90" height="12" /> + <dc:Bounds x="250" y="482" width="0" height="0" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNShape id="ServiceTask_10v49qn_di" bpmnElement="Task_UpdateExtErrorSource"> - <dc:Bounds x="261" y="374" width="100" height="80" /> + <dc:Bounds x="264" y="463" width="100" height="80" /> </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_05le7o3_di" bpmnElement="SequenceFlow_05le7o3"> + <di:waypoint xsi:type="dc:Point" x="617" y="377" /> + <di:waypoint xsi:type="dc:Point" x="659" y="377" /> + <di:waypoint xsi:type="dc:Point" x="659" y="421" /> + <di:waypoint xsi:type="dc:Point" x="580" y="491" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="674" y="399" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1xh5ngw_di" bpmnElement="SequenceFlow_1xh5ngw"> + <di:waypoint xsi:type="dc:Point" x="553" y="492" /> + <di:waypoint xsi:type="dc:Point" x="462" y="423" /> + <di:waypoint xsi:type="dc:Point" x="462" y="377" /> + <di:waypoint xsi:type="dc:Point" x="517" y="377" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="468" y="400" width="35" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0xyd2zl_di" bpmnElement="SequenceFlow_0xyd2zl"> + <di:waypoint xsi:type="dc:Point" x="553" y="514" /> + <di:waypoint xsi:type="dc:Point" x="449" y="589" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="506" y="549.4997153461163" width="21" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0ohzi8e_di" bpmnElement="Task_setHandlingCodeSuccessOnSkip"> + <dc:Bounds x="399" y="589" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="CallActivity_0szwp51_di" bpmnElement="PauseForManualTaskRainyDay"> + <dc:Bounds x="517" y="337" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="EndEvent_1py1er4_di" bpmnElement="EndEvent_1py1er4"> + <dc:Bounds x="304" y="611" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="313" y="647" width="18" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1ynai9j_di" bpmnElement="SequenceFlow_1ynai9j"> + <di:waypoint xsi:type="dc:Point" x="399" y="629" /> + <di:waypoint xsi:type="dc:Point" x="340" y="629" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="370" y="604" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1g7oq3t_di" bpmnElement="SequenceFlow_1g7oq3t"> + <di:waypoint xsi:type="dc:Point" x="583" y="512" /> + <di:waypoint xsi:type="dc:Point" x="670" y="562" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="649" y="533" width="39" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/PauseForManualTaskRainyDay.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/PauseForManualTaskRainyDay.bpmn new file mode 100644 index 0000000000..29657e17af --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/PauseForManualTaskRainyDay.bpmn @@ -0,0 +1,164 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="_MagIIMOUEeW8asg-vCEgWQ" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="1.4.0" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"> + <bpmn2:process id="PauseForManualTaskRainyDay" name="PauseForManualTaskRainyDay" isExecutable="true"> + <bpmn2:startEvent id="PauseForManualTaskRainyDay_Start"> + <bpmn2:outgoing>SequenceFlow_0jav6cu</bpmn2:outgoing> + </bpmn2:startEvent> + <bpmn2:endEvent id="PauseForManualTaskRainyDay_End"> + <bpmn2:incoming>SequenceFlow_14cyk9v</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_0jav6cu" sourceRef="PauseForManualTaskRainyDay_Start" targetRef="InitRainyDayManualHandling" /> + <bpmn2:sequenceFlow id="SequenceFlow_192yimz" sourceRef="ManualUserTask" targetRef="UpdateDbStatusToInProgress" /> + <bpmn2:userTask id="ManualUserTask" name="Manual User Task"> + <bpmn2:extensionElements> + <camunda:taskListener expression="${ManualHandlingTasks.completeTask(task)}" event="complete" /> + <camunda:properties> + <camunda:property /> + </camunda:properties> + <camunda:taskListener expression="${ManualHandlingTasks.setFalloutTaskVariables(task)}" event="create" /> + </bpmn2:extensionElements> + <bpmn2:incoming>SequenceFlow_0igra4l</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_192yimz</bpmn2:outgoing> + </bpmn2:userTask> + <bpmn2:sequenceFlow id="SequenceFlow_0b84ki5" sourceRef="UpdateDbStatusToPendingManualTask" targetRef="CreateExternalTicket" /> + <bpmn2:sequenceFlow id="SequenceFlow_14cyk9v" sourceRef="UpdateDbStatusToInProgress" targetRef="PauseForManualTaskRainyDay_End" /> + <bpmn2:serviceTask id="UpdateDbStatusToPendingManualTask" name="Update Infra DB Status to PENDING_MANUAL_TASK" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")),"PENDING_MANUAL_TASK")}"> + <bpmn2:incoming>SequenceFlow_1idwudp</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0b84ki5</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:serviceTask id="UpdateDbStatusToInProgress" name="Update Infra DB Status to IN_PROGRESS" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")), "IN_PROGRESS")}"> + <bpmn2:incoming>SequenceFlow_192yimz</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_14cyk9v</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:sequenceFlow id="SequenceFlow_0igra4l" sourceRef="CreateExternalTicket" targetRef="ManualUserTask" /> + <bpmn2:boundaryEvent id="ManualTaskTimer" name="Timer" attachedToRef="ManualUserTask"> + <bpmn2:outgoing>SequenceFlow_01k6zgt</bpmn2:outgoing> + <bpmn2:timerEventDefinition> + <bpmn2:timeDuration xsi:type="bpmn2:tFormalExpression"><![CDATA[${execution.getVariable("taskTimeout")}]]></bpmn2:timeDuration> + </bpmn2:timerEventDefinition> + </bpmn2:boundaryEvent> + <bpmn2:serviceTask id="CreateExternalTicket" name="Create ExternalTicket" camunda:expression="${ManualHandlingTasks.createExternalTicket(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn2:incoming>SequenceFlow_0b84ki5</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_0igra4l</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:sequenceFlow id="SequenceFlow_01k6zgt" sourceRef="ManualTaskTimer" targetRef="UpdateDBStatusToTimeout" /> + <bpmn2:serviceTask id="UpdateDBStatusToTimeout" name="Update Infra DB Status To TIMEOUT" camunda:expression="${ManualHandlingTasks.updateRequestDbStatus(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")), "TIMEOUT")}"> + <bpmn2:incoming>SequenceFlow_01k6zgt</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_16bjdgj</bpmn2:outgoing> + </bpmn2:serviceTask> + <bpmn2:sequenceFlow id="SequenceFlow_16bjdgj" sourceRef="UpdateDBStatusToTimeout" targetRef="PauseForManualTaskRainyDay_Timeout" /> + <bpmn2:endEvent id="PauseForManualTaskRainyDay_Timeout"> + <bpmn2:incoming>SequenceFlow_16bjdgj</bpmn2:incoming> + </bpmn2:endEvent> + <bpmn2:sequenceFlow id="SequenceFlow_1idwudp" sourceRef="InitRainyDayManualHandling" targetRef="UpdateDbStatusToPendingManualTask" /> + <bpmn2:serviceTask id="InitRainyDayManualHandling" name="Init Rainy Day Manual Handling" camunda:expression="${ManualHandlingTasks.initRainyDayManualHandling(InjectExecution.execute(execution, execution.getVariable("gBuildingBlockExecution")))}"> + <bpmn2:incoming>SequenceFlow_0jav6cu</bpmn2:incoming> + <bpmn2:outgoing>SequenceFlow_1idwudp</bpmn2:outgoing> + </bpmn2:serviceTask> + </bpmn2:process> + <bpmn2:error id="Error_2" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> + <bpmn2:error id="Error_1" name="java.lang.Exception" errorCode="java.lang.Exception" /> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="PauseForManualTaskRainyDay"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_47" bpmnElement="PauseForManualTaskRainyDay_Start"> + <dc:Bounds x="46" y="79" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="65" y="120" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="_BPMNShape_EndEvent_177" bpmnElement="PauseForManualTaskRainyDay_End"> + <dc:Bounds x="919" y="79" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="937" y="120" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0jav6cu_di" bpmnElement="SequenceFlow_0jav6cu"> + <di:waypoint xsi:type="dc:Point" x="82" y="97" /> + <di:waypoint xsi:type="dc:Point" x="129" y="97" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="106" y="82" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_192yimz_di" bpmnElement="SequenceFlow_192yimz"> + <di:waypoint xsi:type="dc:Point" x="688" y="97" /> + <di:waypoint xsi:type="dc:Point" x="740" y="98" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="714" y="82.5" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="UserTask_1krqrz1_di" bpmnElement="ManualUserTask"> + <dc:Bounds x="588" y="57" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0b84ki5_di" bpmnElement="SequenceFlow_0b84ki5"> + <di:waypoint xsi:type="dc:Point" x="370" y="97" /> + <di:waypoint xsi:type="dc:Point" x="432" y="97" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="401" y="82" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_14cyk9v_di" bpmnElement="SequenceFlow_14cyk9v"> + <di:waypoint xsi:type="dc:Point" x="840" y="98" /> + <di:waypoint xsi:type="dc:Point" x="919" y="97" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="880" y="82.5" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_0c0yopb_di" bpmnElement="UpdateDbStatusToPendingManualTask"> + <dc:Bounds x="270" y="57" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_1hc2ewj_di" bpmnElement="UpdateDbStatusToInProgress"> + <dc:Bounds x="740" y="58" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_0igra4l_di" bpmnElement="SequenceFlow_0igra4l"> + <di:waypoint xsi:type="dc:Point" x="532" y="97" /> + <di:waypoint xsi:type="dc:Point" x="588" y="97" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="560" y="82" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="BoundaryEvent_1g8ju6a_di" bpmnElement="ManualTaskTimer"> + <dc:Bounds x="652" y="119" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="692" y="144" width="28" height="12" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ServiceTask_04rimht_di" bpmnElement="CreateExternalTicket"> + <dc:Bounds x="432" y="57" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_01k6zgt_di" bpmnElement="SequenceFlow_01k6zgt"> + <di:waypoint xsi:type="dc:Point" x="670" y="137" /> + <di:waypoint xsi:type="dc:Point" x="670" y="265" /> + <di:waypoint xsi:type="dc:Point" x="744" y="265" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="685" y="201" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_18sdiiw_di" bpmnElement="UpdateDBStatusToTimeout"> + <dc:Bounds x="744" y="225" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_16bjdgj_di" bpmnElement="SequenceFlow_16bjdgj"> + <di:waypoint xsi:type="dc:Point" x="844" y="265" /> + <di:waypoint xsi:type="dc:Point" x="919" y="265" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="882" y="250" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_172wy7j_di" bpmnElement="PauseForManualTaskRainyDay_Timeout"> + <dc:Bounds x="919" y="247" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="937" y="283" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1idwudp_di" bpmnElement="SequenceFlow_1idwudp"> + <di:waypoint xsi:type="dc:Point" x="229" y="97" /> + <di:waypoint xsi:type="dc:Point" x="270" y="97" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="250" y="82" width="0" height="0" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_06ztv9g_di" bpmnElement="InitRainyDayManualHandling"> + <dc:Bounds x="129" y="57" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn2:definitions> diff --git a/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskRainyDayTest.java b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskRainyDayTest.java new file mode 100644 index 0000000000..576f9c4f01 --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/subprocess/PauseForManualTaskRainyDayTest.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 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.bpmn.infrastructure.bpmn.subprocess; + +import static org.camunda.bpm.engine.test.assertions.ProcessEngineTests.assertThat; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doThrow; +import org.camunda.bpm.engine.ManagementService; +import org.camunda.bpm.engine.TaskService; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.runtime.Job; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.task.Task; +import org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.onap.so.bpmn.BaseBPMNTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; + + +public class PauseForManualTaskRainyDayTest extends BaseBPMNTest { + private static final String TIMEOUT_10_S = "PT10S"; + + @Autowired + protected ManagementService managementService; + + @Autowired + protected TaskService taskService; + + @Test + public void sunnyDayPauseForManualTaskRainyDayTimeout_Test() throws InterruptedException { + variables.put("taskTimeout", TIMEOUT_10_S); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("PauseForManualTaskRainyDay", variables); + assertThat(pi).isNotNull(); + BpmnAwareAssertions.assertThat(pi).isWaitingAt("ManualUserTask"); + Task task = taskService.createTaskQuery().active().list().get(0); + assertThat(pi).task().isNotNull(); + assertNotNull(task); + + Job job = managementService.createJobQuery().activityId("ManualTaskTimer").singleResult(); + assertNotNull(job); + managementService.executeJob(job.getId()); + + assertThat(pi).isStarted().hasPassedInOrder("PauseForManualTaskRainyDay_Start", "InitRainyDayManualHandling", + "UpdateDbStatusToPendingManualTask", "CreateExternalTicket", "ManualTaskTimer", + "UpdateDBStatusToTimeout", "PauseForManualTaskRainyDay_Timeout"); + } + + @Test + public void sunnyDayPauseForManualTaskCompleted_Test() throws InterruptedException { + variables.put("taskTimeout", TIMEOUT_10_S); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("PauseForManualTaskRainyDay", variables); + assertThat(pi).isNotNull(); + BpmnAwareAssertions.assertThat(pi).isWaitingAt("ManualUserTask"); + assertThat(pi).task().isNotNull(); + Task task = taskService.createTaskQuery().active().list().get(0); + assertNotNull(task); + taskService.complete(task.getId()); + + assertThat(pi).isStarted().hasPassedInOrder("PauseForManualTaskRainyDay_Start", "InitRainyDayManualHandling", + "UpdateDbStatusToPendingManualTask", "CreateExternalTicket", "ManualUserTask", + "UpdateDbStatusToInProgress", "PauseForManualTaskRainyDay_End"); + assertThat(pi).isEnded(); + } + + @Test + public void rainyDayPauseForManualTask_Test() throws Exception { + doThrow(new BpmnError("7000", "TESTING ERRORS")).when(manualHandlingTasks) + .createExternalTicket((any(BuildingBlockExecution.class))); + ProcessInstance pi = runtimeService.startProcessInstanceByKey("PauseForManualTaskRainyDay", variables); + assertThat(pi).isNotNull().isStarted() + .hasPassedInOrder("PauseForManualTaskRainyDay_Start", "InitRainyDayManualHandling", + "UpdateDbStatusToPendingManualTask", "CreateExternalTicket") + .hasNotPassed("ManualUserTask", "UpdateDbStatusToInProgress", "PauseForManualTaskRainyDay_End"); + } + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/VnfInPlaceUpdate_VID_request.json b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/VnfInPlaceUpdate_VID_request.json index eb2d9faa2a..0a211e6b08 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/VnfInPlaceUpdate_VID_request.json +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/resources/__files/InfrastructureFlows/VnfInPlaceUpdate_VID_request.json @@ -10,7 +10,7 @@ }, "requestParameters": { "payload": -"{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}" +"{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}" } } }
\ No newline at end of file diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index 86645391b4..f1fbe545ce 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -32,6 +32,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; @@ -44,6 +45,7 @@ import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAICollectionResources; import org.onap.so.client.orchestration.AAIConfigurationResources; import org.onap.so.client.orchestration.AAINetworkResources; +import org.onap.so.client.orchestration.AAIPnfResources; import org.onap.so.client.orchestration.AAIServiceInstanceResources; import org.onap.so.client.orchestration.AAIVfModuleResources; import org.onap.so.client.orchestration.AAIVnfResources; @@ -78,6 +80,8 @@ public class AAIUpdateTasks { private AAICollectionResources aaiCollectionResources; @Autowired private AAIConfigurationResources aaiConfigurationResources; + @Autowired + private AAIPnfResources aaiPnfResources; /** * BPMN access method to update the status of Service to Assigned in AAI @@ -114,6 +118,22 @@ public class AAIUpdateTasks { } } + + /** + * BPMN access method to update status of Pnf to Active in AAI + * + * @param execution + */ + public void updateOrchestrationStatusActivePnf(BuildingBlockExecution execution) { + try { + Pnf pnf = extractPojosForBB.extractByKey(execution, ResourceKey.PNF); + aaiPnfResources.updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ACTIVE); + } catch (Exception ex) { + logger.error("Exception occurred in AAIUpdateTasks updateOrchestrationStatusActivePnf", ex); + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex); + } + } + /** * BPMN access method to update status of Vnf to Assigned in AAI * diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java index 4b967c7bc4..9697246b03 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java @@ -24,6 +24,7 @@ import org.onap.so.client.exception.ExceptionBuilder; import org.onap.so.client.orchestration.AAIVnfResources; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.exceptions.ValidationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -77,11 +78,11 @@ public class AppcOrchestratorPreProcessor { if (payload == null) { payload = ""; } - String existingSoftwareVersion = JsonUtils.getJsonValue(payload, "existing-software-version"); + String existingSoftwareVersion = JsonUtils.getJsonValue(payload, "existing_software_version"); appcTaskRequest.setExistingSoftwareVersion(existingSoftwareVersion); - String newSoftwareVersion = JsonUtils.getJsonValue(payload, "new-software-version"); + String newSoftwareVersion = JsonUtils.getJsonValue(payload, "new_software_version"); appcTaskRequest.setNewSoftwareVersion(newSoftwareVersion); - String operationsTimeout = JsonUtils.getJsonValue(payload, "operations-timeout"); + String operationsTimeout = JsonUtils.getJsonValue(payload, "operations_timeout"); appcTaskRequest.setOperationsTimeout(operationsTimeout); } @@ -123,9 +124,12 @@ public class AppcOrchestratorPreProcessor { applicationControllerVnf.setVnfName(vnfName); appcTaskRequest.setApplicationControllerVnf(applicationControllerVnf); + verifyApplicationControllerTaskRequest(execution, appcTaskRequest); + execution.setVariable("appcOrchestratorRequest", appcTaskRequest); + logger.debug("SET APPC ORCHESTRATOR REQUEST"); } catch (Exception e) { - logger.error("Error building ApplicationControllerTaskRequest Object", e); + logger.error("Error building ApplicationControllerTaskRequest Object", e.getMessage()); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, e); } } @@ -186,4 +190,54 @@ public class AppcOrchestratorPreProcessor { } } } + + protected void verifyApplicationControllerTaskRequest(BuildingBlockExecution execution, + ApplicationControllerTaskRequest appcTaskRequest) throws ValidationException { + String errorMessage = null; + switch (appcTaskRequest.getAction()) { + case QuiesceTraffic: + if (appcTaskRequest.getOperationsTimeout() == null + || appcTaskRequest.getOperationsTimeout().isEmpty()) { + errorMessage = "APPC action QuiesceTraffic is missing operations_timeout parameter. "; + } + break; + case UpgradePreCheck: + case UpgradePostCheck: + case UpgradeBackup: + case UpgradeSoftware: + if (appcTaskRequest.getExistingSoftwareVersion() == null + || appcTaskRequest.getExistingSoftwareVersion().isEmpty()) { + errorMessage = + "APPC action " + appcTaskRequest.getAction() + " is missing existing_software parameter. "; + } + if (appcTaskRequest.getNewSoftwareVersion() == null + || appcTaskRequest.getNewSoftwareVersion().isEmpty()) { + errorMessage = + "APPC action " + appcTaskRequest.getAction() + " is missing new_software parameter. "; + } + break; + case Snapshot: + if (appcTaskRequest.getApplicationControllerVnf().getApplicationControllerVm() != null) { + if (appcTaskRequest.getApplicationControllerVnf().getApplicationControllerVm().getVmId() == null + || appcTaskRequest.getApplicationControllerVnf().getApplicationControllerVm().getVmId() + .isEmpty()) { + errorMessage = "APPC action Snapshot is missing vmId parameter. "; + } + if (appcTaskRequest.getApplicationControllerVnf().getApplicationControllerVm() + .getVserverId() == null + || appcTaskRequest.getApplicationControllerVnf().getApplicationControllerVm().getVserverId() + .isEmpty()) { + errorMessage = "APPC action Snapshot is missing vserverId parameter. "; + } + break; + } + default: + break; + } + if (errorMessage != null) { + logger.debug("verifyApplicationControllerTaskRequest() failed with " + errorMessage); + throw new ValidationException(errorMessage, false); + } + return; + } } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketCreation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketCreation.java new file mode 100644 index 0000000000..70d56db26b --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketCreation.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 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.bpmn.infrastructure.manualhandling.tasks; + +import org.onap.so.bpmn.common.BuildingBlockExecution; + +public interface ExternalTicketCreation { + public void createExternalTicket(BuildingBlockExecution execution); +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java new file mode 100644 index 0000000000..6bfe618460 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasks.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 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.bpmn.infrastructure.manualhandling.tasks; + +import org.onap.so.logger.LoggingAnchor; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.client.ticket.ExternalTicket; +import org.onap.so.logger.ErrorCode; +import org.onap.so.logger.MessageEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +@Component +public class ExternalTicketTasks implements ExternalTicketCreation { + private static final Logger logger = LoggerFactory.getLogger(ExternalTicketTasks.class); + + protected static final String VNF_TYPE = "vnfType"; + protected static final String DESCRIPTION = "description"; + protected static final String SERVICE_TYPE = "serviceType"; + protected static final String MSO_REQUEST_ID = "mso-request-id"; + protected static final String REQUESTOR_ID = "requestorId"; + protected static final String ERROR_CODE = "errorCode"; + protected static final String VALID_RESPONSES = "validResponses"; + protected static final String TASK_TIMEOUT = "taskTimeout"; + protected static final String RESPONSE_VALUE_TASK = "responseValueTask"; + protected static final String RESPONSE_VALUE = "responseValue"; + protected static final String WORKSTEP = "workStep"; + + protected static final String TASK_VARIABLE_TYPE = "type"; + protected static final String TASK_VARIABLE_NFROLE = "nfRole"; + protected static final String TASK_VARIABLE_SUBSCRIPTION_SERVICE_TYPE = "subscriptionServiceType"; + protected static final String TASK_VARIABLE_ORIGINAL_REQUEST_ID = "originalRequestId"; + protected static final String TASK_VARIABLE_ORIGINAL_REQUESTOR_ID = "originalRequestorId"; + protected static final String TASK_VARIABLE_ERROR_SOURCE = "errorSource"; + protected static final String TASK_VARIABLE_ERROR_CODE = "errorCode"; + protected static final String TASK_VARIABLE_ERROR_MESSAGE = "errorMessage"; + protected static final String TASK_VARIABLE_BUILDING_BLOCK_NAME = "buildingBlockName"; + protected static final String TASK_VARIABLE_BUILDING_BLOCK_STEP = "buildingBlockStep"; + protected static final String TASK_VARIABLE_DESCRIPTION = "description"; + protected static final String TASK_VARIABLE_TIMEOUT = "timeout"; + protected static final String TASK_VARIABLE_VALID_RESPONSES = "validResponses"; + + protected static final String BPMN_EXCEPTION = "BPMN exception: "; + protected static final String RAINY_DAY_SERVICE_TYPE = "rainyDayServiceType"; + protected static final String RAINY_DAY_VNF_TYPE = "rainyDayVnfType"; + protected static final String RAINY_DAY_VNF_NAME = "rainyDayVnfName"; + protected static final String G_BUILDING_BLOCK_EXECUTION = "gBuildingBlockExecution"; + protected static final String WORKFLOW_EXCEPTION = "WorkflowException"; + + public void createExternalTicket(BuildingBlockExecution execution) { + + logger.debug("Creating ExternalTicket()"); + try { + ExternalTicket ticket = getExternalTicket(); + + ticket.setRequestId((String) execution.getVariable(MSO_REQUEST_ID)); + ticket.setCurrentActivity((String) execution.getVariable("currentActivity")); + ticket.setNfRole((String) execution.getVariable(VNF_TYPE)); + ticket.setDescription((String) execution.getVariable(DESCRIPTION)); + ticket.setSubscriptionServiceType((String) execution.getVariable(SERVICE_TYPE)); + ticket.setRequestorId((String) execution.getVariable(REQUESTOR_ID)); + ticket.setTimeout((String) execution.getVariable(TASK_TIMEOUT)); + ticket.setErrorSource((String) execution.getVariable("failedActivity")); + ticket.setErrorCode((String) execution.getVariable(ERROR_CODE)); + ticket.setErrorMessage((String) execution.getVariable("errorText")); + ticket.setWorkStep((String) execution.getVariable(WORKSTEP)); + + ticket.createTicket(); + } catch (BpmnError e) { + String msg = "BPMN error in createExternalTicket " + e.getMessage(); + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", + ErrorCode.UnknownError.getValue()); + } catch (Exception ex) { + String msg = "Exception in createExternalTicket " + ex.getMessage(); + logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", + ErrorCode.UnknownError.getValue()); + } + + } + + protected ExternalTicket getExternalTicket() { + return new ExternalTicket(); + } + + +} 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 7e45c3b640..d9f5e65ba3 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 @@ -21,22 +21,23 @@ package org.onap.so.bpmn.infrastructure.manualhandling.tasks; import java.util.Map; +import java.time.Duration; +import java.util.Date; import java.util.HashMap; -import org.onap.so.logger.LoggingAnchor; import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.engine.delegate.DelegateTask; import org.camunda.bpm.engine.delegate.DelegateExecution; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.client.exception.ExceptionBuilder; -import org.onap.so.client.ticket.ExternalTicket; +import org.onap.so.constants.Status; 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.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component @@ -46,13 +47,38 @@ public class ManualHandlingTasks { private static final String TASK_TYPE_PAUSE = "pause"; private static final String TASK_TYPE_FALLOUT = "fallout"; public static final String VNF_TYPE = "vnfType"; + public static final String DESCRIPTION = "description"; public static final String SERVICE_TYPE = "serviceType"; public static final String MSO_REQUEST_ID = "mso-request-id"; public static final String REQUESTOR_ID = "requestorId"; public static final String ERROR_CODE = "errorCode"; public static final String VALID_RESPONSES = "validResponses"; - public static final String DESCRIPTION = "description"; + public static final String TASK_TIMEOUT = "taskTimeout"; + public static final String RESPONSE_VALUE_TASK = "responseValueTask"; + public static final String RESPONSE_VALUE = "responseValue"; + private static final String ASTERISK = "*"; + private static final String WORKSTEP = "workStep"; + + public static final String TASK_VARIABLE_TYPE = "type"; + public static final String TASK_VARIABLE_NFROLE = "nfRole"; + public static final String TASK_VARIABLE_SUBSCRIPTION_SERVICE_TYPE = "subscriptionServiceType"; + public static final String TASK_VARIABLE_ORIGINAL_REQUEST_ID = "originalRequestId"; + public static final String TASK_VARIABLE_ORIGINAL_REQUESTOR_ID = "originalRequestorId"; + public static final String TASK_VARIABLE_ERROR_SOURCE = "errorSource"; + public static final String TASK_VARIABLE_ERROR_CODE = "errorCode"; + public static final String TASK_VARIABLE_ERROR_MESSAGE = "errorMessage"; + public static final String TASK_VARIABLE_BUILDING_BLOCK_NAME = "buildingBlockName"; + public static final String TASK_VARIABLE_BUILDING_BLOCK_STEP = "buildingBlockStep"; + public static final String TASK_VARIABLE_DESCRIPTION = "description"; + public static final String TASK_VARIABLE_TIMEOUT = "timeout"; + public static final String TASK_VARIABLE_VALID_RESPONSES = "validResponses"; + public static final String BPMN_EXCEPTION = "BPMN exception: "; + public static final String RAINY_DAY_SERVICE_TYPE = "rainyDayServiceType"; + public static final String RAINY_DAY_VNF_TYPE = "rainyDayVnfType"; + public static final String RAINY_DAY_VNF_NAME = "rainyDayVnfName"; + public static final String G_BUILDING_BLOCK_EXECUTION = "gBuildingBlockExecution"; + public static final String WORKFLOW_EXCEPTION = "WorkflowException"; @Autowired private ExceptionBuilder exceptionUtil; @@ -60,40 +86,91 @@ public class ManualHandlingTasks { @Autowired private RequestsDbClient requestDbclient; + @Autowired + private Environment environment; + + @Autowired + private ExternalTicketCreation externalTicketCreation; + + protected String manualTaskTimeoutPath = "mso.rainyDay.manualTask.taskTimeout"; + protected String validResponsesPath = "mso.rainyDay.manualTask.validResponses"; + + + public void initRainyDayManualHandling(BuildingBlockExecution execution) { + try { + String manualTaskTimeout = this.environment.getProperty(manualTaskTimeoutPath); + execution.setVariable(TASK_TIMEOUT, manualTaskTimeout); + } catch (Exception e) { + logger.error("Exception occurred", e); + throw new BpmnError("Unknown error reading configuration for manual task handling"); + } + } + public void setFalloutTaskVariables(DelegateTask task) { DelegateExecution execution = task.getExecution(); try { + logger.debug("Setting fallout task variables:"); String taskId = task.getId(); logger.debug("taskId is: " + taskId); String type = TASK_TYPE_FALLOUT; - String nfRole = (String) execution.getVariable(VNF_TYPE); - String subscriptionServiceType = (String) execution.getVariable(SERVICE_TYPE); + BuildingBlockExecution gBuildingBlockExecution = + (BuildingBlockExecution) execution.getVariable(G_BUILDING_BLOCK_EXECUTION); + WorkflowException workflowException = (WorkflowException) execution.getVariable(WORKFLOW_EXCEPTION); + String nfRole = (String) execution.getVariable(RAINY_DAY_VNF_TYPE); + logger.debug(TASK_VARIABLE_NFROLE + ": " + nfRole); + String subscriptionServiceType = (String) execution.getVariable(RAINY_DAY_SERVICE_TYPE); + logger.debug(TASK_VARIABLE_SUBSCRIPTION_SERVICE_TYPE + ": " + subscriptionServiceType); String originalRequestId = (String) execution.getVariable(MSO_REQUEST_ID); - String originalRequestorId = (String) execution.getVariable(REQUESTOR_ID); - String description = ""; - String timeout = ""; - String errorSource = (String) execution.getVariable("failedActivity"); - String errorCode = (String) execution.getVariable(ERROR_CODE); - String errorMessage = (String) execution.getVariable("errorText"); - String buildingBlockName = (String) execution.getVariable("currentActivity"); - String buildingBlockStep = (String) execution.getVariable("workStep"); - String validResponses = (String) execution.getVariable(VALID_RESPONSES); + logger.debug(TASK_VARIABLE_ORIGINAL_REQUEST_ID + ": " + originalRequestId); + String originalRequestorId = + gBuildingBlockExecution.getGeneralBuildingBlock().getRequestContext().getRequestorId(); + logger.debug(TASK_VARIABLE_ORIGINAL_REQUESTOR_ID + ": " + originalRequestorId); + String description = "Manual user task to handle a failure of a BB execution"; + logger.debug(TASK_VARIABLE_DESCRIPTION + ": " + description); + String taskTimeout = (String) gBuildingBlockExecution.getVariable(TASK_TIMEOUT); + String timeout = Date.from((new Date()).toInstant().plus(Duration.parse(taskTimeout))).toGMTString(); + logger.debug(TASK_VARIABLE_TIMEOUT + ": " + timeout); + String errorSource = ASTERISK; + if (workflowException != null && workflowException.getExtSystemErrorSource() != null) { + errorSource = workflowException.getExtSystemErrorSource().toString(); + } + logger.debug(TASK_VARIABLE_ERROR_SOURCE + ": " + errorSource); + String errorCode = ASTERISK; + if (workflowException != null) { + errorCode = workflowException.getErrorCode() + ""; + } + logger.debug(TASK_VARIABLE_ERROR_CODE + ": " + errorCode); + String errorMessage = ASTERISK; + if (workflowException != null) { + errorMessage = workflowException.getErrorMessage(); + } + logger.debug(TASK_VARIABLE_ERROR_MESSAGE + ": " + errorMessage); + String buildingBlockName = gBuildingBlockExecution.getFlowToBeCalled(); + logger.debug(TASK_VARIABLE_BUILDING_BLOCK_NAME + ": " + buildingBlockName); + String buildingBlockStep = ASTERISK; + if (workflowException != null) { + buildingBlockStep = workflowException.getWorkStep(); + } + execution.setVariable(WORKSTEP, buildingBlockStep); + logger.debug(TASK_VARIABLE_BUILDING_BLOCK_STEP + ": " + buildingBlockStep); + String validResponses = this.environment.getProperty(validResponsesPath); + logger.debug(TASK_VARIABLE_VALID_RESPONSES + ": " + validResponses); Map<String, String> taskVariables = new HashMap<>(); - taskVariables.put("type", type); - taskVariables.put("nfRole", nfRole); - taskVariables.put("subscriptionServiceType", subscriptionServiceType); - taskVariables.put("originalRequestId", originalRequestId); - taskVariables.put("originalRequestorId", originalRequestorId); - taskVariables.put("errorSource", errorSource); - taskVariables.put(ERROR_CODE, errorCode); - taskVariables.put("errorMessage", errorMessage); - taskVariables.put("buildingBlockName", buildingBlockName); - taskVariables.put("buildingBlockStep", buildingBlockStep); - taskVariables.put(VALID_RESPONSES, validResponses); - taskVariables.put("tmeout", timeout); - taskVariables.put(DESCRIPTION, description); + taskVariables.put(TASK_VARIABLE_TYPE, type); + taskVariables.put(TASK_VARIABLE_NFROLE, nfRole); + taskVariables.put(TASK_VARIABLE_SUBSCRIPTION_SERVICE_TYPE, subscriptionServiceType); + taskVariables.put(TASK_VARIABLE_ORIGINAL_REQUEST_ID, originalRequestId); + taskVariables.put(TASK_VARIABLE_ORIGINAL_REQUESTOR_ID, originalRequestorId); + taskVariables.put(TASK_VARIABLE_ERROR_SOURCE, errorSource); + taskVariables.put(TASK_VARIABLE_ERROR_CODE, errorCode); + taskVariables.put(TASK_VARIABLE_ERROR_MESSAGE, errorMessage); + taskVariables.put(TASK_VARIABLE_BUILDING_BLOCK_NAME, buildingBlockName); + taskVariables.put(TASK_VARIABLE_BUILDING_BLOCK_STEP, buildingBlockStep); + taskVariables.put(TASK_VARIABLE_VALID_RESPONSES, validResponses); + taskVariables.put(TASK_VARIABLE_TIMEOUT, timeout); + taskVariables.put(TASK_VARIABLE_DESCRIPTION, description); TaskService taskService = execution.getProcessEngineServices().getTaskService(); taskService.setVariables(taskId, taskVariables); @@ -116,33 +193,34 @@ public class ManualHandlingTasks { String taskId = task.getId(); logger.debug("taskId is: " + taskId); String type = TASK_TYPE_PAUSE; + String nfRole = (String) execution.getVariable(VNF_TYPE); String subscriptionServiceType = (String) execution.getVariable(SERVICE_TYPE); String originalRequestId = (String) execution.getVariable(MSO_REQUEST_ID); String originalRequestorId = (String) execution.getVariable(REQUESTOR_ID); String description = (String) execution.getVariable(DESCRIPTION); String timeout = ""; - String errorSource = ""; - String errorCode = ""; - String errorMessage = ""; - String buildingBlockName = ""; - String buildingBlockStep = ""; + String errorSource = ASTERISK; + String errorCode = ASTERISK; + String errorMessage = ASTERISK; + String buildingBlockName = ASTERISK; + String buildingBlockStep = ASTERISK; String validResponses = (String) execution.getVariable(VALID_RESPONSES); Map<String, String> taskVariables = new HashMap<>(); - taskVariables.put("type", type); - taskVariables.put("nfRole", nfRole); - taskVariables.put(DESCRIPTION, description); - taskVariables.put("timeout", timeout); - taskVariables.put("subscriptionServiceType", subscriptionServiceType); - taskVariables.put("originalRequestId", originalRequestId); - taskVariables.put("originalRequestorId", originalRequestorId); - taskVariables.put("errorSource", errorSource); - taskVariables.put(ERROR_CODE, errorCode); - taskVariables.put("errorMessage", errorMessage); - taskVariables.put("buildingBlockName", buildingBlockName); - taskVariables.put("buildingBlockStep", buildingBlockStep); - taskVariables.put(VALID_RESPONSES, validResponses); + taskVariables.put(TASK_VARIABLE_TYPE, type); + taskVariables.put(TASK_VARIABLE_NFROLE, nfRole); + taskVariables.put(TASK_VARIABLE_DESCRIPTION, description); + taskVariables.put(TASK_VARIABLE_TIMEOUT, timeout); + taskVariables.put(TASK_VARIABLE_SUBSCRIPTION_SERVICE_TYPE, subscriptionServiceType); + taskVariables.put(TASK_VARIABLE_ORIGINAL_REQUEST_ID, originalRequestId); + taskVariables.put(TASK_VARIABLE_ORIGINAL_REQUESTOR_ID, originalRequestorId); + taskVariables.put(TASK_VARIABLE_ERROR_SOURCE, errorSource); + taskVariables.put(TASK_VARIABLE_ERROR_CODE, errorCode); + taskVariables.put(TASK_VARIABLE_ERROR_MESSAGE, errorMessage); + taskVariables.put(TASK_VARIABLE_BUILDING_BLOCK_NAME, buildingBlockName); + taskVariables.put(TASK_VARIABLE_BUILDING_BLOCK_STEP, buildingBlockStep); + taskVariables.put(TASK_VARIABLE_VALID_RESPONSES, validResponses); TaskService taskService = execution.getProcessEngineServices().getTaskService(); taskService.setVariables(taskId, taskVariables); @@ -169,14 +247,14 @@ public class ManualHandlingTasks { TaskService taskService = execution.getProcessEngineServices().getTaskService(); Map<String, Object> taskVariables = taskService.getVariables(taskId); - String responseValue = (String) taskVariables.get("responseValue"); + String responseValue = (String) taskVariables.get(RESPONSE_VALUE); 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); logger.debug("ResponseValue to taskListener: " + responseValueUppercaseStart); - execution.setVariable("responseValueTask", responseValueUppercaseStart); + execution.setVariable(RESPONSE_VALUE_TASK, responseValueUppercaseStart); } catch (BpmnError e) { logger.debug(BPMN_EXCEPTION + e.getMessage()); @@ -190,33 +268,7 @@ public class ManualHandlingTasks { } public void createExternalTicket(BuildingBlockExecution execution) { - - try { - ExternalTicket ticket = new ExternalTicket(); - - ticket.setRequestId((String) execution.getVariable(MSO_REQUEST_ID)); - ticket.setCurrentActivity((String) execution.getVariable("currentActivity")); - ticket.setNfRole((String) execution.getVariable(VNF_TYPE)); - ticket.setDescription((String) execution.getVariable(DESCRIPTION)); - ticket.setSubscriptionServiceType((String) execution.getVariable(SERVICE_TYPE)); - ticket.setRequestorId((String) execution.getVariable(REQUESTOR_ID)); - ticket.setTimeout((String) execution.getVariable("taskTimeout")); - ticket.setErrorSource((String) execution.getVariable("failedActivity")); - ticket.setErrorCode((String) execution.getVariable(ERROR_CODE)); - ticket.setErrorMessage((String) execution.getVariable("errorText")); - ticket.setWorkStep((String) execution.getVariable("workStep")); - - ticket.createTicket(); - } catch (BpmnError e) { - String msg = "BPMN error in createAOTSTicket " + e.getMessage(); - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", - ErrorCode.UnknownError.getValue()); - } catch (Exception ex) { - String msg = "Exception in createExternalTicket " + ex.getMessage(); - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", - ErrorCode.UnknownError.getValue()); - } - + externalTicketCreation.createExternalTicket(execution); } public void updateRequestDbStatus(BuildingBlockExecution execution, String status) { @@ -224,6 +276,9 @@ public class ManualHandlingTasks { String requestId = (String) execution.getVariable(MSO_REQUEST_ID); InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); + if (status.equalsIgnoreCase(Status.TIMEOUT.name())) { + execution.setVariable(RESPONSE_VALUE_TASK, "Timeout"); + } request.setRequestStatus(status); request.setLastModifiedBy("ManualHandling"); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 8911ebf15d..80c6f0b969 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -198,7 +198,7 @@ public class WorkflowAction { try { suppressRollback = requestDetails.getRequestInfo().getSuppressRollback(); } catch (Exception ex) { - logger.error("Exception in getSuppressRollback", ex); + logger.warn("Exception in getSuppressRollback", ex); suppressRollback = false; } execution.setVariable("suppressRollback", suppressRollback); @@ -431,7 +431,7 @@ public class WorkflowAction { execution.setVariable("isRollbackComplete", false); } catch (Exception ex) { - buildAndThrowException(execution, "Exception in execution list. ", ex); + buildAndThrowException(execution, "Exception while setting execution list. ", ex); } } @@ -1562,8 +1562,8 @@ public class WorkflowAction { protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) { logger.error(msg, ex); - execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg); - exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg); + execution.setVariable(WORKFLOW_ACTION_ERROR_MESSAGE, msg + ex.getMessage()); + exceptionBuilder.buildAndThrowWorkflowException(execution, 7000, msg + ex.getMessage()); } protected void buildAndThrowException(DelegateExecution execution, String msg) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java index 9dd44c43e9..1dde814584 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java @@ -49,4 +49,14 @@ public class AAIPnfResources { injectionHelper.getAaiClient().createIfNotExists(pnfURI, Optional.of(aaiObjectMapper.mapPnf(pnf))) .connect(pnfURI, serviceInstanceURI); } + + public void updateOrchestrationStatusPnf(Pnf pnf, OrchestrationStatus orchestrationStatus) { + AAIResourceUri pnfURI = AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnf.getPnfName()); + + Pnf pnfCopy = pnf.shallowCopyId(); + + pnf.setOrchestrationStatus(orchestrationStatus); + pnfCopy.setOrchestrationStatus(orchestrationStatus); + injectionHelper.getAaiClient().update(pnfURI, aaiObjectMapper.mapPnf(pnfCopy)); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index c337f7f1b5..ae6dde6521 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -20,21 +20,7 @@ package org.onap.so.bpmn.infrastructure.aai.tasks; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import java.util.HashMap; import org.camunda.bpm.engine.delegate.BpmnError; -import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentMatchers; @@ -48,6 +34,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; @@ -56,6 +43,18 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf; import org.onap.so.client.exception.BBObjectNotFoundException; import org.onap.so.db.catalog.beans.OrchestrationStatus; +import java.util.HashMap; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class AAIUpdateTasksTest extends BaseTaskTest { @@ -140,6 +139,27 @@ public class AAIUpdateTasksTest extends BaseTaskTest { aaiUpdateTasks.updateOrchestrationStatusActiveService(execution); } + + @Test + public void updateOrchestrationStatusActivePnfTest() throws Exception { + Pnf pnf = preparePnfAndExtractForPnf(); + doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ACTIVE); + + aaiUpdateTasks.updateOrchestrationStatusActivePnf(execution); + + verify(aaiPnfResources, times(1)).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ACTIVE); + } + + @Test + public void updateOrchestrationStatusActivePnfExceptionTest() throws Exception { + Pnf pnf = preparePnfAndExtractForPnf(); + doThrow(RuntimeException.class).when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, + OrchestrationStatus.ACTIVE); + + expectedException.expect(BpmnError.class); + aaiUpdateTasks.updateOrchestrationStatusActivePnf(execution); + } + @Test public void updateOrchestrationStatusAssignedVnfTest() throws Exception { doNothing().when(aaiVnfResources).updateOrchestrationStatusVnf(genericVnf, OrchestrationStatus.ASSIGNED); @@ -743,4 +763,10 @@ public class AAIUpdateTasksTest extends BaseTaskTest { aaiUpdateTasks.updateOrchestrationStatusConfigDeployConfiguredVnf(execution); } + + private Pnf preparePnfAndExtractForPnf() throws BBObjectNotFoundException { + Pnf pnf = buildPnf(); + when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.PNF))).thenReturn(pnf); + return pnf; + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasksTest.java new file mode 100644 index 0000000000..f8ecf01579 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ExternalTicketTasksTest.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 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.bpmn.infrastructure.manualhandling.tasks; + +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.onap.so.bpmn.BaseTaskTest; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.ticket.ExternalTicket; + +public class ExternalTicketTasksTest extends BaseTaskTest { + + @Mock + private BuildingBlockExecution buildingBlockExecution; + + @Mock + private GeneralBuildingBlock generalBuildingBlock; + + @Mock + private RequestContext requestContext; + + @Mock + private ExternalTicket MOCK_externalTicket; + + @Before + public void before() throws Exception { + delegateExecution = new DelegateExecutionFake(); + buildingBlockExecution = new DelegateExecutionImpl(delegateExecution); + generalBuildingBlock = new GeneralBuildingBlock(); + requestContext = new RequestContext(); + requestContext.setRequestorId("someRequestorId"); + generalBuildingBlock.setRequestContext(requestContext); + buildingBlockExecution.setVariable("mso-request-id", ("testMsoRequestId")); + buildingBlockExecution.setVariable("vnfType", "testVnfType"); + buildingBlockExecution.setVariable("gBBInput", generalBuildingBlock); + buildingBlockExecution.setVariable("rainyDayVnfName", "someVnfName"); + buildingBlockExecution.setVariable("workStep", "someWorkstep"); + buildingBlockExecution.setVariable("taskTimeout", "PT5M"); + } + + @Test + public void createExternalTicket_Test() throws Exception { + ExternalTicketTasks externalTicketTasksSpy = spy(new ExternalTicketTasks()); + when(externalTicketTasksSpy.getExternalTicket()).thenReturn(MOCK_externalTicket); + externalTicketTasksSpy.createExternalTicket(buildingBlockExecution); + verify(MOCK_externalTicket, times(1)).createTicket(); + } +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java index b40195c07b..b6dcd96534 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java @@ -37,9 +37,13 @@ import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.client.ticket.ExternalTicket; import org.onap.so.db.request.beans.InfraActiveRequests; public class ManualHandlingTasksTest extends BaseTaskTest { @@ -61,14 +65,36 @@ public class ManualHandlingTasksTest extends BaseTaskTest { @Mock private BuildingBlockExecution buildingBlockExecution; + @Mock + private GeneralBuildingBlock generalBuildingBlock; + + @Mock + private RequestContext requestContext; + + @Mock + private ExternalTicket MOCK_externalTicket; + @Before public void before() throws Exception { + MockitoAnnotations.initMocks(this); delegateExecution = new DelegateExecutionFake(); buildingBlockExecution = new DelegateExecutionImpl(delegateExecution); + generalBuildingBlock = new GeneralBuildingBlock(); + requestContext = new RequestContext(); + requestContext.setRequestorId("someRequestorId"); + generalBuildingBlock.setRequestContext(requestContext); + buildingBlockExecution.setVariable("mso-request-id", ("testMsoRequestId")); + buildingBlockExecution.setVariable("vnfType", "testVnfType"); + buildingBlockExecution.setVariable("gBBInput", generalBuildingBlock); + buildingBlockExecution.setVariable("rainyDayVnfName", "someVnfName"); + buildingBlockExecution.setVariable("workStep", "someWorkstep"); + buildingBlockExecution.setVariable("taskTimeout", "PT5M"); } @Test public void setFalloutTaskVariables_Test() { + when(mockExecution.getVariable("gBuildingBlockExecution")).thenReturn(buildingBlockExecution); + buildingBlockExecution.setVariable("gBBInput", generalBuildingBlock); when(task.getId()).thenReturn("taskId"); when(task.getExecution()).thenReturn(mockExecution); when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices); @@ -103,7 +129,6 @@ public class ManualHandlingTasksTest extends BaseTaskTest { @Test public void updateRequestDbStatus_Test() throws Exception { InfraActiveRequests mockedRequest = new InfraActiveRequests(); - buildingBlockExecution.setVariable("mso-request-id", "msoRequestId"); when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest); doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class)); manualHandlingTasks.updateRequestDbStatus(buildingBlockExecution, "IN_PROGRESS"); @@ -111,10 +136,4 @@ public class ManualHandlingTasksTest extends BaseTaskTest { assertEquals(mockedRequest.getRequestStatus(), "IN_PROGRESS"); } - @Test - public void createExternalTicket_Test() throws Exception { - buildingBlockExecution.setVariable("mso-request-id", ("testMsoRequestId")); - buildingBlockExecution.setVariable("vnfType", "testVnfType"); - manualHandlingTasks.createExternalTicket(buildingBlockExecution); - } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index cc4a5ce04e..8e47c34cb0 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -36,8 +36,11 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.when; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; @@ -224,6 +227,28 @@ public class WorkflowActionTest extends BaseTaskTest { assertEqualsBulkFlowName(ebbs, "AssignServiceInstanceBB", "ActivateServiceInstanceBB"); } + @Test + public void selectExecutionListDuplicateNameExceptionTest() throws Exception { + String gAction = "createInstance"; + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + String bpmnRequest = + new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", true); + execution.setVariable("apiVersion", "7"); + execution.setVariable("requestUri", "v6/serviceInstances"); + execution.setVariable("requestAction", gAction); + + doThrow(new DuplicateNameException( + "serviceInstance with name (instanceName) and different version id (3c40d244-808e-42ca-b09a-256d83d19d0a) already exists. The name must be unique.")) + .when(SPY_workflowAction).validateResourceIdInAAI(anyString(), eq(WorkflowType.SERVICE), + eq("test"), any(RequestDetails.class), any(WorkflowResourceIds.class)); + + SPY_workflowAction.selectExecutionList(execution); + assertEquals(execution.getVariable("WorkflowActionErrorMessage"), + "Exception while setting execution list. serviceInstance with name (instanceName) and different version id (3c40d244-808e-42ca-b09a-256d83d19d0a) already exists. The name must be unique."); + } + /** * SERVICE MACRO TESTS */ diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java index a929f256ac..6d5e6db083 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java @@ -22,6 +22,7 @@ package org.onap.so.client.orchestration; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; @@ -83,4 +84,17 @@ public class AAIPnfResourcesTest extends TestDataSetup { verify(aaiResourcesClientMock, times(1)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class)); } + @Test + public void updateOrchestrationStatusPnfShouldSetStatusAndUpdatePnfInAAI() { + org.onap.aai.domain.yang.Pnf pnfYang = new org.onap.aai.domain.yang.Pnf(); + doReturn(pnfYang).when(aaiObjectMapperMock).mapPnf(pnf); + + aaiPnfResources.updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ACTIVE); + + assertEquals(OrchestrationStatus.ACTIVE, pnf.getOrchestrationStatus()); + verify(aaiObjectMapperMock, times(1)) + .mapPnf(argThat(arg -> OrchestrationStatus.ACTIVE.equals(arg.getOrchestrationStatus()))); + verify(aaiResourcesClientMock, times(1)).update(any(AAIResourceUri.class), eq(pnfYang)); + } + } diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json index 39e87f19f1..1dd475cad4 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroAssign.json @@ -24,7 +24,8 @@ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", "source": "VID", "suppressRollback": true, - "requestorId": "xxxxxx" + "requestorId": "xxxxxx", + "instanceName": "test" }, "requestParameters": { "subscriptionServiceType": "VMX", diff --git a/common/src/main/java/org/onap/so/client/ruby/RubyClient.java b/common/src/main/java/org/onap/so/client/ruby/RubyClient.java deleted file mode 100644 index 6c8f48884d..0000000000 --- a/common/src/main/java/org/onap/so/client/ruby/RubyClient.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.client.ruby; - -import java.io.IOException; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import org.onap.so.client.dmaap.DmaapPublisher; -import org.onap.so.client.ruby.beans.Event; -import org.onap.so.client.ruby.beans.MsoRequest; -import org.onap.so.client.ruby.beans.Ruby; -import org.onap.so.client.ruby.dmaap.RubyCreateTicketRequestPublisher; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - - -public class RubyClient { - - private static final String REQUEST_CLIENT_NAME = "MSO"; - private static final String ACTION = "Create Ticket"; - - protected String buildRequest(String requestId, String sourceName, String reason, String workflowId, - String notification) throws JsonProcessingException { - final MsoRequest request = new MsoRequest(); - request.withRequestClientName(REQUEST_CLIENT_NAME).withRequestId(requestId).withSourceName(sourceName) - .withWorkflowId(workflowId).withAction(ACTION); - - request.withRequestTime(this.getTime()); - - if (reason.length() <= 255) { - request.withReason(reason); - } else { - throw new IllegalArgumentException("reason exceeds 255 characters"); - } - if (notification.length() <= 1024) { - request.withNotification(notification); - } else { - throw new IllegalArgumentException("notification exceeds 1024 characters"); - } - final Event event = new Event(); - event.setMsoRequest(request); - final Ruby ruby = new Ruby(); - ruby.setEvent(event); - return this.getJson(ruby); - } - - protected String getJson(Ruby obj) throws JsonProcessingException { - final ObjectMapper mapper = new ObjectMapper(); - return mapper.writeValueAsString(obj); - } - - protected DmaapPublisher getPublisher() throws IOException { - return new RubyCreateTicketRequestPublisher(); - } - - protected String getTime() { - final ZonedDateTime currentDateTime = ZonedDateTime.now(ZoneOffset.UTC); - final DateTimeFormatter format = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss Z"); - return currentDateTime.format(format); - } - - public void rubyCreateTicketCheckRequest(String requestId, String sourceName, String reason, String workflowId, - String notification) throws Exception { - String request = this.buildRequest(requestId, sourceName, reason, workflowId, notification); - final DmaapPublisher publisher = this.getPublisher(); - publisher.send(request); - } -} diff --git a/common/src/main/java/org/onap/so/client/ruby/beans/Event.java b/common/src/main/java/org/onap/so/client/ruby/beans/Event.java deleted file mode 100644 index 2737342adc..0000000000 --- a/common/src/main/java/org/onap/so/client/ruby/beans/Event.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.client.ruby.beans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"msoRequest"}) -public class Event { - - @JsonProperty("msoRequest") - private MsoRequest msoRequest; - - /** - * No args constructor for use in serialization - * - */ - public Event() {} - - /** - * - * @param msoRequest - */ - public Event(MsoRequest msoRequest) { - super(); - this.msoRequest = msoRequest; - } - - @JsonProperty("msoRequest") - public MsoRequest getMsoRequest() { - return msoRequest; - } - - @JsonProperty("msoRequest") - public void setMsoRequest(MsoRequest msoRequest) { - this.msoRequest = msoRequest; - } - - public Event withMsoRequest(MsoRequest msoRequest) { - this.msoRequest = msoRequest; - return this; - } - -} diff --git a/common/src/main/java/org/onap/so/client/ruby/beans/MsoRequest.java b/common/src/main/java/org/onap/so/client/ruby/beans/MsoRequest.java deleted file mode 100644 index 15cfc9222f..0000000000 --- a/common/src/main/java/org/onap/so/client/ruby/beans/MsoRequest.java +++ /dev/null @@ -1,199 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.client.ruby.beans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"requestClientName", "requestId", "requestTime", "sourceName", "reason", "action", "workflowId", - "notification"}) -public class MsoRequest { - - @JsonProperty("requestClientName") - private String requestClientName; - @JsonProperty("requestId") - private String requestId; - @JsonProperty("requestTime") - private String requestTime; - @JsonProperty("sourceName") - private String sourceName; - @JsonProperty("reason") - private String reason; - @JsonProperty("action") - private String action; - @JsonProperty("workflowId") - private String workflowId; - @JsonProperty("notification") - private String notification; - - /** - * No args constructor for use in serialization - * - */ - public MsoRequest() {} - - /** - * - * @param requestClientName - * @param requestTime - * @param reason - * @param requestId - * @param workflowId - * @param sourceName - * @param action - * @param notification - */ - public MsoRequest(String requestClientName, String requestId, String requestTime, String sourceName, String reason, - String action, String workflowId, String notification) { - super(); - this.requestClientName = requestClientName; - this.requestId = requestId; - this.requestTime = requestTime; - this.sourceName = sourceName; - this.reason = reason; - this.action = action; - this.workflowId = workflowId; - this.notification = notification; - } - - @JsonProperty("requestClientName") - public String getRequestClientName() { - return requestClientName; - } - - @JsonProperty("requestClientName") - public void setRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - } - - public MsoRequest withRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - return this; - } - - @JsonProperty("requestId") - public String getRequestId() { - return requestId; - } - - @JsonProperty("requestId") - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public MsoRequest withRequestId(String requestId) { - this.requestId = requestId; - return this; - } - - @JsonProperty("requestTime") - public String getRequestTime() { - return requestTime; - } - - @JsonProperty("requestTime") - public void setRequestTime(String requestTime) { - this.requestTime = requestTime; - } - - public MsoRequest withRequestTime(String requestTime) { - this.requestTime = requestTime; - return this; - } - - @JsonProperty("sourceName") - public String getSourceName() { - return sourceName; - } - - @JsonProperty("sourceName") - public void setSourceName(String sourceName) { - this.sourceName = sourceName; - } - - public MsoRequest withSourceName(String sourceName) { - this.sourceName = sourceName; - return this; - } - - @JsonProperty("reason") - public String getReason() { - return reason; - } - - @JsonProperty("reason") - public void setReason(String reason) { - this.reason = reason; - } - - public MsoRequest withReason(String reason) { - this.reason = reason; - return this; - } - - @JsonProperty("action") - public String getAction() { - return action; - } - - @JsonProperty("action") - public void setAction(String action) { - this.action = action; - } - - public MsoRequest withAction(String action) { - this.action = action; - return this; - } - - @JsonProperty("workflowId") - public String getWorkflowId() { - return workflowId; - } - - @JsonProperty("workflowId") - public void setWorkflowId(String workflowId) { - this.workflowId = workflowId; - } - - public MsoRequest withWorkflowId(String workflowId) { - this.workflowId = workflowId; - return this; - } - - @JsonProperty("notification") - public String getNotification() { - return notification; - } - - @JsonProperty("notification") - public void setNotification(String notification) { - this.notification = notification; - } - - public MsoRequest withNotification(String notification) { - this.notification = notification; - return this; - } - -} diff --git a/common/src/main/java/org/onap/so/client/ruby/beans/Ruby.java b/common/src/main/java/org/onap/so/client/ruby/beans/Ruby.java deleted file mode 100644 index 708b91638b..0000000000 --- a/common/src/main/java/org/onap/so/client/ruby/beans/Ruby.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.client.ruby.beans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"event"}) -public class Ruby { - - @JsonProperty("event") - private Event event; - - /** - * No args constructor for use in serialization - * - */ - public Ruby() {} - - /** - * - * @param event - */ - public Ruby(Event event) { - super(); - this.event = event; - } - - @JsonProperty("event") - public Event getEvent() { - return event; - } - - @JsonProperty("event") - public void setEvent(Event event) { - this.event = event; - } - - public Ruby withEvent(Event event) { - this.event = event; - return this; - } - -} diff --git a/common/src/main/java/org/onap/so/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java b/common/src/main/java/org/onap/so/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java deleted file mode 100644 index 10402d9921..0000000000 --- a/common/src/main/java/org/onap/so/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.client.ruby.dmaap; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Optional; -import org.onap.so.client.dmaap.DmaapPublisher; - -public class RubyCreateTicketRequestPublisher extends DmaapPublisher { - public RubyCreateTicketRequestPublisher() throws FileNotFoundException, IOException { - super(); - } - - @Override - public String getAuth() { - return msoProperties.get("ruby.create-ticket-request.dmaap.auth"); - } - - @Override - public String getKey() { - return msoProperties.get("mso.msoKey"); - } - - @Override - public String getTopic() { - return msoProperties.get("ruby.create-ticket-request.publisher.topic"); - } - - @Override - public Optional<String> getHost() { - return Optional.ofNullable(msoProperties.get("ruby.create-ticket-request.publisher.host")); - } - -} - - diff --git a/common/src/test/java/org/onap/so/BeansTest.java b/common/src/test/java/org/onap/so/BeansTest.java index 9e8a0184ab..01bdc4db38 100644 --- a/common/src/test/java/org/onap/so/BeansTest.java +++ b/common/src/test/java/org/onap/so/BeansTest.java @@ -63,7 +63,6 @@ public class BeansTest { test("org.onap.so.appc.orchestrator.service.beans"); test("org.onap.so.client.policy.entities"); test("org.onap.so.client.grm.beans"); - test("org.onap.so.client.ruby.beans"); test("org.onap.so.client.sdno.beans"); test("org.onap.so.entity"); test("org.onap.so.serviceinstancebeans"); diff --git a/common/src/test/java/org/onap/so/client/ruby/RubyCheckClientTest.java b/common/src/test/java/org/onap/so/client/ruby/RubyCheckClientTest.java deleted file mode 100644 index 1ca8942ac1..0000000000 --- a/common/src/test/java/org/onap/so/client/ruby/RubyCheckClientTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 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.client.ruby; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.text.ParseException; -import java.time.format.DateTimeFormatter; -import org.junit.Test; -import org.onap.so.client.ruby.beans.Ruby; -import static org.apache.commons.lang3.StringUtils.*; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class RubyCheckClientTest { - private final String fileLocation = "src/test/resources/org/onap/so/client/ruby/create-ticket/"; - private static final String REQUEST_ID = "abc123"; - private static final String SOURCE_NAME = "source-name"; - private static final String TIME = "test-time"; - private static final String REASON = "reason"; - private static final String WORK_FLOW_ID = "work-flow-Id"; - private static final String NOTIFICATION = "notification"; - - - - @Test - public void verifyRubyCreateTicketRequest() throws IOException, ParseException { - String content = this.getJson("create-ticket-request.json"); - ObjectMapper mapper = new ObjectMapper(); - Ruby expected = mapper.readValue(content, Ruby.class); - RubyClient client = new RubyClient(); - RubyClient spy = spy(client); - when(spy.getTime()).thenReturn(TIME); - String actual = spy.buildRequest(REQUEST_ID, SOURCE_NAME, REASON, WORK_FLOW_ID, NOTIFICATION); - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - } - - - @Test - public void verifyTimeFormat() { - RubyClient client = new RubyClient(); - String time = client.getTime(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss Z"); - formatter.parse(time); - } - - - @Test - public void verifyReasonCharLimit() throws IOException { - final String reasonLong = repeat("*", 256); - RubyClient client = new RubyClient(); - try { - client.buildRequest(REQUEST_ID, SOURCE_NAME, reasonLong, WORK_FLOW_ID, NOTIFICATION); - fail("Should have thrown IllegalArgumentException but did not!"); - } catch (final IllegalArgumentException e) { - final String msg = "reason exceeds 255 characters"; - assertEquals(msg, e.getMessage()); - } - } - - @Test - public void verifyNotificationCharLimit() throws IOException { - final String notificationLong = repeat("*", 1025); - RubyClient client = new RubyClient(); - try { - client.buildRequest(REQUEST_ID, SOURCE_NAME, REASON, WORK_FLOW_ID, notificationLong); - fail("Should have thrown IllegalArgumentException but did not!"); - } catch (final IllegalArgumentException e) { - final String msg = "notification exceeds 1024 characters"; - assertEquals(msg, e.getMessage()); - } - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); - } - -} - diff --git a/common/src/test/java/org/onap/so/client/ruby/beans/RubyBeansTest.java b/common/src/test/java/org/onap/so/client/ruby/beans/RubyBeansTest.java deleted file mode 100644 index ca80930468..0000000000 --- a/common/src/test/java/org/onap/so/client/ruby/beans/RubyBeansTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 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.client.ruby.beans; - -import org.junit.Test; -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterEnum; -import com.openpojo.reflection.filters.FilterPackageInfo; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - -public class RubyBeansTest { - - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - @Test - public void pojoStructure() { - test("org.onap.so.client.ruby.beans"); - } - - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new SetterMustExistRule()) - .with(new SetterTester()).with(new GetterTester()).build(); - validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); - } - - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } -} diff --git a/common/src/test/resources/org/onap/so/client/ruby/create-ticket/create-ticket-request.json b/common/src/test/resources/org/onap/so/client/ruby/create-ticket/create-ticket-request.json deleted file mode 100644 index e388d3e9ad..0000000000 --- a/common/src/test/resources/org/onap/so/client/ruby/create-ticket/create-ticket-request.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "event": { - "msoRequest": { - "requestClientName": "MSO", - "requestId": "abc123", - "requestTime": "test-time", - "sourceName": "source-name", - "reason": "reason", - "action": "Create Ticket", - "workflowId": "work-flow-Id", - "notification": "notification" - } -} -} - 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 7e4452aeb3..34eca2f266 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 @@ -66,7 +66,7 @@ import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; -@Path("/tasks") +@Path("/onap/so/infra/tasks") @Component public class ManualTasks { private static Logger logger = LoggerFactory.getLogger(ManualTasks.class); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java index b8d1e56cf7..fcf25b23e9 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ManualTasksTest.java @@ -52,7 +52,7 @@ import com.github.tomakehurst.wiremock.http.Fault; public class ManualTasksTest extends BaseTest { - private final String basePath = "/tasks/v1/"; + private final String basePath = "/onap/so/infra/tasks/v1/"; @Test public void testCreateOpEnvObjectMapperError() throws IOException { diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateTenantId.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateTenantId.json index 686faf15c0..ef7acdcb65 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateTenantId.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/MsoRequestTest/CloudConfiguration/InPlaceSoftwareUpdateTenantId.json @@ -35,7 +35,7 @@ ], "requestParameters": { "autoBuildVfModules": false, - "payload": "{\"existing-software-version\": \"3.1\",\"new-software-version\": \"3.2\", \"operations-timeout\": \"3600\"}" + "payload": "{\"existing_software_version\": \"3.1\",\"new_software_version\": \"3.2\", \"operations_timeout\": \"3600\"}" } } }
\ No newline at end of file |