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;
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;
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;
64 @RunWith(MockitoJUnitRunner.class)
65 public class TstRestMusicLockAPI {
71 RestMusicLocksAPI lock = new RestMusicLocksAPI();
72 RestMusicDataAPI data = new RestMusicDataAPI();
73 static PreparedQueryObject testObject;
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";
90 public static void init() throws Exception {
91 System.out.println("Testing RestMusicLock class");
94 } catch (Exception e) {
96 throw new Exception("Unable to initialize before TestRestMusicData test class. " + e.getMessage());
101 public void afterEachTest() throws MusicServiceException {
102 clearAllTablesFromKeyspace();
106 public static void tearDownAfterClass() throws Exception {
107 testObject = new PreparedQueryObject();
108 testObject.appendQueryString("DROP KEYSPACE IF EXISTS " + keyspaceName);
109 MusicCore.eventualPut(testObject);
112 @SuppressWarnings("unchecked")
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());
122 assertEquals(200, response.getStatus());
123 assertTrue(respMap.containsKey("lock"));
124 assertTrue(((Map<String, String>) respMap.get("lock")).containsKey("lock"));
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());
136 assertEquals(400, response.getStatus());
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());
149 assertEquals(200, response.getStatus());
150 assertTrue(respMap.containsKey("lock"));
151 assertTrue(((Map<String, String>) respMap.get("lock")).containsKey("lock"));
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());
164 assertEquals(200, response.getStatus());
165 assertTrue(respMap.containsKey("lock"));
166 assertTrue(((Map<String, String>) respMap.get("lock")).containsKey("lock"));
170 public void test_accquireLock() throws Exception {
171 System.out.println("Testing acquire lock");
172 createAndInsertIntoTable();
173 String lockRef = createLockReference();
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());
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);
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());
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());
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);
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());
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());
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);
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);
235 Response response = data.updateTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
236 authorization, jsonUpdate, keyspaceName, tableName, info);
238 assertEquals(400, response.getStatus());
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);
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);
261 Response response = data.updateTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
262 authorization, jsonUpdate, keyspaceName, tableName, info);
264 assertEquals(200, response.getStatus());
268 public void test_accquireLockWLease() throws Exception {
269 System.out.println("Testing acquire lock with lease");
270 createAndInsertIntoTable();
271 String lockRef = createLockReference();
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());
282 public void test_accquireBadLockWLease() throws Exception {
283 System.out.println("Testing acquire bad lock ref with lease");
284 createAndInsertIntoTable();
285 String lockRef = createLockReference();
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());
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();
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());
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();
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());
324 public void test_currentLockHolder() throws Exception {
325 System.out.println("Testing get current lock holder");
326 createAndInsertIntoTable();
328 String lockRef = createLockReference();
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"));
339 public void test_nocurrentLockHolder() throws Exception {
340 System.out.println("Testing get current lock holder w/ bad lockref");
341 createAndInsertIntoTable();
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());
350 public void test_badcurrentLockHolder() throws Exception {
351 System.out.println("Testing get current lock holder w/ bad lockref");
352 createAndInsertIntoTable();
354 String lockRef = createLockReference();
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());
363 public void test_holders() throws Exception {
364 System.out.println("Testing holders api");
365 createAndInsertIntoTable();
367 String lockRef = createLockReference();
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));
378 public void test_holdersbadRef() throws Exception {
379 System.out.println("Testing holders api w/ bad lockref");
380 createAndInsertIntoTable();
382 String lockRef = createLockReference();
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());
391 public void test_unLock() throws Exception {
392 System.out.println("Testing unlock");
393 createAndInsertIntoTable();
394 String lockRef = createLockReference();
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());
403 public void test_unLockBadRef() throws Exception {
404 System.out.println("Testing unlock w/ bad lock ref");
405 createAndInsertIntoTable();
406 String lockRef = createLockReference();
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());
415 public void test_getLockState() throws Exception {
416 System.out.println("Testing get lock state");
417 createAndInsertIntoTable();
419 String lockRef = createLockReference();
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"));
430 public void test_getLockStateBadRef() throws Exception {
431 System.out.println("Testing get lock state w/ bad ref");
432 createAndInsertIntoTable();
434 String lockRef = createLockReference();
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());
442 @SuppressWarnings("unchecked")
444 public void test_deadlock() throws Exception {
445 System.out.println("Testing deadlock");
446 createAndInsertIntoTable();
447 insertAnotherIntoTable();
449 // Process 1 creates and acquires a lock on row 1
450 JsonLock jsonLock = createJsonLock(LockType.WRITE);
451 Response responseCreate1 = lock.createLockReference(lockName, "1", "1", authorization,
452 "abcde001-d857-4e90-b1e5-df98a3d40ce6", jsonLock, "process1", appName);
453 Map<String, Object> respMapCreate1 = (Map<String, Object>) responseCreate1.getEntity();
454 String lockRefCreate1 = ((Map<String, String>) respMapCreate1.get("lock")).get("lock");
456 Response responseAcquire1 =
457 lock.accquireLock(lockRefCreate1, "1", "1", authorization, "abc66001-d857-4e90-b1e5-df98a3d40ce6", appName);
459 // Process 2 creates and acquires a lock on row 2
460 Response responseCreate2 = lock.createLockReference(lockName + "2", "1", "1", authorization,
461 "abcde002-d857-4e90-b1e5-df98a3d40ce6", jsonLock, "process2", appName);
462 Map<String, Object> respMapCreate2 = (Map<String, Object>) responseCreate2.getEntity();
463 String lockRefCreate2 = ((Map<String, String>) respMapCreate2.get("lock")).get("lock");
465 Response responseAcquire2 =
466 lock.accquireLock(lockRefCreate2, "1", "1", authorization, "abc66002-d857-4e90-b1e5-df98a3d40ce6", appName);
468 // Process 2 creates a lock on row 1
469 Response responseCreate3 = lock.createLockReference(lockName, "1", "1", authorization,
470 "abcde003-d857-4e90-b1e5-df98a3d40ce6", jsonLock, "process2", appName);
472 // Process 1 creates a lock on row 2, causing deadlock
473 Response responseCreate4 = lock.createLockReference(lockName + "2", "1", "1", authorization,
474 "abcde004-d857-4e90-b1e5-df98a3d40ce6", jsonLock, "process1", appName);
475 Map<String, Object> respMapCreate4 = (Map<String, Object>) responseCreate4.getEntity();
477 System.out.println("Status: " + responseCreate4.getStatus() + ". Entity " + responseCreate4.getEntity());
478 assertEquals(400, responseCreate4.getStatus());
479 assertTrue(respMapCreate4.containsKey("error"));
480 assertTrue( ((String)respMapCreate4.get("error")).toLowerCase().indexOf("deadlock") > -1 );
484 // Ignoring since this is now a duplicate of delete lock ref.
487 public void test_deleteLock() throws Exception {
488 System.out.println("Testing get lock state");
489 createAndInsertIntoTable();
491 String lockRef = createLockReference();
493 Response response = lock.deleteLock(lockName, "1", "1",
494 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", authorization, appName);
495 System.out.println("Status: " + response.getStatus() + ". Entity " + response.getEntity());
496 assertEquals(200, response.getStatus());
500 * Create table and lock reference
502 * @return the lock ref created
505 @SuppressWarnings("unchecked")
506 private String createLockReference() throws Exception {
507 Response response = lock.createLockReference(lockName, "1", "1", authorization,
508 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", null, null, appName);
509 Map<String, Object> respMap = (Map<String, Object>) response.getEntity();
510 return ((Map<String, String>) respMap.get("lock")).get("lock");
514 * Create table and lock reference
516 * @return the lock ref created
519 @SuppressWarnings("unchecked")
520 private String createLockReference(LockType lockType) throws Exception {
521 JsonLock jsonLock = createJsonLock(lockType);
522 Response response = lock.createLockReference(lockName, "1", "1", authorization,
523 "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", jsonLock, null, appName);
524 Map<String, Object> respMap = (Map<String, Object>) response.getEntity();
525 return ((Map<String, String>) respMap.get("lock")).get("lock");
528 private static void createKeyspace() throws Exception {
529 // shouldn't really be doing this here, but create keyspace is currently turned off
530 PreparedQueryObject query = new PreparedQueryObject();
531 query.appendQueryString(CassandraCQL.createKeySpace);
532 MusicCore.eventualPut(query);
534 boolean isAAF = false;
535 String hashedpwd = BCrypt.hashpw(password, BCrypt.gensalt());
536 query = new PreparedQueryObject();
537 query.appendQueryString("INSERT into admin.keyspace_master (uuid, keyspace_name, application_name, is_api, "
538 + "password, username, is_aaf) values (?,?,?,?,?,?,?)");
539 query.addValue(MusicUtil.convertToActualDataType(DataType.uuid(), uuid));
540 query.addValue(MusicUtil.convertToActualDataType(DataType.text(), keyspaceName));
541 query.addValue(MusicUtil.convertToActualDataType(DataType.text(), appName));
542 query.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), "True"));
543 query.addValue(MusicUtil.convertToActualDataType(DataType.text(), hashedpwd));
544 query.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
545 query.addValue(MusicUtil.convertToActualDataType(DataType.cboolean(), isAAF));
546 //CachingUtil.updateMusicCache(keyspaceName, appName);
547 //CachingUtil.updateMusicValidateCache(appName, userId, hashedpwd);
548 MusicCore.eventualPut(query);
551 private void clearAllTablesFromKeyspace() throws MusicServiceException {
552 ArrayList<String> tableNames = new ArrayList<>();
553 PreparedQueryObject query = new PreparedQueryObject();
554 query.appendQueryString(
555 "SELECT table_name FROM system_schema.tables WHERE keyspace_name = '" + keyspaceName + "';");
556 ResultSet rs = MusicCore.get(query);
558 tableNames.add(row.getString("table_name"));
560 for (String table : tableNames) {
561 query = new PreparedQueryObject();
562 query.appendQueryString("DROP TABLE " + keyspaceName + "." + table);
563 MusicCore.eventualPut(query);
568 * Create a table {@link tableName} in {@link keyspaceName}
572 private void createTable() throws Exception {
573 JsonTable jsonTable = new JsonTable();
574 Map<String, String> consistencyInfo = new HashMap<>();
575 Map<String, String> fields = new HashMap<>();
576 fields.put("uuid", "text");
577 fields.put("emp_name", "text");
578 fields.put("emp_salary", "varint");
579 fields.put("PRIMARY KEY", "(emp_name)");
580 consistencyInfo.put("type", "eventual");
581 jsonTable.setConsistencyInfo(consistencyInfo);
582 jsonTable.setKeyspaceName(keyspaceName);
583 jsonTable.setPrimaryKey("emp_name");
584 jsonTable.setTableName(tableName);
585 jsonTable.setFields(fields);
586 // Mockito.doNothing().when(http).addHeader(xLatestVersion, MusicUtil.getVersion());
587 Response response = data.createTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
588 authorization, jsonTable, keyspaceName, tableName);
592 * Create table {@link createTable} and insert into said table
596 private void createAndInsertIntoTable() throws Exception {
599 JsonInsert jsonInsert = new JsonInsert();
600 Map<String, String> consistencyInfo = new HashMap<>();
601 Map<String, Object> values = new HashMap<>();
602 values.put("uuid", "cfd66ccc-d857-4e90-b1e5-df98a3d40cd6");
603 values.put("emp_name", "testname");
604 values.put("emp_salary", 500);
605 consistencyInfo.put("type", "eventual");
606 jsonInsert.setConsistencyInfo(consistencyInfo);
607 jsonInsert.setKeyspaceName(keyspaceName);
608 jsonInsert.setTableName(tableName);
609 jsonInsert.setValues(values);
610 Response response = data.insertIntoTable("1", "1", "1", "abc66ccc-d857-4e90-b1e5-df98a3d40ce6", appName,
611 authorization, jsonInsert, keyspaceName, tableName);
614 private void insertAnotherIntoTable() throws Exception {
617 JsonInsert jsonInsert = new JsonInsert();
618 Map<String, String> consistencyInfo = new HashMap<>();
619 Map<String, Object> values = new HashMap<>();
620 values.put("uuid", "cccccccc-d857-4e90-b1e5-df98a3d40cd6");
621 values.put("emp_name", "testname2");
622 values.put("emp_salary", 700);
623 consistencyInfo.put("type", "eventual");
624 jsonInsert.setConsistencyInfo(consistencyInfo);
625 jsonInsert.setKeyspaceName(keyspaceName);
626 jsonInsert.setTableName(tableName);
627 jsonInsert.setValues(values);
628 Response response = data.insertIntoTable("1", "1", "1", "abcdef00-d857-4e90-b1e5-df98a3d40ce6", appName,
629 authorization, jsonInsert, keyspaceName, tableName);
632 private JsonLock createJsonLock(LockType lockType) {
633 JsonLock jsonLock = new JsonLock();
634 jsonLock.setLockType(lockType);