diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
-rw-r--r-- | bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java index 9adae88a5a..67ce6bfbe9 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java @@ -41,6 +41,7 @@ import org.onap.so.adapters.nwrest.CreateNetworkRequest; import org.onap.so.adapters.nwrest.CreateNetworkResponse; import org.onap.so.adapters.nwrest.DeleteNetworkRequest; import org.onap.so.adapters.nwrest.DeleteNetworkResponse; +import org.onap.so.adapters.nwrest.NetworkRequestCommon; import org.onap.so.adapters.nwrest.UpdateNetworkError; import org.onap.so.adapters.nwrest.UpdateNetworkRequest; import org.onap.so.adapters.nwrest.UpdateNetworkResponse; @@ -224,7 +225,7 @@ public class NetworkAdapterRestV1Test { deleteNetworkRequest.setMessageId(messageId); delegateExecution.setVariable("networkAdapterRequest", deleteNetworkRequest); Status status = Status.OK; - String responseEntity = "createNetworkResponse"; + String responseEntity = "deleteNetworkResponse"; Optional<Response> response = Optional.of(createResponse(status, responseEntity)); when(networkAdapterResources.deleteNetworkAsync(deleteNetworkRequest)).thenReturn(response); // when @@ -233,6 +234,47 @@ public class NetworkAdapterRestV1Test { verifyExecutionContent(status, responseEntity, messageId); } + @Test + public void callNetworkAdapter_UpdateNetworkRequestSuccess() throws Exception { + // given + String messageId = "UpdateNetReqMessageId"; + UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); + updateNetworkRequest.setMessageId(messageId); + delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest); + Status status = Status.OK; + String responseEntity = "updateNetworkResponse"; + Optional<Response> response = Optional.of(createResponse(status, responseEntity)); + when(networkAdapterResources.updateNetworkAsync(updateNetworkRequest)).thenReturn(response); + // when + networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); + // then + verifyExecutionContent(status, responseEntity, messageId); + } + + @Test + public void callNetworkAdapterError_networkAdapterRequestIsNull() { + // when + networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); + // then + verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000), + any(Exception.class), eq(ONAPComponents.SO)); + } + + @Test + public void callNetworkAdapterError_noResponse() throws Exception { + // given + String messageId = "UpdateNetReqMessageId"; + UpdateNetworkRequest updateNetworkRequest = new UpdateNetworkRequest(); + updateNetworkRequest.setMessageId(messageId); + delegateExecution.setVariable("networkAdapterRequest", updateNetworkRequest); + when(networkAdapterResources.updateNetworkAsync(updateNetworkRequest)).thenReturn(Optional.empty()); + // when + networkAdapterRestV1Tasks.callNetworkAdapter(delegateExecution); + // then + verify(exceptionBuilder, times(1)).buildAndThrowWorkflowException(any(DelegateExecution.class), eq(7000), + any(Exception.class), eq(ONAPComponents.SO)); + } + private void verifyExecutionContent(Status status, String responseEntity, String messageId) { assertEquals(delegateExecution.getVariable("NETWORKREST_networkAdapterStatusCode"), Integer.toString(status.getStatusCode())); |