Async vnf adapter response not getting to bpmn 18/95818/1
authorGamboa, Gilbert <gilbert.g.gamboa@att.com>
Tue, 17 Sep 2019 13:38:30 +0000 (09:38 -0400)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Tue, 17 Sep 2019 13:38:31 +0000 (09:38 -0400)
Async vnf adapter response is not getting to bpmn @OneWay web
methods in VnfAdapterNotifyServiceImpl class do not work with the
@Async  handleCallback() method in CallbackHandlerService. Updating
code to call the non-async version of the (overloaded) handleCallback
method until we can figure out how to properly do @oneway to @async.
Added junits to all methods in VnfAdapterNotifyServiceimpl

Issue-ID: SO-2347
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: I0e8b4a60addfc5e742c77e671377fa152ecce4db

bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java
bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImplTest.java [new file with mode: 0644]

index 5f70ab5..3a1e126 100644 (file)
@@ -82,7 +82,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple
         String correlationValue = messageId;
 
         callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable,
-                correlationValue, logMarker);
+                correlationValue, logMarker, null);
     }
 
     @WebMethod(operationName = "queryVnfNotification")
@@ -117,7 +117,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple
         message.setOutputs(outputs);
 
         callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable,
-                correlationValue, logMarker);
+                correlationValue, logMarker, null);
     }
 
     @WebMethod(operationName = "createVnfNotification")
@@ -150,7 +150,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple
         message.setRollback(rollback);
 
         callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable,
-                correlationValue, logMarker);
+                correlationValue, logMarker, null);
     }
 
     @WebMethod(operationName = "updateVnfNotification")
@@ -181,7 +181,7 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple
         message.setRollback(rollback);
 
         callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable,
-                correlationValue, logMarker);
+                correlationValue, logMarker, null);
     }
 
     @WebMethod(operationName = "deleteVnfNotification")
@@ -208,6 +208,6 @@ public class VnfAdapterNotifyServiceImpl extends ProcessEngineAwareService imple
         message.setErrorMessage(errorMessage);
 
         callback.handleCallback(method, message, messageEventName, messageVariable, correlationVariable,
-                correlationValue, logMarker);
+                correlationValue, logMarker, null);
     }
 }
diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImplTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImplTest.java
new file mode 100644 (file)
index 0000000..d15d71a
--- /dev/null
@@ -0,0 +1,118 @@
+package org.onap.so.bpmn.common.workflow.service;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.adapter.vnf.CreateVnfNotification;
+import org.onap.so.bpmn.common.adapter.vnf.DeleteVnfNotification;
+import org.onap.so.bpmn.common.adapter.vnf.MsoExceptionCategory;
+import org.onap.so.bpmn.common.adapter.vnf.QueryVnfNotification;
+import org.onap.so.bpmn.common.adapter.vnf.RollbackVnfNotification;
+import org.onap.so.bpmn.common.adapter.vnf.UpdateVnfNotification;
+import org.onap.so.bpmn.common.adapter.vnf.VnfRollback;
+import org.onap.so.bpmn.common.adapter.vnf.VnfStatus;
+import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackResult;
+
+@RunWith(MockitoJUnitRunner.class)
+public class VnfAdapterNotifyServiceImplTest {
+
+
+    @InjectMocks
+    @Spy
+    private VnfAdapterNotifyServiceImpl vnfAdapterNotifyServiceImpl;
+
+    @Mock
+    private CallbackHandlerService callbackHandlerService;
+
+    @Mock
+    private CallbackResult callbackResult;
+
+    protected CreateVnfNotification.Outputs outputs = new CreateVnfNotification.Outputs();
+    protected QueryVnfNotification.Outputs queryOutputs = new QueryVnfNotification.Outputs();
+    protected UpdateVnfNotification.Outputs updateOutputs = new UpdateVnfNotification.Outputs();
+
+    protected VnfRollback vnfRollback = new VnfRollback();
+
+    @Test
+    public void rollbackVnfNotificationTest() {
+        doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("rollbackVnfNotification"),
+                any(RollbackVnfNotification.class), eq("rollbackVnfNotificationCallback"),
+                eq("rollbackVnfNotificationCallback"), eq("VNFRB_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"),
+                eq(null));
+
+        vnfAdapterNotifyServiceImpl.rollbackVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK,
+                "Error creating stack");
+
+        verify(callbackHandlerService, times(1)).handleCallback(eq("rollbackVnfNotification"),
+                any(RollbackVnfNotification.class), eq("rollbackVnfNotificationCallback"),
+                eq("rollbackVnfNotificationCallback"), eq("VNFRB_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"),
+                eq(null));
+    }
+
+    @Test
+    public void queryVnfNotificationTest() {
+        doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("queryVnfNotification"),
+                any(QueryVnfNotification.class), eq("queryVnfNotificationCallback"), eq("queryVnfNotificationCallback"),
+                eq("VNFQ_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), eq(null));
+
+        vnfAdapterNotifyServiceImpl.queryVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, "",
+                Boolean.TRUE, "vnfid", VnfStatus.ACTIVE, queryOutputs);
+
+        verify(callbackHandlerService, times(1)).handleCallback(eq("queryVnfNotification"),
+                any(QueryVnfNotification.class), eq("queryVnfNotificationCallback"), eq("queryVnfNotificationCallback"),
+                eq("VNFQ_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"), eq(null));
+    }
+
+    @Test
+    public void createVnfNotificationTest() {
+        doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("createVnfNotification"),
+                any(CreateVnfNotification.class), eq("createVnfNotificationCallback"),
+                eq("createVnfNotificationCallback"), eq("VNFC_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"),
+                eq(null));
+
+        vnfAdapterNotifyServiceImpl.createVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, "",
+                "vnfId", outputs, vnfRollback);
+
+        verify(callbackHandlerService, times(1)).handleCallback(eq("createVnfNotification"),
+                any(CreateVnfNotification.class), eq("createVnfNotificationCallback"),
+                eq("createVnfNotificationCallback"), eq("VNFC_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"),
+                eq(null));
+    }
+
+    @Test
+    public void updateVnfNotificationTest() {
+        doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("updateVnfNotification"),
+                any(UpdateVnfNotification.class), eq("updateVnfNotificationCallback"),
+                eq("updateVnfNotificationCallback"), eq("VNFU_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"),
+                eq(null));
+
+        vnfAdapterNotifyServiceImpl.updateVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, "",
+                updateOutputs, vnfRollback);
+
+        verify(callbackHandlerService, times(1)).handleCallback(eq("updateVnfNotification"),
+                any(UpdateVnfNotification.class), eq("updateVnfNotificationCallback"),
+                eq("updateVnfNotificationCallback"), eq("VNFU_messageId"), eq("messageId"), eq("[VNF-NOTIFY]"),
+                eq(null));
+    }
+
+    @Test
+    public void deleteVnfNotificationTest() {
+        doReturn(callbackResult).when(callbackHandlerService).handleCallback(eq("deleteVnfNotification"),
+                any(DeleteVnfNotification.class), eq("deleteVnfACallback"), eq("deleteVnfACallback"), eq("VNFDEL_uuid"),
+                eq("messageId"), eq("[VNF-NOTIFY]"), eq(null));
+
+        vnfAdapterNotifyServiceImpl.deleteVnfNotification("messageId", true, MsoExceptionCategory.OPENSTACK, "");
+
+        verify(callbackHandlerService, times(1)).handleCallback(eq("deleteVnfNotification"),
+                any(DeleteVnfNotification.class), eq("deleteVnfACallback"), eq("deleteVnfACallback"), eq("VNFDEL_uuid"),
+                eq("messageId"), eq("[VNF-NOTIFY]"), eq(null));
+    }
+}