e00cb463f22a4cbc7b32bde200c5f94bbc7b2596
[music.git] / music-core / src / test / java / org / onap / music / unittests / jsonobjects / JsonUpdateTest.java
1 /*******************************************************************************
2  * ============LICENSE_START==========================================
3  * org.onap.music
4  * ===================================================================
5  *  Copyright (c) 2018 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
12  *
13  *     http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *  
21  * ============LICENSE_END=============================================
22  * ====================================================================
23  *******************************************************************************/
24
25 package org.onap.music.unittests.jsonobjects;
26
27 import static org.junit.Assert.*;
28 import java.util.HashMap;
29 import java.util.Map;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.onap.music.datastore.jsonobjects.JsonUpdate;
33
34 public class JsonUpdateTest {
35     
36     JsonUpdate ju = null;
37     
38     @Before
39     public void init() {
40         ju = new JsonUpdate();
41     }
42     
43
44     @Test
45     public void testGetConditions() {
46         Map<String,Object>  mapSo = new HashMap<>();
47         mapSo.put("key1","one");
48         mapSo.put("key2","two");
49         ju.setConditions(mapSo);
50         assertEquals("one",ju.getConditions().get("key1"));
51     }
52
53     @Test
54     public void testGetRow_specification() {
55         Map<String,Object>  mapSo = new HashMap<>();
56         mapSo.put("key1","one");
57         mapSo.put("key2","two");
58         ju.setRow_specification(mapSo);
59         assertEquals("one",ju.getRow_specification().get("key1"));
60     }
61
62     @Test
63     public void testGetKeyspaceName() {
64         String keyspace = "keyspace";
65         ju.setKeyspaceName(keyspace);
66         assertEquals(keyspace,ju.getKeyspaceName());
67     }
68
69     @Test
70     public void testGetTableName() {
71         String table = "table";
72         ju.setTableName(table);
73         assertEquals(table,ju.getTableName());
74    }
75
76     @Test
77     public void testGetConsistencyInfo() {
78         Map<String, String> mapSs = new HashMap<>();
79         mapSs.put("k1", "one");
80         ju.setConsistencyInfo(mapSs);
81         assertEquals("one",ju.getConsistencyInfo().get("k1"));
82     }
83
84     @Test
85     public void testGetTtl() {
86         ju.setTtl("2000");
87         assertEquals("2000",ju.getTtl());
88     }
89
90     @Test
91     public void testGetTimestamp() {
92         ju.setTimestamp("20:00");
93         assertEquals("20:00",ju.getTimestamp());
94
95     }
96
97     @Test
98     public void testGetValues() {
99         Map<String,Object> cons = new HashMap<>();
100         cons.put("val1","one");
101         cons.put("val2","two");
102         ju.setValues(cons);
103         assertEquals("one",ju.getValues().get("val1"));
104     }
105     
106     @Test
107     public void testSerialize() {
108         assertTrue(ju.serialize() instanceof byte[]);
109     }
110
111 }