Sonar Fixes to increate Coverage on Unit tests
[music.git] / src / test / java / org / onap / music / unittests / TestMusicCore.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 //package org.onap.music.unittests;
23 //
24 //import static org.junit.Assert.*;
25 //import static org.onap.music.main.MusicCore.mDstoreHandle;
26 //import static org.onap.music.main.MusicCore.mLockHandle;
27 //import org.junit.Before;
28 //import org.junit.Test;
29 //import org.junit.runner.RunWith;
30 //import org.mockito.Mock;
31 //import org.mockito.Mockito;
32 //import org.mockito.runners.MockitoJUnitRunner;
33 //import org.onap.music.exceptions.MusicLockingException;
34 //import org.onap.music.exceptions.MusicQueryException;
35 //import org.onap.music.exceptions.MusicServiceException;
36 //import org.onap.music.lockingservice.MusicLockState;
37 //import org.onap.music.lockingservice.MusicLockingService;
38 //import org.onap.music.lockingservice.MusicLockState.LockStatus;
39 //import org.onap.music.main.MusicCore;
40 //import org.onap.music.main.ResultType;
41 //import org.onap.music.main.ReturnType;
42 //import org.onap.music.main.MusicCore.Condition;
43 //import org.onap.music.datastore.MusicDataStore;
44 //import org.onap.music.datastore.PreparedQueryObject;
45 //import com.datastax.driver.core.ResultSet;
46 //
47 //@RunWith(MockitoJUnitRunner.class)
48 //public class TestMusicCore {
49 //
50 //    @Mock
51 //    private Condition condition;
52 //
53 //    @Mock
54 //    private ResultSet rs;
55 //
56 //    @Mock
57 //    private PreparedQueryObject preparedQueryObject;
58 //
59 //    @Before
60 //    public void setUp() {
61 //        mLockHandle = Mockito.mock(MusicLockingService.class);
62 //
63 //    }
64 //
65 //    @Test
66 //    public void testCreateLockReferenceforvalidlock() {
67 //        Mockito.when(mLockHandle.createLockId("/" + "test")).thenReturn("lock");
68 //        String lockId = MusicCore.createLockReference("test");
69 //        assertEquals("lock", lockId);
70 //        Mockito.verify(mLockHandle).createLockId("/" + "test");
71 //    }
72 //
73 //    @Test
74 //    public void testIsTableOrKeySpaceLock() {
75 //        Boolean result = MusicCore.isTableOrKeySpaceLock("ks1.tn1");
76 //        assertTrue(result);
77 //    }
78 //
79 //    @Test
80 //    public void testIsTableOrKeySpaceLockwithPrimarykey() {
81 //        Boolean result = MusicCore.isTableOrKeySpaceLock("ks1.tn1.pk1");
82 //        assertFalse(result);
83 //    }
84 //
85 //    @Test
86 //    public void testGetMusicLockState() throws MusicLockingException {
87 //        MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
88 //        Mockito.when(mLockHandle.getLockState("ks1.tb1.pk1")).thenReturn(musicLockState);
89 //        MusicLockState mls = MusicCore.getMusicLockState("ks1.tb1.pk1");
90 //        assertEquals(musicLockState, mls);
91 //        Mockito.verify(mLockHandle).getLockState("ks1.tb1.pk1");
92 //    }
93 //
94 //    @Test
95 //    public void testAcquireLockifisMyTurnTrue() {
96 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
97 //        ReturnType lock = MusicCore.acquireLock("ks1.tn1", "id1");
98 //        assertEquals(lock.getResult(), ResultType.SUCCESS);
99 //        Mockito.verify(mLockHandle).isMyTurn("id1");
100 //    }
101 //
102 //    @Test
103 //    public void testAcquireLockifisMyTurnFalse() {
104 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(false);
105 //        ReturnType lock = MusicCore.acquireLock("ks1.ts1", "id1");
106 //        assertEquals(lock.getResult(), ResultType.FAILURE);
107 //        Mockito.verify(mLockHandle).isMyTurn("id1");
108 //    }
109 //
110 //    @Test
111 //    public void testAcquireLockifisMyTurnTrueandIsTableOrKeySpaceLockTrue() {
112 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
113 //        ReturnType lock = MusicCore.acquireLock("ks1.tn1", "id1");
114 //        assertEquals(lock.getResult(), ResultType.SUCCESS);
115 //        Mockito.verify(mLockHandle).isMyTurn("id1");
116 //    }
117 //
118 //    @Test
119 //    public void testAcquireLockifisMyTurnTrueandIsTableOrKeySpaceLockFalseandHaveLock() throws MusicLockingException {
120 //        MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
121 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
122 //        Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
123 //        ReturnType lock = MusicCore.acquireLock("ks1.tn1.pk1", "id1");
124 //        assertEquals(lock.getResult(), ResultType.SUCCESS);
125 //        Mockito.verify(mLockHandle).isMyTurn("id1");
126 //        Mockito.verify(mLockHandle).getLockState("ks1.tn1.pk1");
127 //    }
128 //
129 //    @Test
130 //    public void testAcquireLockifisMyTurnTrueandIsTableOrKeySpaceLockFalseandDontHaveLock() throws MusicLockingException {
131 //        MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id2");
132 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
133 //        Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
134 //        ReturnType lock = MusicCore.acquireLock("ks1.tn1.pk1", "id1");
135 //        assertEquals(lock.getResult(), ResultType.SUCCESS);
136 //        Mockito.verify(mLockHandle).isMyTurn("id1");
137 //        Mockito.verify(mLockHandle).getLockState("ks1.tn1.pk1");
138 //    }
139 //    
140 //    @Test
141 //    public void testAcquireLockifLockRefDoesntExist() {
142 //        Mockito.when(mLockHandle.lockIdExists("bs1")).thenReturn(false);
143 //        ReturnType lock = MusicCore.acquireLock("ks1.ts1", "bs1");
144 //        assertEquals(lock.getResult(), ResultType.FAILURE);
145 //        assertEquals(lock.getMessage(), "Lockid doesn't exist");
146 //        Mockito.verify(mLockHandle).lockIdExists("bs1");
147 //    }
148 //    
149 //    @Test
150 //    public void testAcquireLockWithLeasewithLease() throws MusicLockingException {
151 //        MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
152 //        musicLockState.setLeasePeriod(0);
153 //        ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
154 //        Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
155 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
156 //        ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
157 //        assertEquals(expectedResult.getResult(), actualResult.getResult());
158 //        Mockito.verify(mLockHandle).isMyTurn("id1");
159 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
160 //    }
161 //    
162 //    @Test
163 //    public void testAcquireLockWithLeasewithException() throws MusicLockingException {
164 //        ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "failure");
165 //        Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenThrow(new MusicLockingException());
166 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
167 //        ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
168 //        assertEquals(expectedResult.getResult(), actualResult.getResult());
169 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
170 //    }
171 //
172 //    @Test
173 //    public void testAcquireLockWithLeasewithLockStatusLOCKED() throws MusicLockingException {
174 //        MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
175 //        ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
176 //        Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
177 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
178 //        ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
179 //        assertEquals(expectedResult.getResult(), actualResult.getResult());
180 //        Mockito.verify(mLockHandle).isMyTurn("id1");
181 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
182 //    }
183 //
184 //    @Test
185 //    public void testAcquireLockWithLeasewithLockStatusUNLOCKED() throws MusicLockingException {
186 //        MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
187 //        ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
188 //        Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
189 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
190 //        ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
191 //        assertEquals(expectedResult.getResult(), actualResult.getResult());
192 //        Mockito.verify(mLockHandle).isMyTurn("id1");
193 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
194 //
195 //    }
196 //
197 //    @Test
198 //    public void testAcquireLockWithLeaseIfNotMyTurn() throws MusicLockingException {
199 //        MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
200 //        ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
201 //        Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
202 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(false);
203 //        ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
204 //        assertEquals(expectedResult.getResult(), actualResult.getResult());
205 //        Mockito.verify(mLockHandle).isMyTurn("id1");
206 //        Mockito.verify(mLockHandle).getLockState("ks1.tn1.pk1");
207 //    }
208 //
209 //    @Test
210 //    public void testQuorumGet() throws MusicServiceException, MusicQueryException {
211 //      preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
212 //      mDstoreHandle = Mockito.mock(MusicDataStore.class);
213 //      rs = Mockito.mock(ResultSet.class);
214 //      Mockito.when(mDstoreHandle.executeCriticalGet(preparedQueryObject)).thenReturn(rs);
215 //      ResultSet rs1 = MusicCore.quorumGet(preparedQueryObject);
216 //      assertNotNull(rs1);
217 //    }
218 //
219 //    @Test
220 //    public void testGetLockNameFromId() {
221 //        String lockname = MusicCore.getLockNameFromId("lockName$id");
222 //        assertEquals("lockName", lockname);
223 //    }
224 //
225 //    @Test
226 //    public void testDestroyLockRef() {
227 //        Mockito.doNothing().when(mLockHandle).unlockAndDeleteId("id1");
228 //        MusicCore.destroyLockRef("id1");
229 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce()).unlockAndDeleteId("id1");
230 //    }
231 //
232 //    @Test
233 //    public void testreleaseLockwithvoluntaryReleaseTrue() {
234 //        MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id2");
235 //        Mockito.doNothing().when(mLockHandle).unlockAndDeleteId("id1");
236 //        MusicLockState musicLockState1 = MusicCore.releaseLock("id1", true);
237 //        assertEquals(musicLockState.getLockStatus(), musicLockState1.getLockStatus());
238 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce()).unlockAndDeleteId("id1");
239 //    }
240 //
241 //    @Test
242 //    public void testreleaseLockwithvoluntaryReleaseFalse() {
243 //        MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id2");
244 //        Mockito.doNothing().when(mLockHandle).unlockAndDeleteId("id1");
245 //        MusicLockState musicLockState1 = MusicCore.releaseLock("id1", false);
246 //        assertEquals(musicLockState.getLockStatus(), musicLockState1.getLockStatus());
247 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce()).unlockAndDeleteId("id1");
248 //    }
249 //
250 //    @Test
251 //    public void testDeleteLock() {
252 //        Mockito.doNothing().when(mLockHandle).deleteLock("/" + "id1");
253 //        MusicCore.deleteLock("id1");
254 //        Mockito.verify(mLockHandle).deleteLock("/" + "id1");
255 //    }
256 //
257 //    /*
258 //     * @Test public void testNonKeyRelatedPut() throws Exception { mDstoreHandle =
259 //     * Mockito.mock(MusicDataStore.class); Mockito.when(mDstoreHandle.executePut("qu1",
260 //     * "consistency")).thenReturn(true); Boolean result = MusicCore.nonKeyRelatedPut("qu1",
261 //     * "consistency"); assertTrue(result); Mockito.verify(mDstoreHandle).executePut("qu1",
262 //     * "consistency"); }
263 //     */
264 //
265 //    @Test
266 //    public void testEventualPutPreparedQuery() throws MusicServiceException, MusicQueryException {
267 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
268 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
269 //        ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
270 //        Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "eventual")).thenReturn(true);
271 //        ReturnType actualResult = MusicCore.eventualPut(preparedQueryObject);
272 //        assertEquals(expectedResult.getResult(), actualResult.getResult());
273 //        Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "eventual");
274 //    }
275 //
276 //    @Test
277 //    public void testEventualPutPreparedQuerywithResultFalse()
278 //                    throws MusicServiceException, MusicQueryException {
279 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
280 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
281 //        ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
282 //        Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "eventual")).thenReturn(false);
283 //        ReturnType actualResult = MusicCore.eventualPut(preparedQueryObject);
284 //        assertEquals(expectedResult.getResult(), actualResult.getResult());
285 //        Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "eventual");
286 //    }
287 //
288 //    @Test
289 //    public void testCriticalPutPreparedQuerywithValidLockId()
290 //                    throws Exception {
291 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
292 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
293 //        MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
294 //        Mockito.when(condition.testCondition()).thenReturn(true);
295 //        ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
296 //        Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
297 //                        .thenReturn(musicLockState);
298 //        Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "critical")).thenReturn(true);
299 //        ReturnType returnType = MusicCore.criticalPut("ks1", "tn1", "pk1", preparedQueryObject,
300 //                        "id1", condition);
301 //        assertEquals(expectedResult.getResult(), returnType.getResult());
302 //        Mockito.verify(condition).testCondition();
303 //        Mockito.verify(mLockHandle).getLockState("ks1" + "." + "tn1" + "." + "pk1");
304 //        Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "critical");
305 //    }
306 //
307 //    @Test
308 //    public void testCriticalPutPreparedQuerywithInvalidLockId() throws MusicLockingException {
309 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
310 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
311 //        MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id2");
312 //        ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
313 //        Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
314 //                        .thenReturn(musicLockState);
315 //        ReturnType returnType = MusicCore.criticalPut("ks1", "tn1", "pk1", preparedQueryObject,
316 //                        "id1", condition);
317 //        assertEquals(expectedResult.getResult(), returnType.getResult());
318 //        Mockito.verify(mLockHandle).getLockState("ks1" + "." + "tn1" + "." + "pk1");
319 //    }
320 //
321 //    @Test
322 //    public void testCriticalPutPreparedQuerywithvalidLockIdandTestConditionFalse() throws Exception {
323 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
324 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
325 //        MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
326 //        Mockito.when(condition.testCondition()).thenReturn(false);
327 //        ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
328 //        Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
329 //                        .thenReturn(musicLockState);
330 //        ReturnType returnType = MusicCore.criticalPut("ks1", "tn1", "pk1", preparedQueryObject,
331 //                        "id1", condition);
332 //        assertEquals(expectedResult.getResult(), returnType.getResult());
333 //        Mockito.verify(condition).testCondition();
334 //        Mockito.verify(mLockHandle).getLockState("ks1" + "." + "tn1" + "." + "pk1");
335 //    }
336 //
337 //    @Test
338 //    public void testNonKeyRelatedPutPreparedQuery() throws Exception {
339 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
340 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
341 //        Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "consistency")).thenReturn(true);
342 //        Boolean result = MusicCore.nonKeyRelatedPut(preparedQueryObject, "consistency");
343 //        assertTrue(result);
344 //        Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "consistency");
345 //    }
346 //
347 //    @Test
348 //    public void testAtomicPutPreparedQuery() throws Exception {
349 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
350 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
351 //        Mockito.when(mLockHandle.createLockId("/" + "ks1.tn1.pk1")).thenReturn("id1");
352 //        MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
353 //        ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
354 //        Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
355 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
356 //        Mockito.when(condition.testCondition()).thenReturn(true);
357 //        Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
358 //                        .thenReturn(musicLockState);
359 //        Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "critical")).thenReturn(true);
360 //        ReturnType returnType =
361 //                        MusicCore.atomicPut("ks1", "tn1", "pk1", preparedQueryObject, condition);
362 //        assertEquals(expectedResult.getResult(), returnType.getResult());
363 //        Mockito.verify(mLockHandle).createLockId("/" + "ks1.tn1.pk1");
364 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
365 //        Mockito.verify(mLockHandle).isMyTurn("id1");
366 //        Mockito.verify(condition).testCondition();
367 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce())
368 //                        .getLockState("ks1" + "." + "tn1" + "." + "pk1");
369 //        Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "critical");
370 //    }
371 //
372 //    @Test
373 //    public void testAtomicPutPreparedQuerywithAcquireLockWithLeaseFalse() throws MusicLockingException {
374 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
375 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
376 //        Mockito.when(mLockHandle.createLockId("/" + "ks1.tn1.pk1")).thenReturn("id1");
377 //        ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
378 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(false);
379 //        ReturnType returnType =
380 //                        MusicCore.atomicPut("ks1", "tn1", "pk1", preparedQueryObject, condition);
381 //        assertEquals(expectedResult.getResult(), returnType.getResult());
382 //        Mockito.verify(mLockHandle).isMyTurn("id1");
383 //        Mockito.verify(mLockHandle).createLockId("/" + "ks1.tn1.pk1");
384 //    }
385 //
386 //    @Test
387 //    public void testAtomicGetPreparedQuery() throws MusicServiceException, MusicQueryException, MusicLockingException {
388 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
389 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
390 //        rs = Mockito.mock(ResultSet.class);
391 //        Mockito.when(mLockHandle.createLockId("/" + "ks1.tn1.pk1")).thenReturn("id1");
392 //        MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
393 //        Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
394 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
395 //        Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
396 //                        .thenReturn(musicLockState);
397 //        Mockito.when(mDstoreHandle.executeCriticalGet(preparedQueryObject)).thenReturn(rs);
398 //        ResultSet rs1 = MusicCore.atomicGet("ks1", "tn1", "pk1", preparedQueryObject);
399 //        assertNotNull(rs1);
400 //        Mockito.verify(mLockHandle).createLockId("/" + "ks1.tn1.pk1");
401 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
402 //        Mockito.verify(mLockHandle).isMyTurn("id1");
403 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce())
404 //                        .getLockState("ks1" + "." + "tn1" + "." + "pk1");
405 //        Mockito.verify(mDstoreHandle).executeCriticalGet(preparedQueryObject);
406 //    }
407 //
408 //    @Test
409 //    public void testAtomicGetPreparedQuerywithAcquireLockWithLeaseFalse()
410 //                    throws MusicServiceException, MusicLockingException {
411 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
412 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
413 //        rs = Mockito.mock(ResultSet.class);
414 //        Mockito.when(mLockHandle.createLockId("/" + "ks1.tn1.pk1")).thenReturn("id1");
415 //        Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(false);
416 //        ResultSet rs1 = MusicCore.atomicGet("ks1", "tn1", "pk1", preparedQueryObject);
417 //        assertNull(rs1);
418 //        Mockito.verify(mLockHandle).createLockId("/" + "ks1.tn1.pk1");
419 //        Mockito.verify(mLockHandle).isMyTurn("id1");
420 //    }
421 //
422 //    @Test
423 //    public void testGetPreparedQuery() throws MusicServiceException, MusicQueryException {
424 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
425 //        rs = Mockito.mock(ResultSet.class);
426 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
427 //        Mockito.when(mDstoreHandle.executeEventualGet(preparedQueryObject)).thenReturn(rs);
428 //        ResultSet rs1 = MusicCore.get(preparedQueryObject);
429 //        assertNotNull(rs1);
430 //        Mockito.verify(mDstoreHandle).executeEventualGet(preparedQueryObject);
431 //
432 //    }
433 //
434 //    @Test
435 //    public void testcriticalGetPreparedQuery() throws MusicServiceException, MusicQueryException, MusicLockingException {
436 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
437 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
438 //        MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
439 //        rs = Mockito.mock(ResultSet.class);
440 //        Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
441 //                        .thenReturn(musicLockState);
442 //        Mockito.when(mDstoreHandle.executeCriticalGet(preparedQueryObject)).thenReturn(rs);
443 //        ResultSet rs1 = MusicCore.criticalGet("ks1", "tn1", "pk1", preparedQueryObject, "id1");
444 //        assertNotNull(rs1);
445 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce())
446 //                        .getLockState("ks1" + "." + "tn1" + "." + "pk1");
447 //        Mockito.verify(mDstoreHandle).executeCriticalGet(preparedQueryObject);
448 //    }
449 //
450 //    @Test
451 //    public void testcriticalGetPreparedQuerywithInvalidLockId() throws MusicServiceException, MusicLockingException {
452 //        mDstoreHandle = Mockito.mock(MusicDataStore.class);
453 //        preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
454 //        MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id2");
455 //        Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
456 //                        .thenReturn(musicLockState);
457 //        ResultSet rs1 = MusicCore.criticalGet("ks1", "tn1", "pk1", preparedQueryObject, "id1");
458 //        assertNull(rs1);
459 //        Mockito.verify(mLockHandle, Mockito.atLeastOnce())
460 //                        .getLockState("ks1" + "." + "tn1" + "." + "pk1");
461 //    }
462 //
463 //}