1 package org.onap.appc.flow.controller.node;
3 import static org.mockito.Mockito.mock;
4 import static org.mockito.Mockito.when;
5 import static org.onap.appc.flow.controller.utils.FlowControllerConstants.ACTION_LEVEL;
6 import static org.onap.appc.flow.controller.utils.FlowControllerConstants.PAYLOAD;
7 import static org.onap.appc.flow.controller.utils.FlowControllerConstants.REQUEST_ACTION;
9 import java.util.HashMap;
10 import java.util.List;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.onap.appc.flow.controller.data.Response;
15 import org.onap.appc.flow.controller.data.ResponseAction;
16 import org.onap.appc.flow.controller.data.Transaction;
17 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
19 public class FlowGeneratorTest {
21 private HashMap<String, String> inParams;
22 private SvcLogicContext ctx;
26 inParams = new HashMap<>();
27 ctx = mock(SvcLogicContext.class);
31 public void should_get_proper_transactions() {
32 when(ctx.getAttribute(REQUEST_ACTION)).thenReturn("some-request-action");
33 when(ctx.getAttribute(ACTION_LEVEL)).thenReturn("some-action-level");
34 when(ctx.getAttribute(PAYLOAD)).thenReturn("some-payload");
36 FlowGenerator flowGenerator = new FlowGenerator();
37 List<Transaction> transactionsList = flowGenerator.createSingleStepModel(inParams, ctx).getTransactions();
39 Assert.assertEquals(1, transactionsList.size());
41 Transaction transaction = transactionsList.get(0);
42 Assert.assertEquals(1, transaction.getTransactionId());
43 Assert.assertEquals("some-request-action", transaction.getAction());
44 Assert.assertEquals("some-payload", transaction.getPayload());
45 Assert.assertEquals("some-action-level", transaction.getActionLevel());
47 List<Response> responses = transaction.getResponses();
48 Assert.assertEquals(1, responses.size());
50 ResponseAction responseAction = responses.get(0).getResponseAction();
51 Assert.assertTrue(responseAction.isStop());