summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2020-04-07 18:33:23 +0200
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2020-04-07 18:33:23 +0200
commit1c2207093f959202f69e3978289c3dbf321053c7 (patch)
treeaf458ab88dd083e2f35b32d67bab232969410345 /bpmn/so-bpmn-tasks
parentda123b489a80779f3162d9e007616c6a083414bc (diff)
add junit coverage
Issue-ID: SO-1576 Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com> Change-Id: Idbe2e35eecb16706d4ddf5447e4cc1efc0aa78fd
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/network/tasks/NetworkAdapterRestV1Test.java44
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()));