* 测试删除角色时删除用户-角色的中间表.
*/
@Test
public void deleteRole() {
//新增测试角色并与admin用户绑定.
Role role = new Role();
role.setName(DataUtils.randomName("Role"));
roleDao.save(role);
User user = userDao.get(1L);
user.getRoleList().add(role);
userDao.save(user);
userDao.flush();
int oldJoinTableCount = countRowsInTable("ACCT_USER_ROLE");
int oldUserTableCount = countRowsInTable("ACCT_USER");
//删除用户角色, 中间表将减少1条记录,而用户表应该不受影响.
roleDao.delete(role.getId());
roleDao.flush();
int newJoinTableCount = countRowsInTable("ACCT_USER_ROLE");
int newUserTableCount = countRowsInTable("ACCT_USER");
assertEquals(1, oldJoinTableCount - newJoinTableCount);