DefaultUserServiceAdapter implements UserServiceAdapter { @Override public UserInfo createUser(UserInfo user) { if (user == null) { throw new IllegalArgumentException("user is null"); } if (user.getUsername() == null || user.getUsername().isEmpty()) { throw new IllegalArgumentException("Username is null or empty"); } if (this.userCurator.findByLogin(user.getUsername()) != null) { throw new IllegalStateException("User already exists: " + user.getUsername()); } User entity = new User(); entity.setUsername(user.getUsername()); entity.setHashedPassword(user.getHashedPassword()); entity.setSuperAdmin(user.isSuperAdmin() != null ? user.isSuperAdmin() : false); if (user.getRoles() != null) { for (RoleInfo role : user.getRoles()) { Role roleEntity = this.roleCurator.getByName(role.getName()); if (roleEntity == null) { throw new IllegalStateException("Role does not exist: " + role.getName()); } entity.addRole(roleEntity); } } entity = this.userCurator.create(entity); return entity; } @Inject  DefaultUserServiceAdapter(UserCurator userCurator, RoleCurator roleCurator,
        PermissionBlueprintCurator permissionCurator, OwnerCurator ownerCurator,
        PermissionFactory permissionFactory); @Override UserInfo createUser(UserInfo user); @Override UserInfo updateUser(String username, UserInfo user); @Override List<? extends UserInfo> listUsers(); @Override boolean validateUser(String username, String password); @Override void deleteUser(String username); @Override UserInfo findByLogin(String login); @Override Collection<? extends OwnerInfo> getAccessibleOwners(String username); @Override RoleInfo createRole(RoleInfo role); @Override RoleInfo updateRole(String roleName, RoleInfo role); @Override RoleInfo addUserToRole(String roleName, String username); @Override RoleInfo removeUserFromRole(String roleName, String username); @Override RoleInfo addPermissionToRole(String roleName, PermissionBlueprintInfo permission); @Override RoleInfo removePermissionFromRole(String roleName, String permissionId); @Override void deleteRole(String role); @Override RoleInfo getRole(String roleName); @Override List<? extends RoleInfo> listRoles();  }
@Test @Disabled("Find a way to do this with permissions") public void findOwner() { User user = new User("test_name", "password"); this.service.createUser(user); Role adminRole = createAdminRole(owner); adminRole.addUser(user); roleCurator.create(adminRole); }