diff options
author | Gamboa, Gilbert <gilbert.g.gamboa@att.com> | 2019-09-17 09:38:30 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2019-09-17 09:38:31 -0400 |
commit | 15eb25e5711d3bf64b99a8e91ff704f39181b12d (patch) | |
tree | ed7ec6bdd660406965f78586f6617e74c7e2c911 /bpmn/mso-infrastructure-bpmn/src | |
parent | 80d6f2f06e538dbb212f968514f0943bb7dd41ba (diff) |
Async vnf adapter response not getting to bpmn
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
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn/src')
2 files changed, 123 insertions, 5 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java index 5f70ab5924..3a1e126fef 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImpl.java @@ -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 index 0000000000..d15d71a9e9 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/workflow/service/VnfAdapterNotifyServiceImplTest.java @@ -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)); + } +} |