summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-04-09 12:28:42 +0000
committerGerrit Code Review <gerrit@onap.org>2020-04-09 12:28:42 +0000
commitbeff102e821e81f2a54c0b40a9a5986079a8dfed (patch)
tree707709397dc660e393eb3c2bbed91a51e36acb0b /bpmn
parent5e8a0267b4c674c2935973f2e01d7a6695017e2d (diff)
parent1c2207093f959202f69e3978289c3dbf321053c7 (diff)
Merge "add junit coverage"
Diffstat (limited to 'bpmn')
-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()));