* 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.
AuthzEnv env;
@Mock
LogTarget logTarget;
-
+
@Before
public void setUp() throws APIException, IOException {
initMocks(this);
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);
PSInfo createPS = Mockito.mock(PSInfo.class);
Result<ResultSet> rs = new Result<ResultSet>(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);
Result<Data> retVal = daoObj.create(trans, data);
assertTrue(retVal.status == 0);
}
-
+
@Test
public void testTouch() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
Mockito.doNothing().when(tt).done();
Mockito.doReturn(logTarget).when(env).debug();
-
+
CacheInfoDAO.Data data = new CacheInfoDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
Result<ResultSet> rs = new Result<ResultSet>(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);
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) {
retVal = daoObj.touch(trans, "test", 1, 2);
assertTrue(retVal.status == Result.ERR_Backend);
}
-
+
@Test
public void testCheck() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
PSInfo createPS = Mockito.mock(PSInfo.class);
Result<ResultSet> rs = new Result<ResultSet>(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(resultSet).when(session).execute(Mockito.any(Statement.class));
Result<Void> 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);
}
@Test
public void testStopUpdate() {
-
+
CacheInfoDAO.stopUpdate();
-
+
}
PSInfo createPS = Mockito.mock(PSInfo.class);
Result<ResultSet> rs = new Result<ResultSet>(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);
}
}
*/
-
+
@Test
public void testWasMOdified() {
TimeTaken tt = Mockito.mock(TimeTaken.class);
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<ResultSet> rs1 = new Result<ResultSet>(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);
e.printStackTrace();
}
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
-
-
+
+
}
-
+
@Test
public void testInfoLoader(){
TimeTaken tt = Mockito.mock(TimeTaken.class);
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"}});
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testCacheUpdate(){
TimeTaken tt = Mockito.mock(TimeTaken.class);
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 (CadiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
+
@Test
public void testIntHolder(){
TimeTaken tt = Mockito.mock(TimeTaken.class);
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.invoke(innerClassObj, new Object[] {a});
-
-
+
+
} catch (InstantiationException 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);
// 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
}
}
-
+
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");
e.printStackTrace();
}
}
-
+
}