2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
19 * * ============LICENSE_END=========================================================
\r
22 package org.onap.appc.flow.controller.node;
\r
24 import static org.junit.Assert.assertEquals;
\r
26 import java.util.ArrayList;
\r
27 import java.util.List;
\r
29 import org.junit.Test;
\r
30 import org.onap.appc.flow.controller.data.Transaction;
\r
31 import org.onap.appc.flow.controller.data.Transactions;
\r
33 import com.fasterxml.jackson.core.JsonProcessingException;
\r
34 import com.fasterxml.jackson.databind.ObjectMapper;
\r
37 * Adding this test case to ensure that JSON mapping works as expected.
\r
38 * Add or modify test case if changes are made to class attributes.
\r
41 public class MapperTest {
\r
44 public void testsIfJsonGenerationisValid() throws JsonProcessingException {
\r
46 Transaction t = new Transaction();
\r
47 Transactions transactions = new Transactions();
\r
48 t.setAction("testAction");
\r
49 t.setTransactionId(100);
\r
50 t.setActionLevel("testActionLevel");
\r
51 t.setExecutionRPC("testMethod");
\r
52 List<Transaction> tList = new ArrayList<Transaction>();
\r
54 transactions.setTransactions(tList);
\r
55 Transactions trans = transactions;
\r
56 ObjectMapper mapper = new ObjectMapper();
\r
57 String flowSequence = mapper.writeValueAsString(trans);
\r
58 String compareString = "{\"transactions\":[{\"executionType\":null,\"uId\":null,\"statusCode\":null,\"pswd\":null,"
\r
59 + "\"executionEndPoint\":null,\"executionModule\":null,\"executionRPC\":\"testMethod\","
\r
60 + "\"status\":\"PENDING\",\"transaction-id\":100,\"action\":\"testAction\","
\r
61 + "\"action-level\":\"testActionLevel\",\"action-identifier\":null,"
\r
62 + "\"parameters\":null,\"state\":null,\"precheck\":null,\"payload\":null,\"responses\":null}]}";
\r
63 assertEquals(flowSequence, compareString);
\r