2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (c) 2017 AT&T Intellectual Property
6 * ===================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * ============LICENSE_END=============================================
20 * ====================================================================
23 package org.onap.music.unittests.jsonobjects;
25 import static org.junit.Assert.*;
27 import java.io.Serializable;
28 import java.util.HashMap;
31 import org.apache.commons.lang3.SerializationUtils;
32 import org.junit.Test;
33 import org.onap.music.datastore.jsonobjects.JsonInsert;
35 public class JsonInsertTest {
37 JsonInsert ji = new JsonInsert();
40 public void testGetKeyspaceName() {
41 ji.setKeyspaceName("keyspace");
42 assertEquals("keyspace",ji.getKeyspaceName());
46 public void testGetTableName() {
47 ji.setTableName("table");
48 assertEquals("table",ji.getTableName());
52 public void testGetConsistencyInfo() {
53 Map<String,String> cons = new HashMap<>();
54 cons.put("test","true");
55 ji.setConsistencyInfo(cons);
56 assertEquals("true",ji.getConsistencyInfo().get("test"));
60 public void testGetTtl() {
62 assertEquals("ttl",ji.getTtl());
66 public void testGetTimestamp() {
67 ji.setTimestamp("10:30");
68 assertEquals("10:30",ji.getTimestamp());
72 public void testGetValues() {
73 Map<String,Object> cons = new HashMap<>();
74 cons.put("val1","one");
75 cons.put("val2","two");
77 assertEquals("one",ji.getValues().get("val1"));
81 public void testGetRowSpecification() {
82 Map<String,Object> cons = new HashMap<>();
83 cons.put("val1","one");
84 cons.put("val2","two");
85 ji.setRowSpecification(cons);
86 assertEquals("two",ji.getRowSpecification().get("val2"));
90 public void testSerialize() {
91 Map<String,Object> cons = new HashMap<>();
92 cons.put("val1","one");
93 cons.put("val2","two");
94 ji.setTimestamp("10:30");
95 ji.setRowSpecification(cons);
96 byte[] test1 = ji.serialize();
97 byte[] ji1 = SerializationUtils.serialize(ji);
98 assertArrayEquals(ji1,test1);