Fixes in WorkflowAction 42/91142/3
authorr.bogacki <r.bogacki@samsung.com>
Wed, 10 Jul 2019 09:29:37 +0000 (11:29 +0200)
committerRobert Bogacki <r.bogacki@samsung.com>
Fri, 12 Jul 2019 06:49:14 +0000 (06:49 +0000)
Fixes in WorkflowAction according to the Sonar analysis:
-Fixed String comparison.
-Removed unnecessary method parameters.
-Updated junit test.

Issue-ID: SO-2107
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
Change-Id: I7522269e237f736521a627bcd1c8f77b0c776a70

bpmn/so-bpmn-building-blocks/src/test/java/org/onap/so/bpmn/infrastructure/bpmn/process/WorkflowActionBBTest.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java

index 051f373..bd29e55 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * 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
@@ -93,8 +95,7 @@ public class WorkflowActionBBTest extends BaseBPMNTest {
         Map<String, String> map = new HashMap<>();
         map.put("handlingCode", "Abort");
 
-        doThrow(new BpmnError("7000", "TESTING ERRORS")).when(workflowActionBBFailure)
-                .abortCallErrorHandling(any(DelegateExecution.class));
+        doThrow(new BpmnError("7000", "TESTING ERRORS")).when(workflowActionBBFailure).abortCallErrorHandling();
         mockSubprocess("ExecuteBuildingBlock", "Mocked ExecuteBuildingBlock", "GenericStub", map);
 
         ProcessInstance pi = runtimeService.startProcessInstanceByKey("WorkflowActionBB", variables);
index 2d3f5de..be3e06c 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * 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
@@ -143,10 +145,10 @@ public class WorkflowActionBBFailure {
         String errorMsg = null;
         try {
             WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
-            if (exception != null && (exception.getErrorMessage() != null || !exception.getErrorMessage().equals(""))) {
+            if (exception != null && (exception.getErrorMessage() != null || !"".equals(exception.getErrorMessage()))) {
                 errorMsg = exception.getErrorMessage();
             }
-            if (errorMsg == null || errorMsg.equals("")) {
+            if (errorMsg == null || "".equals(errorMsg)) {
                 errorMsg = (String) execution.getVariable("WorkflowExceptionErrorMessage");
             }
             if (errorMsg == null) {
@@ -165,7 +167,7 @@ public class WorkflowActionBBFailure {
         updateRequestStatusToFailed(execution);
     }
 
-    public void abortCallErrorHandling(DelegateExecution execution) {
+    public void abortCallErrorHandling() {
         String msg = "Flow has failed. Rainy day handler has decided to abort the process.";
         logger.error(msg);
         throw new BpmnError(msg);