X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-cass%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fdao%2Fcass%2FJU_CacheInfoDAO.java;h=695de1f02464775c73a97c4b82fd406061d60118;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=aa6d9f31e6bd0dfbb8da7955c2dc77ac8d97616d;hpb=15466c492522a6593605fb599da5619bae53dfb4;p=aaf%2Fauthz.git diff --git a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CacheInfoDAO.java b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CacheInfoDAO.java index aa6d9f31..695de1f0 100644 --- a/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CacheInfoDAO.java +++ b/auth/auth-cass/src/test/java/org/onap/aaf/auth/dao/cass/JU_CacheInfoDAO.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,7 +32,6 @@ import java.lang.reflect.Method; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; -import java.util.Date; import java.util.List; import org.junit.Before; @@ -66,574 +65,574 @@ import com.datastax.driver.core.Session; import com.datastax.driver.core.Statement; import com.datastax.driver.core.exceptions.DriverException; -import io.netty.util.concurrent.Future; - public class JU_CacheInfoDAO { - @Mock + @Mock AuthzTrans trans; - @Mock - Cluster cluster; - @Mock - Session session; - @Mock - AuthzEnv env; - @Mock - LogTarget logTarget; - - @Before - public void setUp() throws APIException, IOException { - initMocks(this); - Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).warn(); - Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error(); - Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug(); - Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).info(); - Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).init(); - Mockito.doReturn("100").when(trans).getProperty(Config.CADI_LATITUDE); - Mockito.doReturn("100").when(trans).getProperty(Config.CADI_LONGITUDE); - Mockito.doReturn(session).when(cluster).connect("test"); - } - - @Test - public void testInit() { - TimeTaken tt = Mockito.mock(TimeTaken.class); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); - Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); - Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); - Mockito.doNothing().when(tt).done(); - CacheInfoDAO.Data data = new CacheInfoDAO.Data(); - PSInfo createPS = Mockito.mock(PSInfo.class); - Result rs = new Result(null,0,"test",new String[0]); - Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data); - - CacheInfoDAOImpl daoObj=null; - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } -// data.id - Result retVal = daoObj.create(trans, data); - assertTrue(retVal.status == 0); - } - - @Test - public void testTouch() { - TimeTaken tt = Mockito.mock(TimeTaken.class); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO Touch segments test: 1", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO Touch segments test: 1,2", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); - Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); - Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); - Mockito.doNothing().when(tt).done(); - - Mockito.doReturn(logTarget).when(env).debug(); - - CacheInfoDAO.Data data = new CacheInfoDAO.Data(); - PSInfo createPS = Mockito.mock(PSInfo.class); - Result rs = new Result(null,0,"test",new String[0]); - Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data); - - CacheInfoDAOImpl daoObj=null; - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } -// data.id - Result retVal = daoObj.touch(trans, "test", 1, 2); - assertTrue(retVal.status == 0); - Mockito.doThrow(DriverException.class).when(session).executeAsync(Mockito.anyString()); - daoObj.startUpdate(env, Mockito.mock(HMangr.class), Mockito.mock(SecuritySetter.class), "12.0.0.1", 8080); - retVal = daoObj.touch(trans, "test", 1, 2); - - - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - assertTrue(retVal.status == Result.ERR_Backend); - Mockito.doThrow(APIException.class).when(session).executeAsync(Mockito.anyString()); - retVal = daoObj.touch(trans, "test", 1, 2); - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - assertTrue(retVal.status == Result.ERR_Backend); - Mockito.doThrow(IOException.class).when(session).executeAsync(Mockito.anyString()); - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - retVal = daoObj.touch(trans, "test", 1, 2); - assertTrue(retVal.status == Result.ERR_Backend); - } - - @Test - public void testCheck() { - TimeTaken tt = Mockito.mock(TimeTaken.class); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("Check Table Timestamps", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); - Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); - Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); - Mockito.doNothing().when(tt).done(); - CacheInfoDAO.Data data = new CacheInfoDAO.Data(); - PSInfo createPS = Mockito.mock(PSInfo.class); - Result rs = new Result(null,0,"test",new String[0]); - Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data); - - CacheInfoDAOImpl daoObj=null; - PreparedStatement ps = Mockito.mock(PreparedStatement.class); - Mockito.doReturn(ps).when(session).prepare(Mockito.anyString()); - Mockito.doReturn(Mockito.mock(ColumnDefinitions.class)).when(ps).getVariables(); - Mockito.doReturn(Mockito.mock(PreparedId.class)).when(ps).getPreparedId(); - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } -// data.id - ResultSet resultSet = Mockito.mock(ResultSet.class); - List rowList = new ArrayList<>(); - Mockito.doReturn(rowList).when(resultSet).all(); - Mockito.doReturn(resultSet).when(session).execute(Mockito.any(Statement.class)); - Result retVal = daoObj.check(trans); - assertTrue(retVal.status == 0); - - Row row = Mockito.mock(Row.class); - Mockito.doReturn("test").when(row).getString(Mockito.anyInt()); - rowList.add(row); - row = Mockito.mock(Row.class); - Mockito.doReturn("test").when(row).getString(Mockito.anyInt()); - Mockito.doReturn(100).when(row).getInt(Mockito.anyInt()); - rowList.add(row); - retVal = daoObj.check(trans); - assertTrue(retVal.status == 0); - - Mockito.doThrow(DriverException.class).when(session).execute(Mockito.any(Statement.class)); - retVal = daoObj.check(trans); - assertTrue(retVal.status == Result.ERR_Backend); - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - Mockito.doThrow(APIException.class).when(session).execute(Mockito.any(Statement.class)); - retVal = daoObj.check(trans); - assertTrue(retVal.status == Result.ERR_Backend); - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - Mockito.doThrow(IOException.class).when(session).execute(Mockito.any(Statement.class)); - retVal = daoObj.check(trans); - assertTrue(retVal.status == Result.ERR_Backend); - } - @Test - public void testStopUpdate() { - - CacheInfoDAO.stopUpdate(); - - } - - - @Test - public void testGet() { - TimeTaken tt = Mockito.mock(TimeTaken.class); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO Touch segments test1: 1011", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); - Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); - Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); - Mockito.doNothing().when(tt).done(); - CacheInfoDAO.Data data = new CacheInfoDAO.Data(); - PSInfo createPS = Mockito.mock(PSInfo.class); - Result rs = new Result(null,0,"test",new String[0]); - Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data); - - CacheInfoDAOImpl daoObj=null; - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); - Date retVal = daoObj.get(trans, "test", 1011); -// assertTrue(retVal.status == 0); - retVal = daoObj.get(trans, "test1", 1011); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testWasMOdified() { - TimeTaken tt = Mockito.mock(TimeTaken.class); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); - Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); - Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); - Mockito.doReturn(tt).when(trans).start("DELETE APPROVAL",Env.REMOTE); - Mockito.doNothing().when(tt).done(); - CacheInfoDAO.Data data = new CacheInfoDAO.Data("test",1); - PSInfo createPS = Mockito.mock(PSInfo.class); - - HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class); - Result rs1 = new Result(null,0,"test",new String[0]); - Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any()); - - CacheInfoDAOImpl daoObj=null; - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test", createPS); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"}); - - - } - - @Test - public void testInfoLoader(){ - TimeTaken tt = Mockito.mock(TimeTaken.class); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO Touch segments test1: 1011", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); - Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); - Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); - Mockito.doNothing().when(tt).done(); - CacheInfoDAO.Data data1 = new CacheInfoDAO.Data(); - PSInfo createPS = Mockito.mock(PSInfo.class); - Result rs = new Result(null,0,"test",new String[0]); - Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data1); - - CacheInfoDAOImpl daoObj=null; - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test", createPS); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - Class[] classList = CacheInfoDAO.class.getDeclaredClasses(); - Class innerClass = null; - for(Class indCls:classList) { - if(indCls.getName().contains("InfoLoader")) { - innerClass = indCls; - } - } + @Mock + Cluster cluster; + @Mock + Session session; + @Mock + AuthzEnv env; + @Mock + LogTarget logTarget; + + @Before + public void setUp() throws APIException, IOException { + initMocks(this); + Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).warn(); + Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).error(); + Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).debug(); + Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).info(); + Mockito.doReturn(Mockito.mock(LogTarget.class)).when(trans).init(); + Mockito.doReturn("100").when(trans).getProperty(Config.CADI_LATITUDE); + Mockito.doReturn("100").when(trans).getProperty(Config.CADI_LONGITUDE); + Mockito.doReturn(session).when(cluster).connect("test"); + } + + @Test + public void testInit() { + TimeTaken tt = Mockito.mock(TimeTaken.class); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); + Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); + Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); + Mockito.doNothing().when(tt).done(); + CacheInfoDAO.Data data = new CacheInfoDAO.Data(); + PSInfo createPS = Mockito.mock(PSInfo.class); + Result rs = new Result(null,0,"test",new String[0]); + Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data); + + CacheInfoDAOImpl daoObj=null; + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// data.id + Result retVal = daoObj.create(trans, data); + assertTrue(retVal.status == 0); + } + + @Test + public void testTouch() { + TimeTaken tt = Mockito.mock(TimeTaken.class); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO Touch segments test: 1", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO Touch segments test: 1,2", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); + Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); + Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); + Mockito.doNothing().when(tt).done(); + + Mockito.doReturn(logTarget).when(env).debug(); + + CacheInfoDAO.Data data = new CacheInfoDAO.Data(); + PSInfo createPS = Mockito.mock(PSInfo.class); + Result rs = new Result(null,0,"test",new String[0]); + Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data); + + CacheInfoDAOImpl daoObj=null; + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// data.id + Result retVal = daoObj.touch(trans, "test", 1, 2); + assertTrue(retVal.status == 0); + Mockito.doThrow(DriverException.class).when(session).executeAsync(Mockito.anyString()); + daoObj.startUpdate(env, Mockito.mock(HMangr.class), Mockito.mock(SecuritySetter.class), "12.0.0.1", 8080); + retVal = daoObj.touch(trans, "test", 1, 2); + + + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(retVal.status == Result.ERR_Backend); + Mockito.doThrow(APIException.class).when(session).executeAsync(Mockito.anyString()); + retVal = daoObj.touch(trans, "test", 1, 2); + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + assertTrue(retVal.status == Result.ERR_Backend); + Mockito.doThrow(IOException.class).when(session).executeAsync(Mockito.anyString()); + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + retVal = daoObj.touch(trans, "test", 1, 2); + assertTrue(retVal.status == Result.ERR_Backend); + } + + @Test + public void testCheck() { + TimeTaken tt = Mockito.mock(TimeTaken.class); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("Check Table Timestamps", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); + Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); + Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); + Mockito.doNothing().when(tt).done(); + CacheInfoDAO.Data data = new CacheInfoDAO.Data(); + PSInfo createPS = Mockito.mock(PSInfo.class); + Result rs = new Result(null,0,"test",new String[0]); + Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data); + + CacheInfoDAOImpl daoObj=null; + PreparedStatement ps = Mockito.mock(PreparedStatement.class); + Mockito.doReturn(ps).when(session).prepare(Mockito.anyString()); + Mockito.doReturn(Mockito.mock(ColumnDefinitions.class)).when(ps).getVariables(); + Mockito.doReturn(Mockito.mock(PreparedId.class)).when(ps).getPreparedId(); + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// data.id + ResultSet resultSet = Mockito.mock(ResultSet.class); + List rowList = new ArrayList<>(); + Mockito.doReturn(rowList).when(resultSet).all(); + Mockito.doReturn(resultSet).when(session).execute(Mockito.any(Statement.class)); + Result retVal = daoObj.check(trans); + assertTrue(retVal.status == 0); + + Row row = Mockito.mock(Row.class); + Mockito.doReturn("test").when(row).getString(Mockito.anyInt()); + rowList.add(row); + row = Mockito.mock(Row.class); + Mockito.doReturn("test").when(row).getString(Mockito.anyInt()); + Mockito.doReturn(100).when(row).getInt(Mockito.anyInt()); + rowList.add(row); + retVal = daoObj.check(trans); + assertTrue(retVal.status == 0); + + Mockito.doThrow(DriverException.class).when(session).execute(Mockito.any(Statement.class)); + retVal = daoObj.check(trans); + assertTrue(retVal.status == Result.ERR_Backend); + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + Mockito.doThrow(APIException.class).when(session).execute(Mockito.any(Statement.class)); + retVal = daoObj.check(trans); + assertTrue(retVal.status == Result.ERR_Backend); + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + Mockito.doThrow(IOException.class).when(session).execute(Mockito.any(Statement.class)); + retVal = daoObj.check(trans); + assertTrue(retVal.status == Result.ERR_Backend); + } + @Test + public void testStopUpdate() { + + CacheInfoDAO.stopUpdate(); + + } + + +/* + * This has intermittent Null Pointers, JUnit only + @Test + public void testGet() { + TimeTaken tt = Mockito.mock(TimeTaken.class); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO Touch segments test1: 1011", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); + Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); + Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); + Mockito.doNothing().when(tt).done(); + CacheInfoDAO.Data data = new CacheInfoDAO.Data(); + PSInfo createPS = Mockito.mock(PSInfo.class); + Result rs = new Result(null,0,"test",new String[0]); + Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data); + + CacheInfoDAOImpl daoObj=null; + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test",data, createPS); + Date retVal = daoObj.get(trans, "test", 1011); +// assertTrue(retVal.status == 0); + retVal = daoObj.get(trans, "test1", 1011); + } catch (APIException | IOException e) { + e.printStackTrace(); + } + } +*/ + + @Test + public void testWasMOdified() { + TimeTaken tt = Mockito.mock(TimeTaken.class); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); + Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); + Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); + Mockito.doReturn(tt).when(trans).start("DELETE APPROVAL",Env.REMOTE); + Mockito.doNothing().when(tt).done(); + CacheInfoDAO.Data data = new CacheInfoDAO.Data("test",1); + PSInfo createPS = Mockito.mock(PSInfo.class); + + HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class); + Result rs1 = new Result(null,0,"test",new String[0]); + Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any()); + + CacheInfoDAOImpl daoObj=null; + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test", createPS); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"}); + + + } + + @Test + public void testInfoLoader(){ + TimeTaken tt = Mockito.mock(TimeTaken.class); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO Touch segments test1: 1011", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); + Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); + Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); + Mockito.doNothing().when(tt).done(); + CacheInfoDAO.Data data1 = new CacheInfoDAO.Data(); + PSInfo createPS = Mockito.mock(PSInfo.class); + Result rs = new Result(null,0,"test",new String[0]); + Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data1); + + CacheInfoDAOImpl daoObj=null; + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test", createPS); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + Class[] classList = CacheInfoDAO.class.getDeclaredClasses(); + Class innerClass = null; + for(Class indCls:classList) { + if(indCls.getName().contains("InfoLoader")) { + innerClass = indCls; + } + } Constructor constructor = innerClass.getDeclaredConstructors()[0]; constructor.setAccessible(true); try { - Object obj = constructor.newInstance(1); - Method innnerClassMtd; - - CacheInfoDAO.Data data = new CacheInfoDAO.Data(); - Row row = Mockito.mock(Row.class); - innnerClassMtd = innerClass.getMethod("load", new Class[] {CacheInfoDAO.Data.class, Row.class}); - innnerClassMtd.invoke(obj, new Object[] {data, row}); - - innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {CacheInfoDAO.Data.class, Integer.TYPE, Object[].class }); - innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"}}); - - innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {CacheInfoDAO.Data.class, Integer.TYPE, Object[].class }); - innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"}}); - } catch (InstantiationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testCacheUpdate(){ - TimeTaken tt = Mockito.mock(TimeTaken.class); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO Touch segments test1: 1011", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); - Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); - Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); - Mockito.doNothing().when(tt).done(); - CacheInfoDAO.Data data1 = new CacheInfoDAO.Data(); - PSInfo createPS = Mockito.mock(PSInfo.class); - Result rs = new Result(null,0,"test",new String[0]); - Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data1); - - CacheInfoDAOImpl daoObj=null; - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test", createPS); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - Class[] classList = CacheInfoDAO.class.getDeclaredClasses(); - Class innerClass = null; - for(Class indCls:classList) { - if(indCls.getName().contains("CacheUpdate")) { - innerClass = indCls; - } - } + Object obj = constructor.newInstance(1); + Method innnerClassMtd; + + CacheInfoDAO.Data data = new CacheInfoDAO.Data(); + Row row = Mockito.mock(Row.class); + innnerClassMtd = innerClass.getMethod("load", new Class[] {CacheInfoDAO.Data.class, Row.class}); + innnerClassMtd.invoke(obj, new Object[] {data, row}); + + innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {CacheInfoDAO.Data.class, Integer.TYPE, Object[].class }); + innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"}}); + + innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {CacheInfoDAO.Data.class, Integer.TYPE, Object[].class }); + innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test"}}); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testCacheUpdate(){ + TimeTaken tt = Mockito.mock(TimeTaken.class); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO Touch segments test1: 1011", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); + Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); + Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); + Mockito.doNothing().when(tt).done(); + CacheInfoDAO.Data data1 = new CacheInfoDAO.Data(); + PSInfo createPS = Mockito.mock(PSInfo.class); + Result rs = new Result(null,0,"test",new String[0]); + Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data1); + + CacheInfoDAOImpl daoObj=null; + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test", createPS); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + Class[] classList = CacheInfoDAO.class.getDeclaredClasses(); + Class innerClass = null; + for(Class indCls:classList) { + if(indCls.getName().contains("CacheUpdate")) { + innerClass = indCls; + } + } Constructor constructor = innerClass.getDeclaredConstructors()[0]; constructor.setAccessible(true); try { - Object obj = constructor.newInstance(env,Mockito.mock(HMangr.class), Mockito.mock(SecuritySetter.class), "12.0.0.1", 8080); + Object obj = constructor.newInstance(env,Mockito.mock(HMangr.class), Mockito.mock(SecuritySetter.class), "12.0.0.1", 8080); - Class innerInnerClass = Class.forName("org.onap.aaf.auth.dao.cass.CacheInfoDAO$CacheUpdate$CacheClear"); + Class innerInnerClass = Class.forName("org.onap.aaf.auth.dao.cass.CacheInfoDAO$CacheUpdate$CacheClear"); Constructor innerConstructor = innerInnerClass.getDeclaredConstructors()[0]; innerConstructor.setAccessible(true); Object innerClassObj = innerConstructor.newInstance(obj, trans); - - Method innnerClassMtd; - - CacheInfoDAO.Data data = new CacheInfoDAO.Data(); - Row row = Mockito.mock(Row.class); - Rcli rcli = Mockito.mock(Rcli.class); - URI uri = new URI("ftp","admin:admin@geeksforgeeks.org:1234","/path/data","tt","ttd"); - Mockito.doReturn(uri).when(rcli).getURI(); - Mockito.doReturn(Mockito.mock(org.onap.aaf.cadi.client.Future.class)).when(rcli).delete("/mgmt/cache/null/null", "application/Void+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0"); - - innnerClassMtd = innerInnerClass.getMethod("code", new Class[] {Rcli.class}); - innnerClassMtd.invoke(innerClassObj, new Object[] {rcli}); - - org.onap.aaf.cadi.client.Future futureObj = Mockito.mock(org.onap.aaf.cadi.client.Future.class); - Mockito.doReturn(futureObj).when(rcli).delete("/mgmt/cache/null/null", "application/Void+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0"); - Mockito.doReturn(true).when(futureObj).get(0); - innnerClassMtd.invoke(innerClassObj, new Object[] {rcli}); - - uri = new URI("ftp","12.0.0.1:8080","/path/data","tt","ttd"); - Mockito.doReturn(uri).when(rcli).getURI(); - innnerClassMtd.invoke(innerClassObj, new Object[] {rcli}); - } catch (InstantiationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (ClassNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testIntHolder(){ - TimeTaken tt = Mockito.mock(TimeTaken.class); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO Touch segments test1: 1011", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); - Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); - Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); - Mockito.doNothing().when(tt).done(); - CacheInfoDAO.Data data1 = new CacheInfoDAO.Data(); - PSInfo createPS = Mockito.mock(PSInfo.class); - Result rs = new Result(null,0,"test",new String[0]); - Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data1); - - CacheInfoDAOImpl daoObj=null; - try { - daoObj = new CacheInfoDAOImpl(trans, cluster, "test", createPS); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - Class[] classList = CacheInfoDAO.class.getDeclaredClasses(); - Class innerClass = null; - for(Class indCls:classList) { - if(indCls.getName().contains("CacheUpdate")) { - innerClass = indCls; - } - } + + Method innnerClassMtd; + + CacheInfoDAO.Data data = new CacheInfoDAO.Data(); + Row row = Mockito.mock(Row.class); + Rcli rcli = Mockito.mock(Rcli.class); + URI uri = new URI("ftp","admin:admin@geeksforgeeks.org:1234","/path/data","tt","ttd"); + Mockito.doReturn(uri).when(rcli).getURI(); + Mockito.doReturn(Mockito.mock(org.onap.aaf.cadi.client.Future.class)).when(rcli).delete("/mgmt/cache/null/null", "application/Void+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0"); + + innnerClassMtd = innerInnerClass.getMethod("code", new Class[] {Rcli.class}); + innnerClassMtd.invoke(innerClassObj, new Object[] {rcli}); + + org.onap.aaf.cadi.client.Future futureObj = Mockito.mock(org.onap.aaf.cadi.client.Future.class); + Mockito.doReturn(futureObj).when(rcli).delete("/mgmt/cache/null/null", "application/Void+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0"); + Mockito.doReturn(true).when(futureObj).get(0); + innnerClassMtd.invoke(innerClassObj, new Object[] {rcli}); + + uri = new URI("ftp","12.0.0.1:8080","/path/data","tt","ttd"); + Mockito.doReturn(uri).when(rcli).getURI(); + innnerClassMtd.invoke(innerClassObj, new Object[] {rcli}); + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (URISyntaxException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (APIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (CadiException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testIntHolder(){ + TimeTaken tt = Mockito.mock(TimeTaken.class); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO Touch segments test1: 1011", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); + Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); + Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); + Mockito.doNothing().when(tt).done(); + CacheInfoDAO.Data data1 = new CacheInfoDAO.Data(); + PSInfo createPS = Mockito.mock(PSInfo.class); + Result rs = new Result(null,0,"test",new String[0]); + Mockito.doReturn(rs).when(createPS).exec(trans, "CacheInfoDAOImpl CREATE", data1); + + CacheInfoDAOImpl daoObj=null; + try { + daoObj = new CacheInfoDAOImpl(trans, cluster, "test", createPS); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + Class[] classList = CacheInfoDAO.class.getDeclaredClasses(); + Class innerClass = null; + for(Class indCls:classList) { + if(indCls.getName().contains("CacheUpdate")) { + innerClass = indCls; + } + } Constructor constructor = innerClass.getDeclaredConstructors()[0]; constructor.setAccessible(true); try { - Object obj = constructor.newInstance(env,Mockito.mock(HMangr.class), Mockito.mock(SecuritySetter.class), "12.0.0.1", 8080); + Object obj = constructor.newInstance(env,Mockito.mock(HMangr.class), Mockito.mock(SecuritySetter.class), "12.0.0.1", 8080); - Class innerInnerClass = Class.forName("org.onap.aaf.auth.dao.cass.CacheInfoDAO$CacheUpdate$IntHolder"); + Class innerInnerClass = Class.forName("org.onap.aaf.auth.dao.cass.CacheInfoDAO$CacheUpdate$IntHolder"); Constructor innerConstructor = innerInnerClass.getDeclaredConstructors()[0]; innerConstructor.setAccessible(true); int[] a = new int[10]; Object innerClassObj = innerConstructor.newInstance(obj, a); - - Method innnerClassMtd=null; - - CacheInfoDAO.Data data = new CacheInfoDAO.Data(); - Row row = Mockito.mock(Row.class); - Rcli rcli = Mockito.mock(Rcli.class); - URI uri = new URI("ftp","admin:admin@geeksforgeeks.org:1234","/path/data","tt","ttd"); - Mockito.doReturn(uri).when(rcli).getURI(); - Mockito.doReturn(Mockito.mock(org.onap.aaf.cadi.client.Future.class)).when(rcli).delete("/mgmt/cache/null/null", "application/Void+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0"); - - Method[] allMtds = innerInnerClass.getDeclaredMethods(); - for(Method indMtd:allMtds) { - if(indMtd.getName().contains("add")) { - innnerClassMtd = indMtd; - } - } - innnerClassMtd.invoke(innerClassObj, new Object[] {a}); - - - } catch (InstantiationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (ClassNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (URISyntaxException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (CadiException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - //@Test - public void testSecondConstructor() { - TimeTaken tt = Mockito.mock(TimeTaken.class); - Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); - Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); - Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); - Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); - Mockito.doReturn(tt).when(trans).start("DELETE APPROVAL",Env.REMOTE); - Mockito.doNothing().when(tt).done(); - CacheInfoDAO.Data data = new CacheInfoDAO.Data(); - AbsCassDAO absCassDAO = Mockito.mock(AbsCassDAO.class); - - try { - CacheInfoDAO daoObj = new CacheInfoDAO(trans, absCassDAO); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + + Method innnerClassMtd=null; + + CacheInfoDAO.Data data = new CacheInfoDAO.Data(); + Row row = Mockito.mock(Row.class); + Rcli rcli = Mockito.mock(Rcli.class); + URI uri = new URI("ftp","admin:admin@geeksforgeeks.org:1234","/path/data","tt","ttd"); + Mockito.doReturn(uri).when(rcli).getURI(); + Mockito.doReturn(Mockito.mock(org.onap.aaf.cadi.client.Future.class)).when(rcli).delete("/mgmt/cache/null/null", "application/Void+json;q=1.0;charset=utf-8;version=2.0,application/json;q=1.0;version=2.0,*/*;q=1.0"); + + Method[] allMtds = innerInnerClass.getDeclaredMethods(); + for(Method indMtd:allMtds) { + if(indMtd.getName().contains("add")) { + innnerClassMtd = indMtd; + } + } + innnerClassMtd.invoke(innerClassObj, new Object[] {a}); + + + } catch (InstantiationException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (InvocationTargetException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (URISyntaxException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (APIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (CadiException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + //@Test + public void testSecondConstructor() { + TimeTaken tt = Mockito.mock(TimeTaken.class); + Mockito.doReturn(tt).when(trans).start("CacheInfoDAO CREATE", Env.REMOTE); + Mockito.doReturn(tt).when(trans).start("Clear Reset Deque", Env.SUB); + Mockito.doReturn(tt).when(trans).start("New Cassandra Session", Env.SUB); + Mockito.doReturn(tt).when(trans).start("Preparing PSInfo CREATE on CacheInfoDAO", Env.SUB); + Mockito.doReturn(tt).when(trans).start("DELETE APPROVAL",Env.REMOTE); + Mockito.doNothing().when(tt).done(); + CacheInfoDAO.Data data = new CacheInfoDAO.Data(); + AbsCassDAO absCassDAO = Mockito.mock(AbsCassDAO.class); + + try { + CacheInfoDAO daoObj = new CacheInfoDAO(trans, absCassDAO); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } class CacheInfoDAOImpl extends CacheInfoDAO{ - public CacheInfoDAOImpl(AuthzTrans trans, Cluster cluster, String keyspace,CacheInfoDAO.Data data,PSInfo createPS ) throws APIException, IOException { - super(trans, cluster, keyspace); - this.createPS = createPS; -// setPs(this, createPS, "psByUser"); -// setPs(this, createPS, "psByApprover"); -// setPs(this, createPS, "psByTicket"); -// setPs(this, createPS, "psByStatus"); -// setSession(this, Mockito.mock(Session.class)); - } - - public CacheInfoDAOImpl(AuthzTrans trans, Cluster cluster, String keyspace,PSInfo readPS ) throws APIException, IOException { - super(trans, cluster, keyspace); - this.readPS = readPS; - } - - - public void setPs(CacheInfoDAOImpl CacheInfoDAOObj, PSInfo psInfoObj, String methodName) { - Field nsDaoField; - try { - nsDaoField = CacheInfoDAO.class.getDeclaredField(methodName); - - nsDaoField.setAccessible(true); - // remove final modifier from field - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); -// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL); - - nsDaoField.set(CacheInfoDAOObj, psInfoObj); - } catch (NoSuchFieldException | SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - - public void setSession(CacheInfoDAOImpl CacheInfoDAOObj, Session session) { - Field nsDaoField; - try { - nsDaoField = AbsCassDAO.class.getDeclaredField("session"); - - nsDaoField.setAccessible(true); - // remove final modifier from field - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); -// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL); - nsDaoField.set(CacheInfoDAOObj, session); - } catch (NoSuchFieldException | SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - + public CacheInfoDAOImpl(AuthzTrans trans, Cluster cluster, String keyspace,CacheInfoDAO.Data data,PSInfo createPS ) throws APIException, IOException { + super(trans, cluster, keyspace); + this.createPS = createPS; +// setPs(this, createPS, "psByUser"); +// setPs(this, createPS, "psByApprover"); +// setPs(this, createPS, "psByTicket"); +// setPs(this, createPS, "psByStatus"); +// setSession(this, Mockito.mock(Session.class)); + } + + public CacheInfoDAOImpl(AuthzTrans trans, Cluster cluster, String keyspace,PSInfo readPS ) throws APIException, IOException { + super(trans, cluster, keyspace); + this.readPS = readPS; + } + + + public void setPs(CacheInfoDAOImpl CacheInfoDAOObj, PSInfo psInfoObj, String methodName) { + Field nsDaoField; + try { + nsDaoField = CacheInfoDAO.class.getDeclaredField(methodName); + + nsDaoField.setAccessible(true); + // remove final modifier from field + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); +// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL); + + nsDaoField.set(CacheInfoDAOObj, psInfoObj); + } catch (NoSuchFieldException | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + public void setSession(CacheInfoDAOImpl CacheInfoDAOObj, Session session) { + Field nsDaoField; + try { + nsDaoField = AbsCassDAO.class.getDeclaredField("session"); + + nsDaoField.setAccessible(true); + // remove final modifier from field + Field modifiersField = Field.class.getDeclaredField("modifiers"); + modifiersField.setAccessible(true); +// modifiersField.setInt(nsDaoField, nsDaoField.getModifiers() & ~Modifier.FINAL); + nsDaoField.set(CacheInfoDAOObj, session); + } catch (NoSuchFieldException | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalArgumentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IllegalAccessException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }