Permission permission2 = new Permission();
permission2.setName("123");
permission2.setPermission("abc");
permissionService.save(permission2);
Role role = new Role();
role.setName("abc");
role.setRole("abc");
role.addResourcePermission(
new RoleResourcePermission(
resource1.getId(),
Sets.newHashSet(permission1.getId(), permission2.getId())));
role.addResourcePermission(
new RoleResourcePermission(
resource2.getId(),
Sets.newHashSet(permission1.getId(), permission2.getId())));
roleService.save(role);
clear();
Role dbRole = roleService.findOne(role.getId());
Assert.assertEquals(2, dbRole.getResourcePermissions().size());
Assert.assertEquals(2, dbRole.getResourcePermissions().get(0).getPermissionIds().size());
resourceService.delete(resource1);
permissionService.delete(permission1);
clear();