Update junit test
[music.git] / src / test / java / org / onap / music / unittests / jsonobjects / JsonInsertTest.java
1 /*
2  * ============LICENSE_START==========================================
3  * org.onap.music
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
10  * 
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  * 
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.
18  * 
19  * ============LICENSE_END=============================================
20  * ====================================================================
21  */
22
23 package org.onap.music.unittests.jsonobjects;
24
25 import static org.junit.Assert.*;
26
27 import java.io.Serializable;
28 import java.util.HashMap;
29 import java.util.Map;
30
31 import org.apache.commons.lang3.SerializationUtils;
32 import org.junit.Test;
33 import org.onap.music.datastore.jsonobjects.JsonInsert;
34
35 public class JsonInsertTest {
36     
37     JsonInsert ji = new JsonInsert();
38
39     @Test
40     public void testGetKeyspaceName() {
41         ji.setKeyspaceName("keyspace");
42         assertEquals("keyspace",ji.getKeyspaceName());
43     }
44
45     @Test
46     public void testGetTableName() {
47         ji.setTableName("table");
48         assertEquals("table",ji.getTableName());
49     }
50
51     @Test
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"));
57     }
58
59     @Test
60     public void testGetTtl() {
61         ji.setTtl("ttl");
62         assertEquals("ttl",ji.getTtl());
63     }
64
65     @Test
66     public void testGetTimestamp() {
67         ji.setTimestamp("10:30");
68         assertEquals("10:30",ji.getTimestamp());
69     }
70
71     @Test
72     public void testGetValues() {
73         Map<String,Object> cons = new HashMap<>();
74         cons.put("val1","one");
75         cons.put("val2","two");
76         ji.setValues(cons);
77         assertEquals("one",ji.getValues().get("val1"));
78     }
79
80     @Test
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"));
87     }
88
89     @Test
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);
99     }
100
101
102
103 }