Code changes to fix Exception
[appc.git] / appc-config / appc-flow-controller / provider / src / test / java / org / onap / appc / flow / controller / node / MapperTest.java
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/MapperTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/MapperTest.java
new file mode 100644 (file)
index 0000000..dfeb497
--- /dev/null
@@ -0,0 +1,67 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ *  * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.onap.appc.flow.controller.node;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.junit.Test;\r
+import org.onap.appc.flow.controller.data.Transaction;\r
+import org.onap.appc.flow.controller.data.Transactions;\r
+\r
+import com.fasterxml.jackson.core.JsonProcessingException;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+\r
+/*\r
+ * Adding this test case to ensure that JSON mapping works as expected.\r
+ * Add or modify test case if changes are made to class attributes.\r
+ *\r
+*/\r
+public class MapperTest {\r
+\r
+    @Test\r
+    public void testsIfJsonGenerationisValid() throws JsonProcessingException {\r
+\r
+        Transaction t = new Transaction();\r
+        Transactions transactions = new Transactions();\r
+        t.setAction("testAction");\r
+        t.setTransactionId(100);\r
+        t.setActionLevel("testActionLevel");\r
+        t.setExecutionRPC("testMethod");\r
+        List<Transaction> tList = new ArrayList<Transaction>();\r
+        tList.add(t);\r
+        transactions.setTransactions(tList);\r
+        Transactions trans = transactions;\r
+        ObjectMapper mapper = new ObjectMapper();\r
+        String flowSequence = mapper.writeValueAsString(trans);\r
+        String compareString = "{\"transactions\":[{\"executionType\":null,\"uId\":null,\"statusCode\":null,\"pswd\":null,"\r
+                + "\"executionEndPoint\":null,\"executionModule\":null,\"executionRPC\":\"testMethod\","\r
+                + "\"status\":\"PENDING\",\"transaction-id\":100,\"action\":\"testAction\","\r
+                + "\"action-level\":\"testActionLevel\",\"action-identifier\":null,"\r
+                + "\"parameters\":null,\"state\":null,\"precheck\":null,\"payload\":null,\"responses\":null}]}";\r
+        assertEquals(flowSequence, compareString);\r
+\r
+    }\r
+\r
+}\r