2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
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.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.batch.helpers;
24 import static org.junit.Assert.assertNull;
25 import static org.mockito.MockitoAnnotations.initMocks;
27 import java.io.IOException;
28 import java.lang.reflect.Field;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.mockito.Mock;
33 import org.mockito.Mockito;
34 import org.onap.aaf.auth.env.AuthzTrans;
35 import org.onap.aaf.misc.env.APIException;
36 import org.onap.aaf.misc.env.LogTarget;
37 import org.onap.aaf.misc.env.TimeTaken;
39 import com.datastax.driver.core.ResultSet;
40 import com.datastax.driver.core.Session;
42 public class JU_CQLBatchTest {
56 public void setUp() throws APIException, IOException {
58 Mockito.doReturn(lg).when(trans).info();
59 cqlBatchObj = new CQLBatch(lg, session);
60 Mockito.doReturn(Mockito.mock(TimeTaken.class)).when(trans).start(
61 Mockito.anyString(), Mockito.anyInt(), Mockito.anyString());
63 Mockito.doReturn(Mockito.mock(ResultSet.class)).when(session)
64 .execute(Mockito.anyString());
68 public void testExecute() {
69 ResultSet retVal = cqlBatchObj.execute();
74 f = CQLBatch.class.getDeclaredField("sb");
75 f.setAccessible(true);
76 f.set(cqlBatchObj, new StringBuilder("test"));
77 retVal = cqlBatchObj.execute();
78 } catch (NoSuchFieldException | SecurityException
79 | IllegalArgumentException | IllegalAccessException e) {
80 // TODO Auto-generated catch block
87 public void testExecute2() {
88 ResultSet retVal = cqlBatchObj.execute(false);
93 f = CQLBatch.class.getDeclaredField("sb");
94 f.setAccessible(true);
95 f.set(cqlBatchObj, new StringBuilder("test"));
96 retVal = cqlBatchObj.execute(true);
97 cqlBatchObj.toString();
98 } catch (NoSuchFieldException | SecurityException
99 | IllegalArgumentException | IllegalAccessException e) {
100 // TODO Auto-generated catch block
107 public void testSingleExec() {
108 ResultSet retVal = cqlBatchObj.singleExec(new StringBuilder("test"),
112 retVal = cqlBatchObj.singleExec(new StringBuilder("test"), false);
116 public void testTouch() {
117 cqlBatchObj.touch("test", 0, 4, true);