aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config/appc-flow-controller/provider
diff options
context:
space:
mode:
authorTomasz Gwozdecki <tomasz.gwozdecki@nokia.com>2018-07-11 03:52:04 -0400
committerTomasz Gwozdecki <tomasz.gwozdecki@nokia.com>2018-07-11 03:52:04 -0400
commit0bca5f40a33cd5663002c49ed3d6950ab8417487 (patch)
treea11ccadbab5cf4c6448e1fb585c66f15cd4ce4f1 /appc-config/appc-flow-controller/provider
parentec248ffb74f1c038fdd6c7a77411f628ef51366f (diff)
junits for DefaultResponseHandler
-Added new test for DefaultResponseHandler Change-Id: Iee616c2a73eee3b130bbc68a16055355ecf4eab9 Issue-ID: APPC-975 Signed-off-by: Tomasz Gwozdecki <tomasz.gwozdecki@nokia.com>
Diffstat (limited to 'appc-config/appc-flow-controller/provider')
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/ResponseHandlerImpl/DefaultResponseHandlerTest.java39
1 files changed, 36 insertions, 3 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/ResponseHandlerImpl/DefaultResponseHandlerTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/ResponseHandlerImpl/DefaultResponseHandlerTest.java
index 399259ad8..dc5e2553c 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/ResponseHandlerImpl/DefaultResponseHandlerTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/ResponseHandlerImpl/DefaultResponseHandlerTest.java
@@ -21,8 +21,10 @@ package org.onap.appc.flow.controller.ResponseHandlerImpl;
import static org.junit.Assert.assertEquals;
+import com.google.common.collect.Lists;
import java.util.Collections;
import org.junit.Test;
+import org.onap.appc.flow.controller.data.Response;
import org.onap.appc.flow.controller.data.ResponseAction;
import org.onap.appc.flow.controller.data.Transaction;
@@ -31,20 +33,51 @@ public class DefaultResponseHandlerTest {
@Test
public void handlerResponse_shouldReturnEmptyResponseAction_whenTransactionResponsesAreNull() {
Transaction transaction = new Transaction();
- assertDefaultResponseAction(transaction);
+ assertExpectedResponseAction(transaction, new ResponseAction());
}
@Test
public void handlerResponse_shouldReturnEmptyResponseAction_whenTransactionResponsesAreEmpty() {
Transaction transaction = new Transaction();
transaction.setResponses(Collections.emptyList());
- assertDefaultResponseAction(transaction);
+ assertExpectedResponseAction(transaction, new ResponseAction());
}
- private void assertDefaultResponseAction(Transaction transaction) {
+ @Test
+ public void handlerResponse_shouldReturnExpectedResponseAction_forMatchingStatusCode() {
// GIVEN
+ ResponseAction expectedResponseAction = createExpectedResponseAction();
+ String responseCode = "404";
+
+ Transaction transaction = new Transaction();
+ transaction.setStatusCode(responseCode);
+ transaction.setResponses(Lists.newArrayList(
+ createResponse(null, null),
+ createResponse(null, "500"),
+ createResponse(expectedResponseAction, responseCode)));
+
+ assertExpectedResponseAction(transaction, expectedResponseAction);
+ }
+
+ private ResponseAction createExpectedResponseAction() {
ResponseAction expectedResponseAction = new ResponseAction();
+ expectedResponseAction.setIntermediateMessage(true);
+ expectedResponseAction.setJump("value1");
+ expectedResponseAction.setRetry("value2");
+ expectedResponseAction.setWait("value3");
+ expectedResponseAction.setIgnore(true);
+ expectedResponseAction.setStop(true);
+ return expectedResponseAction;
+ }
+
+ private Response createResponse(ResponseAction expectedResponseAction, String responseCode) {
+ Response response = new Response();
+ response.setResponseCode(responseCode);
+ response.setResponseAction(expectedResponseAction);
+ return response;
+ }
+ private void assertExpectedResponseAction(Transaction transaction, ResponseAction expectedResponseAction) {
// WHEN
ResponseAction responseAction = new DefaultResponseHandler().handlerResponse(transaction);