2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (c) 2017 AT&T Intellectual Property
6 * ===================================================================
7 * Modifications Copyright (c) 2019 IBM.
8 * ===================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ============LICENSE_END=============================================
22 * ====================================================================
25 package org.onap.music.unittests.jsonobjects;
27 import static org.junit.Assert.assertArrayEquals;
28 import static org.junit.Assert.assertEquals;
30 import java.util.HashMap;
33 import org.apache.commons.lang3.SerializationUtils;
34 import org.junit.Test;
35 import org.onap.music.datastore.jsonobjects.JsonInsert;
37 public class JsonInsertTest {
39 JsonInsert ji = new JsonInsert();
42 public void testGetKeyspaceName() {
43 ji.setKeyspaceName("keyspace");
44 assertEquals("keyspace",ji.getKeyspaceName());
48 public void testGetTableName() {
49 ji.setTableName("table");
50 assertEquals("table",ji.getTableName());
54 public void testGetConsistencyInfo() {
55 Map<String,String> cons = new HashMap<>();
56 cons.put("test","true");
57 ji.setConsistencyInfo(cons);
58 assertEquals("true",ji.getConsistencyInfo().get("test"));
62 public void testGetTtl() {
64 assertEquals("ttl",ji.getTtl());
68 public void testGetTimestamp() {
69 ji.setTimestamp("10:30");
70 assertEquals("10:30",ji.getTimestamp());
74 public void testGetValues() {
75 Map<String,Object> cons = new HashMap<>();
76 cons.put("val1","one");
77 cons.put("val2","two");
79 assertEquals("one",ji.getValues().get("val1"));
83 public void testGetRowSpecification() {
84 Map<String,Object> cons = new HashMap<>();
85 cons.put("val1","one");
86 cons.put("val2","two");
87 ji.setRowSpecification(cons);
88 assertEquals("two",ji.getRowSpecification().get("val2"));
92 public void testSerialize() {
93 Map<String,Object> cons = new HashMap<>();
94 cons.put("val1","one");
95 cons.put("val2","two");
96 ji.setTimestamp("10:30");
97 ji.setRowSpecification(cons);
98 byte[] test1 = ji.serialize();
99 byte[] ji1 = SerializationUtils.serialize(ji);
100 assertArrayEquals(ji1,test1);
104 public void testObjectMap()
106 Map<String, byte[]> map = new HashMap<>();
107 ji.setObjectMap(map);
108 assertEquals(map, ji.getObjectMap());