diff options
author | Smokowski, Steven <steve.smokowski@att.com> | 2019-05-10 10:01:06 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-05-10 10:26:10 -0400 |
commit | c22110ebcc4df14891b0f3af3739a5a3fb4d51ef (patch) | |
tree | 880260bbe5c59fe2065d50a59e8536d232a75cc4 /bpmn/MSOCommonBPMN | |
parent | b9bb7f60815cd1e07b81d72b34ea1dcb4fa8d8c9 (diff) |
Update Rainy day handling to be more robust
Clean up unused tests and code, update UT
Fix issue with junits and conflicts on id field
Update Rainy day handling to be more robust
Change-Id: I2ce9a1288457017613dece19357e44b8566867c5
Issue-ID: SO-1866
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN')
2 files changed, 30 insertions, 48 deletions
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 c8e296d5ac..0a7a75c89b 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 @@ -82,7 +82,6 @@ public class ExecuteBuildingBlockRainyDay { boolean aLaCarte = (boolean) execution.getVariable("aLaCarte"); boolean suppressRollback = (boolean) execution.getVariable("suppressRollback"); String handlingCode = ""; - WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException"); try { // Extract error data to be returned to WorkflowAction @@ -97,6 +96,9 @@ public class ExecuteBuildingBlockRainyDay { try { serviceType = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0) .getModelInfoServiceInstance().getServiceType(); + if (serviceType == null || serviceType.isEmpty()) { + serviceType = ASTERISK; + } } catch (Exception ex) { // keep default serviceType value } @@ -118,6 +120,7 @@ public class ExecuteBuildingBlockRainyDay { } catch (Exception ex) { // keep default errorCode value } + try { errorCode = "" + (String) execution.getVariable("WorkflowExceptionCode"); } catch (Exception ex) { @@ -131,29 +134,19 @@ public class ExecuteBuildingBlockRainyDay { // keep default workStep value } - RainyDayHandlerStatus rainyDayHandlerStatus; - rainyDayHandlerStatus = catalogDbClient - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName, - serviceType, vnfType, errorCode, workStep); - if (rainyDayHandlerStatus == null) { - rainyDayHandlerStatus = catalogDbClient - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName, - ASTERISK, ASTERISK, errorCode, ASTERISK); + String errorMessage = ASTERISK; + try { + errorMessage = workflowException.getErrorMessage(); + } catch (Exception ex) { + // keep default workStep value } + RainyDayHandlerStatus rainyDayHandlerStatus; + rainyDayHandlerStatus = catalogDbClient.getRainyDayHandlerStatus(bbName, serviceType, vnfType, + errorCode, workStep, errorMessage); + if (rainyDayHandlerStatus == null) { - rainyDayHandlerStatus = catalogDbClient - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(bbName, - ASTERISK, ASTERISK, ASTERISK, ASTERISK); - if (rainyDayHandlerStatus == null) { - handlingCode = "Abort"; - } else { - if (primaryPolicy) { - handlingCode = rainyDayHandlerStatus.getPolicy(); - } else { - handlingCode = rainyDayHandlerStatus.getSecondaryPolicy(); - } - } + handlingCode = "Abort"; } else { if (primaryPolicy) { handlingCode = rainyDayHandlerStatus.getPolicy(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java index e8d597a823..c5da3cbd51 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java @@ -68,6 +68,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { delegateExecution.setVariable("WorkflowException", new WorkflowException("", 7000, "")); delegateExecution.setVariable("buildingBlock", executeBuildingBlock); delegateExecution.setVariable("lookupKeyMap", lookupKeyMap); + + delegateExecution.setVariable("WorkflowException", new WorkflowException("processKey", 7000, "errorMessage")); } @Test @@ -101,12 +103,10 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setPolicy("Rollback"); rainyDayHandlerStatus.setWorkStep(ASTERISK); - doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); - assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); } @@ -126,15 +126,9 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setPolicy("Rollback"); rainyDayHandlerStatus.setWorkStep(ASTERISK); - doReturn(null).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", "st1", "vnft1", "7000", ASTERISK); - doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", ASTERISK, ASTERISK, ASTERISK, ASTERISK); - + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", ASTERISK, ASTERISK, "errorMessage"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); - assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); assertEquals(5, delegateExecution.getVariable("maxRetries")); } @@ -145,9 +139,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", true); - doReturn(null).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), - isA(String.class), isA(String.class), isA(String.class), isA(String.class)); + doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatus(isA(String.class), isA(String.class), + isA(String.class), isA(String.class), isA(String.class), isA(String.class)); delegateExecution.setVariable("suppressRollback", false); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); @@ -157,9 +150,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { @Test public void queryRainyDayTableExceptionTest() { - doThrow(RuntimeException.class).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep(isA(String.class), - isA(String.class), isA(String.class), isA(String.class), isA(String.class)); + doThrow(RuntimeException.class).when(MOCK_catalogDbClient).getRainyDayHandlerStatus(isA(String.class), + isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class)); delegateExecution.setVariable("aLaCarte", true); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); delegateExecution.setVariable("suppressRollback", false); @@ -184,9 +176,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setWorkStep(ASTERISK); rainyDayHandlerStatus.setSecondaryPolicy("Abort"); - doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, false); @@ -210,9 +201,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setWorkStep(ASTERISK); rainyDayHandlerStatus.setSecondaryPolicy("Abort"); - doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); @@ -236,9 +226,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setWorkStep(ASTERISK); rainyDayHandlerStatus.setSecondaryPolicy("Abort"); - doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient) - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", "st1", "vnft1", "7000", "*"); + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); |