Fixing infinte loop of flow 86/88886/2
authorwaqas.ikram <waqas.ikram@est.tech>
Thu, 30 May 2019 13:15:16 +0000 (13:15 +0000)
committerwaqas.ikram <waqas.ikram@est.tech>
Thu, 30 May 2019 13:15:16 +0000 (13:15 +0000)
Change-Id: I80dc144750406d5afcec9b4da717a55a3840e503
Issue-ID: SO-1946
Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java

index 4645680..4c84bca 100644 (file)
@@ -55,11 +55,18 @@ public class MonitorVnfmCreateJobTask extends MonitorVnfmJobTask {
      * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
      */
     public void getCurrentOperationStatus(final BuildingBlockExecution execution) {
-        LOGGER.debug("Executing getCurrentOperationStatus  ...");
-        final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
-        execution.setVariable(OPERATION_STATUS_PARAM_NAME,
-                getOperationStatus(execution, vnfInstantiateResponse.getJobId()));
-        LOGGER.debug("Finished executing getCurrentOperationStatus ...");
+        try {
+            LOGGER.debug("Executing getCurrentOperationStatus  ...");
+            final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
+            execution.setVariable(OPERATION_STATUS_PARAM_NAME,
+                    getOperationStatus(execution, vnfInstantiateResponse.getJobId()));
+            LOGGER.debug("Finished executing getCurrentOperationStatus ...");
+        } catch (final Exception exception) {
+            final String message = "Unable to invoke get current Operation status";
+            LOGGER.error(message);
+            exceptionUtil.buildAndThrowWorkflowException(execution, 1209, message);
+
+        }
     }
 
     /**
index e91f362..34e3efa 100644 (file)
@@ -56,10 +56,18 @@ public class MonitorVnfmDeleteJobTask extends MonitorVnfmJobTask {
      * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
      */
     public void getCurrentOperationStatus(final BuildingBlockExecution execution) {
-        LOGGER.debug("Executing getCurrentOperationStatus  ...");
-        final DeleteVnfResponse deleteVnfResponse = execution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME);
-        execution.setVariable(OPERATION_STATUS_PARAM_NAME, getOperationStatus(execution, deleteVnfResponse.getJobId()));
-        LOGGER.debug("Finished executing getCurrentOperationStatus ...");
+        try {
+            LOGGER.debug("Executing getCurrentOperationStatus  ...");
+            final DeleteVnfResponse deleteVnfResponse = execution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME);
+            execution.setVariable(OPERATION_STATUS_PARAM_NAME,
+                    getOperationStatus(execution, deleteVnfResponse.getJobId()));
+            LOGGER.debug("Finished executing getCurrentOperationStatus ...");
+        } catch (final Exception exception) {
+            final String message = "Unable to invoke get current Operation status";
+            LOGGER.error(message);
+            exceptionUtil.buildAndThrowWorkflowException(execution, 1216, message);
+
+        }
     }
 
     /**
index f193967..4a51891 100644 (file)
@@ -145,7 +145,7 @@ public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvide
             return Optional.of(response.getBody());
         } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) {
             LOGGER.error("Unexpected error while processing job request", httpInvocationException);
-            return Optional.absent();
+            throw httpInvocationException;
         }
     }
 }
index 7bd6435..e94d7c2 100644 (file)
@@ -228,7 +228,7 @@ public class VnfmAdapterServiceProviderImplTest {
         assertFalse(actual.isPresent());
     }
 
-    @Test
+    @Test(expected = RestProcessingException.class)
     public void testGetInstantiateOperationJobStatus_Exception() {
 
         when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
@@ -237,8 +237,7 @@ public class VnfmAdapterServiceProviderImplTest {
         final VnfmAdapterServiceProvider objUnderTest =
                 new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
 
-        final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
-        assertFalse(actual.isPresent());
+        objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
     }
 
     private QueryJobResponse getQueryJobResponse() {