Role extends AbstractHibernateObject implements Linkable, RoleInfo { public void addPermission(PermissionBlueprint p) { this.permissions.add(p); p.setRole(this); } Role(String name);  Role(String name, Set<User> users, Set<PermissionBlueprint> memberships);  Role(); String getHref(); void setHref(String href); @Override String getId(); void setId(String id); String getName(); void setName(String name); Set<User> getUsers(); void setUsers(Set<User> users); void clearUsers(); void addUser(User u); void removeUser(User u); @Override Set<PermissionBlueprint> getPermissions(); void setPermissions(Set<PermissionBlueprint> permissions); void addPermission(PermissionBlueprint p); void clearPermissions(); static final String DB_TABLE; }
@Test public void testAddPermission() { Role role = new Role("myrole"); roleCurator.create(role); role.addPermission(new PermissionBlueprint(PermissionType.OWNER, owner, Access.ALL)); roleCurator.flush(); role = roleCurator.get(role.getId()); assertEquals(1, role.getPermissions().size()); PermissionBlueprint perm = role.getPermissions().iterator().next(); assertNotNull(perm.getId()); }