* 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
* 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
* 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.
* 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.
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psByUser");
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psByUser");
Result<List<UserRoleDAO.Data>> rs1 = new Result<List<UserRoleDAO.Data>>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "UserRoleDAO READ", new Object[]{"test"});
Result<List<UserRoleDAO.Data>> rs1 = new Result<List<UserRoleDAO.Data>>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "UserRoleDAO READ", new Object[]{"test"});
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psByRole");
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psByRole");
Result<List<UserRoleDAO.Data>> rs1 = new Result<List<UserRoleDAO.Data>>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "UserRoleDAO READ", new Object[]{"test"});
Result<List<UserRoleDAO.Data>> rs1 = new Result<List<UserRoleDAO.Data>>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "UserRoleDAO READ", new Object[]{"test"});
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psUserInRole");
PSInfo psObj = Mockito.mock(PSInfo.class);
setPsByStartAndTarget(daoObj, psObj, "psUserInRole");
Result<List<UserRoleDAO.Data>> rs1 = new Result<List<UserRoleDAO.Data>>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "UserRoleDAO READ", new Object[]{"test"});
Result<List<UserRoleDAO.Data>> rs1 = new Result<List<UserRoleDAO.Data>>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(psObj).read(trans, "UserRoleDAO READ", new Object[]{"test"});
public void setPsByStartAndTarget(UserRoleDAO UserRoleDAOObj, PSInfo psInfoObj, String fieldName) {
Field UserRoleDAOField;
try {
UserRoleDAOField = UserRoleDAO.class.getDeclaredField(fieldName);
public void setPsByStartAndTarget(UserRoleDAO UserRoleDAOObj, PSInfo psInfoObj, String fieldName) {
Field UserRoleDAOField;
try {
UserRoleDAOField = UserRoleDAO.class.getDeclaredField(fieldName);
UserRoleDAOField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(UserRoleDAOField, UserRoleDAOField.getModifiers() & ~Modifier.FINAL);
UserRoleDAOField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(UserRoleDAOField, UserRoleDAOField.getModifiers() & ~Modifier.FINAL);
UserRoleDAOField.set(UserRoleDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
UserRoleDAOField.set(UserRoleDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
Mockito.doNothing().when(tt).done();
UserRoleDAO.Data data = new UserRoleDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
Mockito.doNothing().when(tt).done();
UserRoleDAO.Data data = new UserRoleDAO.Data();
PSInfo createPS = Mockito.mock(PSInfo.class);
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new Object[0]);
Result<Void> rs2 = new Result<Void>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
Result<ResultSet> rs1 = new Result<ResultSet>(null,0,"test",new Object[0]);
Result<Void> rs2 = new Result<Void>(null,0,"test",new Object[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
UserRoleDAOImpl daoObj = null;
try {
daoObj = new UserRoleDAOImpl(trans, historyDAO, cacheInfoDAO, createPS );
UserRoleDAOImpl daoObj = null;
try {
daoObj = new UserRoleDAOImpl(trans, historyDAO, cacheInfoDAO, createPS );
e.printStackTrace();
}
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
e.printStackTrace();
}
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test"});
daoObj.wasModified(trans, CRUD.update, data, new String[] {});
daoObj.wasModified(trans, CRUD.create, data, new String[] {null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test",null});
daoObj.wasModified(trans, CRUD.update, data, new String[] {});
daoObj.wasModified(trans, CRUD.create, data, new String[] {null});
daoObj.wasModified(trans, CRUD.create, data, new String[] {"test",null});
daoObj.wasModified(trans, CRUD.delete, data, new String[] {"test","test"});
daoObj.wasModified(trans, CRUD.delete, data, new String[] {});
daoObj.wasModified(trans, CRUD.delete, data, new String[] {"test","test"});
daoObj.wasModified(trans, CRUD.delete, data, new String[] {});
rs2 = new Result<Void>(null,1,"test",new Object[0]);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
daoObj.wasModified(trans, CRUD.read, data, new String[] {"test","test"});
daoObj.wasModified(trans, CRUD.read, data, new String[] {});
rs2 = new Result<Void>(null,1,"test",new Object[0]);
Mockito.doReturn(rs2).when(cacheInfoDAO).touch(Mockito.any(AuthzTrans.class),Mockito.anyString(), Mockito.anyVararg());
daoObj.wasModified(trans, CRUD.read, data, new String[] {"test","test"});
daoObj.wasModified(trans, CRUD.read, data, new String[] {});
rs1 = new Result<ResultSet>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
daoObj.wasModified(trans, CRUD.delete, data, new String[] {"test","test"});
}
rs1 = new Result<ResultSet>(null,1,"test",new String[0]);
Mockito.doReturn(rs1).when(historyDAO).create(Mockito.any(), Mockito.any());
daoObj.wasModified(trans, CRUD.delete, data, new String[] {"test","test"});
}
@Test
public void testSecondConstructor() {
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
UserRoleDAO daoObj = new UserRoleDAO(trans, historyDAO, cacheInfoDAO);
@Test
public void testSecondConstructor() {
HistoryDAO historyDAO = Mockito.mock(HistoryDAO.class);
CacheInfoDAO cacheInfoDAO = Mockito.mock(CacheInfoDAO.class);
UserRoleDAO daoObj = new UserRoleDAO(trans, historyDAO, cacheInfoDAO);
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
Constructor<?> constructor = innerClass.getDeclaredConstructors()[0];
constructor.setAccessible(true);
UserRoleDAO.Data data = new UserRoleDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
UserRoleDAO.Data data = new UserRoleDAO.Data();
Row row = Mockito.mock(Row.class);
ByteBuffer bbObj = ByteBuffer.allocateDirect(10);
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
bbObj.put(1, new Byte("1"));
bbObj.put(2, new Byte("2"));
Mockito.doReturn(bbObj).when(row).getBytesUnsafe(1);
innnerClassMtd = innerClass.getMethod("load", new Class[] {UserRoleDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
innnerClassMtd = innerClass.getMethod("load", new Class[] {UserRoleDAO.Data.class, Row.class});
innnerClassMtd.invoke(obj, new Object[] {data, row});
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {UserRoleDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test"} });
innnerClassMtd = innerClass.getDeclaredMethod("key", new Class[] {UserRoleDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test"} });
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {UserRoleDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
innnerClassMtd = innerClass.getDeclaredMethod("body", new Class[] {UserRoleDAO.Data.class, Integer.TYPE, Object[].class });
innnerClassMtd.invoke(obj, new Object[] {data, 1, new Object[] {"test","test","test","test","test","test","test","test","test","test","test"} });
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
innnerClassMtd = innerClass.getDeclaredMethod("marshal", new Class[] {UserRoleDAO.Data.class, DataOutputStream.class });
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
innnerClassMtd = innerClass.getDeclaredMethod("marshal", new Class[] {UserRoleDAO.Data.class, DataOutputStream.class });
DataInputStream dis = new DataInputStream(bais);
innnerClassMtd = innerClass.getDeclaredMethod("unmarshal", new Class[] {UserRoleDAO.Data.class, DataInputStream.class });
innnerClassMtd.invoke(obj, new Object[] {data, dis });
DataInputStream dis = new DataInputStream(bais);
innnerClassMtd = innerClass.getDeclaredMethod("unmarshal", new Class[] {UserRoleDAO.Data.class, DataInputStream.class });
innnerClassMtd.invoke(obj, new Object[] {data, dis });
@Test
public void testData() {
UserRoleDAO.Data data = new UserRoleDAO.Data();
NsSplit nss = new NsSplit("test", "test");
data = new UserRoleDAO.Data();
@Test
public void testData() {
UserRoleDAO.Data data = new UserRoleDAO.Data();
NsSplit nss = new NsSplit("test", "test");
data = new UserRoleDAO.Data();
data.toString();
data.role("test", "test");
assertTrue("test".equals(data.ns));
data.toString();
data.role("test", "test");
assertTrue("test".equals(data.ns));
Question q = Mockito.mock( Question.class);
Result<NsSplit> rs = new Result<NsSplit>(nss,0,"test",new Object[0]);
Mockito.doReturn(rs).when(q).deriveNsSplit(trans, "test");
Question q = Mockito.mock( Question.class);
Result<NsSplit> rs = new Result<NsSplit>(nss,0,"test",new Object[0]);
Mockito.doReturn(rs).when(q).deriveNsSplit(trans, "test");
rs = new Result<NsSplit>(nss,1,"test",new Object[0]);
Mockito.doReturn(rs).when(q).deriveNsSplit(trans, "test");
rs = new Result<NsSplit>(nss,1,"test",new Object[0]);
Mockito.doReturn(rs).when(q).deriveNsSplit(trans, "test");
super(trans, historyDAO, cacheDao);
setPs(this, readPS, "createPS");
}
super(trans, historyDAO, cacheDao);
setPs(this, readPS, "createPS");
}
public UserRoleDAOImpl(AuthzTrans trans, HistoryDAO historyDAO,CacheInfoDAO cacheDao, PSInfo readPS, Session session ) throws APIException, IOException {
super(trans, historyDAO, cacheDao);
setPs(this, readPS, "createPS");
setSession(this, session);
}
public UserRoleDAOImpl(AuthzTrans trans, HistoryDAO historyDAO,CacheInfoDAO cacheDao, PSInfo readPS, Session session ) throws APIException, IOException {
super(trans, historyDAO, cacheDao);
setPs(this, readPS, "createPS");
setSession(this, session);
}
public void setPs(UserRoleDAOImpl UserRoleDAOObj, PSInfo psInfoObj, String methodName) {
Field UserRoleDAOField;
try {
UserRoleDAOField = CassDAOImpl.class.getDeclaredField(methodName);
public void setPs(UserRoleDAOImpl UserRoleDAOObj, PSInfo psInfoObj, String methodName) {
Field UserRoleDAOField;
try {
UserRoleDAOField = CassDAOImpl.class.getDeclaredField(methodName);
UserRoleDAOField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(UserRoleDAOField, UserRoleDAOField.getModifiers() & ~Modifier.FINAL);
UserRoleDAOField.setAccessible(true);
// remove final modifier from field
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
// modifiersField.setInt(UserRoleDAOField, UserRoleDAOField.getModifiers() & ~Modifier.FINAL);
UserRoleDAOField.set(UserRoleDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
UserRoleDAOField.set(UserRoleDAOObj, psInfoObj);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
public void setSession(UserRoleDAOImpl approvalDaoObj, Session session) {
Field nsDaoField;
try {
nsDaoField = AbsCassDAO.class.getDeclaredField("session");
public void setSession(UserRoleDAOImpl approvalDaoObj, 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.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(approvalDaoObj, session);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
nsDaoField.set(approvalDaoObj, session);
} catch (NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block