98afe858ba58f78ea48ea9a58f5adf9f098ba81a
[music.git] / src / test / java / org / onap / music / unittests / TstRestMusicLockAPI.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;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertTrue;
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
30 import java.util.Map;
31 import java.util.UUID;
32 import javax.ws.rs.core.MultivaluedMap;
33 import javax.ws.rs.core.Response;
34 import javax.ws.rs.core.UriInfo;
35 import org.junit.After;
36 import org.junit.AfterClass;
37 import org.junit.BeforeClass;
38 import org.junit.Ignore;
39 import org.junit.Test;
40 import org.junit.runner.RunWith;
41 import org.mindrot.jbcrypt.BCrypt;
42 import org.mockito.Mock;
43 import org.mockito.Mockito;
44 import org.mockito.junit.MockitoJUnitRunner;
45 import org.onap.music.datastore.PreparedQueryObject;
46 import org.onap.music.datastore.jsonobjects.JsonInsert;
47 import org.onap.music.datastore.jsonobjects.JsonLeasedLock;
48 import org.onap.music.datastore.jsonobjects.JsonLock;
49 import org.onap.music.datastore.jsonobjects.JsonTable;
50 import org.onap.music.datastore.jsonobjects.JsonUpdate;
51 import org.onap.music.exceptions.MusicServiceException;
52 import org.onap.music.lockingservice.cassandra.CassaLockStore;
53 import org.onap.music.lockingservice.cassandra.LockType;
54 import org.onap.music.main.MusicCore;
55 import org.onap.music.main.MusicUtil;
56 import org.onap.music.rest.RestMusicDataAPI;
57 import org.onap.music.rest.RestMusicLocksAPI;
58 import com.datastax.driver.core.DataType;
59 import com.datastax.driver.core.ResultSet;
60 import com.datastax.driver.core.Row;
61 import com.sun.jersey.core.util.Base64;
62 import com.sun.jersey.core.util.MultivaluedMapImpl;
63
64 @RunWith(MockitoJUnitRunner.class)
65 public class TstRestMusicLockAPI {
66
67
68     @Mock
69     UriInfo info;
70
71     RestMusicLocksAPI lock = new RestMusicLocksAPI();
72     RestMusicDataAPI data = new RestMusicDataAPI();
73     static PreparedQueryObject testObject;
74
75     static String appName = "TestApp";
76     static String userId = "TestUser";
77     static String password = "TestPassword";
78     static String authData = userId + ":" + password;
79     static String wrongAuthData = userId + ":" + "pass";
80     static String authorization = new String(Base64.encode(authData.getBytes()));
81     static String wrongAuthorization = new String(Base64.encode(wrongAuthData.getBytes()));
82     static boolean isAAF = false;
83     static UUID uuid = UUID.fromString("abc66ccc-d857-4e90-b1e5-df98a3d40ce6");
84     static String keyspaceName = "testcassa";
85     static String tableName = "employees";
86     static String onboardUUID = null;
87     static String lockName = "testcassa.employees.testname";
88
89     @BeforeClass
90     public static void init() throws Exception {
91         System.out.println("Testing RestMusicLock class");
92         try {
93             createKeyspace();
94         } catch (Exception e) {
95             e.printStackTrace();
96             throw new Exception("Unable to initialize before TestRestMusicData test class. " + e.getMessage());
97         }
98     }
99     
100     @After
101     public void afterEachTest() throws MusicServiceException {
102         clearAllTablesFromKeyspace();
103     }
104
105     @AfterClass
106     public static void tearDownAfterClass() throws Exception {
107         testObject = new PreparedQueryObject();
108         testObject.appendQueryString("DROP KEYSPACE IF EXISTS " + keyspaceName);
109         MusicCore.eventualPut(testObject);
110     }
111
112     @SuppressWarnings("unchecked")
113     @Test
114     public void test_createLockReference() throws Exception {
115         System.out.println("Testing create lockref");
116         createAndInsertIntoTable();
117         Response response = lock.createLockReference(lockName, "1", "1", authorization,
118                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", null, null, appName);
119         Map<String, Object> respMap = (Map<String, Object>) response.getEntity();
120         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
121
122         assertEquals(200, response.getStatus());
123         assertTrue(respMap.containsKey("lock"));
124         assertTrue(((Map<String, String>) respMap.get("lock")).containsKey("lock"));
125     }
126     
127     @Test
128     public void test_createBadLockReference() throws Exception {
129         System.out.println("Testing create bad lockref");
130         createAndInsertIntoTable();
131         Response response = lock.createLockReference("badlock", "1", "1", authorization,
132                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", null, null, appName);
133         Map<String, Object> respMap = (Map<String, Object>) response.getEntity();
134         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
135
136         assertEquals(400, response.getStatus());
137     }
138
139     @Test
140     public void test_createReadLock() throws Exception {
141         System.out.println("Testing create read lockref");
142         createAndInsertIntoTable();
143         JsonLock jsonLock = createJsonLock(LockType.READ);
144         Response response = lock.createLockReference(lockName, "1", "1", authorization,
145                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", jsonLock, null, appName);
146         Map<String, Object> respMap = (Map<String, Object>) response.getEntity();
147         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
148
149         assertEquals(200, response.getStatus());
150         assertTrue(respMap.containsKey("lock"));
151         assertTrue(((Map<String, String>) respMap.get("lock")).containsKey("lock"));
152     }
153
154     @Test
155     public void test_createWriteLock() throws Exception {
156         System.out.println("Testing create read lockref");
157         createAndInsertIntoTable();
158         JsonLock jsonLock = createJsonLock(LockType.WRITE);
159         Response response = lock.createLockReference(lockName, "1", "1", authorization,
160                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", jsonLock, null, appName);
161         Map<String, Object> respMap = (Map<String, Object>) response.getEntity();
162         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
163
164         assertEquals(200, response.getStatus());
165         assertTrue(respMap.containsKey("lock"));
166         assertTrue(((Map<String, String>) respMap.get("lock")).containsKey("lock"));
167     }
168
169     @Test
170     public void test_accquireLock() throws Exception {
171         System.out.println("Testing acquire lock");
172         createAndInsertIntoTable();
173         String lockRef = createLockReference();
174
175         Response response =
176                 lock.accquireLock(lockRef, "1", "1", authorization, "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
177         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
178         assertEquals(200, response.getStatus());
179     }
180
181     @Test
182     public void test_acquireReadLock() throws Exception {
183         System.out.println("Testing acquire read lock");
184         createAndInsertIntoTable();
185         String lockRef = createLockReference(LockType.READ);
186         String lockRef2 = createLockReference(LockType.READ);
187
188         Response response =
189                 lock.accquireLock(lockRef, "1", "1", authorization, "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
190         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
191         assertEquals(200, response.getStatus());
192         response =
193                 lock.accquireLock(lockRef2, "1", "1", authorization, "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
194         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
195         assertEquals(200, response.getStatus());
196     }
197     
198     @Test
199     public void test_acquireReadLockaFail() throws Exception {
200         System.out.println("Testing acquire read lock");
201         createAndInsertIntoTable();
202         String lockRef = createLockReference(LockType.WRITE);
203         String lockRef2 = createLockReference(LockType.READ);
204
205         Response response =
206                 lock.accquireLock(lockRef, "1", "1", authorization, "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
207         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
208         assertEquals(200, response.getStatus());
209         response =
210                 lock.accquireLock(lockRef2, "1", "1", authorization, "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
211         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
212         assertEquals(400, response.getStatus());
213     }
214
215     @Test
216     public void test_writeWReadLock() throws Exception {
217         System.out.println("Testing writing with a read lock");
218         createAndInsertIntoTable();
219         String lockRef = createLockReference(LockType.READ);
220
221         JsonUpdate jsonUpdate = new JsonUpdate();
222         Map<String, String> consistencyInfo = new HashMap<>();
223         Map<String, Object> values = new HashMap<>();
224         values.put("emp_salary", 2500);
225         consistencyInfo.put("type", "critical");
226         consistencyInfo.put("lockId", lockRef);
227         jsonUpdate.setConsistencyInfo(consistencyInfo);
228         jsonUpdate.setKeyspaceName(keyspaceName);
229         jsonUpdate.setTableName(tableName);
230         jsonUpdate.setValues(values);
231         MultivaluedMap<String, String> row = new MultivaluedMapImpl();
232         row.add("emp_name", "testname");
233         Mockito.when(info.getQueryParameters()).thenReturn(row);
234
235         Response response = data.updateTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
236                 authorization, jsonUpdate, keyspaceName, tableName, info);
237
238         assertEquals(400, response.getStatus());
239     }
240
241     @Test
242     public void test_writeWWriteLock() throws Exception {
243         System.out.println("Testing writing with a read lock");
244         createAndInsertIntoTable();
245         String lockRef = createLockReference(LockType.WRITE);
246
247         JsonUpdate jsonUpdate = new JsonUpdate();
248         Map<String, String> consistencyInfo = new HashMap<>();
249         Map<String, Object> values = new HashMap<>();
250         values.put("emp_salary", 2500);
251         consistencyInfo.put("type", "critical");
252         consistencyInfo.put("lockId", lockRef);
253         jsonUpdate.setConsistencyInfo(consistencyInfo);
254         jsonUpdate.setKeyspaceName(keyspaceName);
255         jsonUpdate.setTableName(tableName);
256         jsonUpdate.setValues(values);
257         MultivaluedMap<String, String> row = new MultivaluedMapImpl();
258         row.add("emp_name", "testname");
259         Mockito.when(info.getQueryParameters()).thenReturn(row);
260
261         Response response = data.updateTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
262                 authorization, jsonUpdate, keyspaceName, tableName, info);
263
264         assertEquals(200, response.getStatus());
265     }
266
267     @Test
268     public void test_accquireLockWLease() throws Exception {
269         System.out.println("Testing acquire lock with lease");
270         createAndInsertIntoTable();
271         String lockRef = createLockReference();
272
273         JsonLeasedLock jsonLock = new JsonLeasedLock();
274         jsonLock.setLeasePeriod(10000); // 10 second lease period?
275         Response response = lock.accquireLockWithLease(jsonLock, lockRef, "1", "1", authorization,
276                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
277         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
278         assertEquals(200, response.getStatus());
279     }
280     
281     @Test
282     public void test_accquireBadLockWLease() throws Exception {
283         System.out.println("Testing acquire bad lock ref with lease");
284         createAndInsertIntoTable();
285         String lockRef = createLockReference();
286
287         JsonLeasedLock jsonLock = new JsonLeasedLock();
288         jsonLock.setLeasePeriod(10000); // 10 second lease period?
289         Response response = lock.accquireLockWithLease(jsonLock, "badlock", "1", "1", authorization,
290                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
291         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
292         assertEquals(400, response.getStatus());
293     }
294     
295     @Test
296     public void test_accquireBadLock() throws Exception {
297         System.out.println("Testing acquire lock that is not lock-holder");
298         createAndInsertIntoTable();
299         // This is required to create an initial loc reference.
300         String lockRef1 = createLockReference();
301         // This will create the next lock reference, whcih will not be avalale yet.
302         String lockRef2 = createLockReference();
303
304         Response response = lock.accquireLock(lockRef2, "1", "1", authorization,
305                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
306         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
307         assertEquals(400, response.getStatus());
308     }
309     
310     @Test
311     public void test_accquireBadLockRef() throws Exception {
312         System.out.println("Testing acquire bad lock ref");
313         createAndInsertIntoTable();
314         // This is required to create an initial loc reference.
315         String lockRef1 = createLockReference();
316
317         Response response = lock.accquireLock("badlockref", "1", "1", authorization,
318                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
319         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
320         assertEquals(400, response.getStatus());
321     }
322     
323     @Test
324     public void test_currentLockHolder() throws Exception {
325         System.out.println("Testing get current lock holder");
326         createAndInsertIntoTable();
327
328         String lockRef = createLockReference();
329
330         Response response =
331                 lock.enquireLock(lockName, "1", "1", authorization, "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
332         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
333         assertEquals(200, response.getStatus());
334         Map<String, Object> respMap = (Map<String, Object>) response.getEntity();
335         assertEquals(lockRef, ((Map<String, String>) respMap.get("lock")).get("lock-holder"));
336     }
337     
338     @Test
339     public void test_nocurrentLockHolder() throws Exception {
340         System.out.println("Testing get current lock holder w/ bad lockref");
341         createAndInsertIntoTable();
342
343         Response response =
344                 lock.enquireLock(lockName, "1", "1", authorization, "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
345         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
346         assertEquals(400, response.getStatus());
347     }
348     
349     @Test
350     public void test_badcurrentLockHolder() throws Exception {
351         System.out.println("Testing get current lock holder w/ bad lockref");
352         createAndInsertIntoTable();
353
354         String lockRef = createLockReference();
355
356         Response response =
357                 lock.enquireLock("badlock", "1", "1", authorization, "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
358         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
359         assertEquals(400, response.getStatus());
360     }
361     
362     @Test
363     public void test_holders() throws Exception {
364         System.out.println("Testing holders api");
365         createAndInsertIntoTable();
366
367         String lockRef = createLockReference();
368         
369         Response response =
370                 lock.currentLockHolder(lockName, "1", "1", authorization, "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
371         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
372         assertEquals(200, response.getStatus());
373         Map<String, Object> respMap = (Map<String, Object>) response.getEntity();
374         assertEquals(lockRef, ((Map<String, List>) respMap.get("lock")).get("lock-holder").get(0));
375     }
376     
377     @Test
378     public void test_holdersbadRef() throws Exception {
379         System.out.println("Testing holders api w/ bad lockref");
380         createAndInsertIntoTable();
381
382         String lockRef = createLockReference();
383         
384         Response response =
385                 lock.currentLockHolder("badname", "1", "1", authorization, "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
386         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
387         assertEquals(400, response.getStatus());
388     }
389     
390     @Test
391     public void test_unLock() throws Exception {
392         System.out.println("Testing unlock");
393         createAndInsertIntoTable();
394         String lockRef = createLockReference();
395
396         Response response =
397                 lock.unLock(lockRef, "1", "1", authorization, "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
398         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
399         assertEquals(200, response.getStatus());
400     }
401     
402     @Test
403     public void test_unLockBadRef() throws Exception {
404         System.out.println("Testing unlock w/ bad lock ref");
405         createAndInsertIntoTable();
406         String lockRef = createLockReference();
407
408         Response response =
409                 lock.unLock("badref", "1", "1", authorization, "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
410         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
411         assertEquals(400, response.getStatus());
412     }
413     
414     @Test
415     public void test_getLockState() throws Exception {
416         System.out.println("Testing get lock state");
417         createAndInsertIntoTable();
418
419         String lockRef = createLockReference();
420
421         Response response = lock.currentLockState(lockName, "1", "1", authorization,
422                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
423         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
424         assertEquals(200, response.getStatus());
425         Map<String,Object> respMap = (Map<String, Object>) response.getEntity();
426         assertEquals(lockRef, ((Map<String,String>) respMap.get("lock")).get("lock-holder"));
427     }
428     
429     @Test
430     public void test_getLockStateBadRef() throws Exception {
431         System.out.println("Testing get lock state w/ bad ref");
432         createAndInsertIntoTable();
433
434         String lockRef = createLockReference();
435
436         Response response = lock.currentLockState("badname", "1", "1", authorization,
437                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName);
438         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
439         assertEquals(400, response.getStatus());
440     }
441
442     // Ignoring since this is now a duplicate of delete lock ref.
443     @Test
444     @Ignore
445     public void test_deleteLock() throws Exception {
446         System.out.println("Testing get lock state");
447         createAndInsertIntoTable();
448         
449         String lockRef = createLockReference();
450
451         Response response = lock.deleteLock(lockName, "1", "1",
452                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", authorization, appName);
453         System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
454         assertEquals(200, response.getStatus());
455     }
456     
457     /**
458     * Create table and lock reference
459      * 
460     * @return the lock ref created
461      * @throws Exception
462     */
463     @SuppressWarnings("unchecked")
464     private String createLockReference() throws Exception {
465         Response response = lock.createLockReference(lockName, "1", "1", authorization,
466                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", null, null, appName);
467         Map<String, Object> respMap = (Map<String, Object>) response.getEntity();
468         return ((Map<String, String>) respMap.get("lock")).get("lock");
469     }
470
471     /**
472      * Create table and lock reference
473      * 
474      * @return the lock ref created
475      * @throws Exception
476      */
477     @SuppressWarnings("unchecked")
478     private String createLockReference(LockType lockType) throws Exception {
479         JsonLock jsonLock = createJsonLock(lockType);
480         Response response = lock.createLockReference(lockName, "1", "1", authorization,
481                 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", jsonLock, null, appName);
482         Map<String, Object> respMap = (Map<String, Object>) response.getEntity();
483         return ((Map<String, String>) respMap.get("lock")).get("lock");
484     }
485
486     private static void createKeyspace() throws Exception {
487         // shouldn't really be doing this here, but create keyspace is currently turned off
488         PreparedQueryObject query = new PreparedQueryObject();
489         query.appendQueryString(CassandraCQL.createKeySpace);
490         MusicCore.eventualPut(query);
491         
492         boolean isAAF = false;
493         String hashedpwd = BCrypt.hashpw(password, BCrypt.gensalt());
494         query = new PreparedQueryObject();
495         query.appendQueryString("INSERT into admin.keyspace_master (uuid, keyspace_name, application_name, is_api, "
496                                     + "password, username, is_aaf) values (?,?,?,?,?,?,?)");
497         query.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), uuid));
498         query.addValue(MusicUtil.convertToActualDataType(DataType.text(), keyspaceName));
499         query.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
500         query.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), "True"));
501         query.addValue(MusicUtil.convertToActualDataType(DataType.text(), hashedpwd));
502         query.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
503         query.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), isAAF));
504         //CachingUtil.updateMusicCache(keyspaceName, appName);
505         //CachingUtil.updateMusicValidateCache(appName, userId, hashedpwd);
506         MusicCore.eventualPut(query);
507     }
508     
509     private void clearAllTablesFromKeyspace() throws MusicServiceException {
510         ArrayList<String> tableNames = new ArrayList<>();
511         PreparedQueryObject query = new PreparedQueryObject();
512         query.appendQueryString(
513                 "SELECT table_name FROM system_schema.tables WHERE keyspace_name = '" + keyspaceName + "';");
514         ResultSet rs = MusicCore.get(query);
515         for (Row row : rs) {
516             tableNames.add(row.getString("table_name"));
517         }
518         for (String table : tableNames) {
519             query = new PreparedQueryObject();
520             query.appendQueryString("DROP TABLE " + keyspaceName + "." + table);
521             MusicCore.eventualPut(query);
522         }
523     }
524     
525     /**
526      * Create a table {@link tableName} in {@link keyspaceName}
527      * 
528      * @throws Exception
529      */
530     private void createTable() throws Exception {
531         JsonTable jsonTable = new JsonTable();
532         Map<String, String> consistencyInfo = new HashMap<>();
533         Map<String, String> fields = new HashMap<>();
534         fields.put("uuid", "text");
535         fields.put("emp_name", "text");
536         fields.put("emp_salary", "varint");
537         fields.put("PRIMARY KEY", "(emp_name)");
538         consistencyInfo.put("type", "eventual");
539         jsonTable.setConsistencyInfo(consistencyInfo);
540         jsonTable.setKeyspaceName(keyspaceName);
541         jsonTable.setPrimaryKey("emp_name");
542         jsonTable.setTableName(tableName);
543         jsonTable.setFields(fields);
544         // Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
545         Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
546                 authorization, jsonTable, keyspaceName, tableName);
547     }
548     
549     /**
550      * Create table {@link createTable} and insert into said table
551      * 
552      * @throws Exception
553      */
554     private void createAndInsertIntoTable() throws Exception {
555         createTable();
556         
557         JsonInsert jsonInsert = new JsonInsert();
558         Map<String, String> consistencyInfo = new HashMap<>();
559         Map<String, Object> values = new HashMap<>();
560         values.put("uuid", "cfd66ccc-d857-4e90-b1e5-df98a3d40cd6");
561         values.put("emp_name", "testname");
562         values.put("emp_salary", 500);
563         consistencyInfo.put("type", "eventual");
564         jsonInsert.setConsistencyInfo(consistencyInfo);
565         jsonInsert.setKeyspaceName(keyspaceName);
566         jsonInsert.setTableName(tableName);
567         jsonInsert.setValues(values);
568         Response response = data.insertIntoTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
569                 authorization, jsonInsert, keyspaceName, tableName);
570     }
571
572     private JsonLock createJsonLock(LockType lockType) {
573         JsonLock jsonLock = new JsonLock();
574         jsonLock.setLockType(lockType);
575         return jsonLock;
576     }
577
578 }