### Question:
UserService implements UserDetailsService { public List<Long> removeRolesFromUser(final Long userId, final Long entityId, final Iterable<Long> rolesId) throws NotFoundEntityException { return addRemoveRolesToFromUser(userId, entityId, rolesId, false); }  EUser createDefaultUser(); EUser signUp(final EUser u, final EmailStatus emailStatus); EUser signUp(final EUser u, final EmailStatus emailStatus,
                        final RegistrationPrivilege registrationPrivilege); List<Long> addRolesToUser(final Long userId, final Long entityId,
                                     final Iterable<Long> rolesId); List<Long> removeRolesFromUser(final Long userId, final Long entityId, final Iterable<Long> rolesId); @Override UserDetails loadUserByUsername(final String usernameOrEmail); String getUserAuthoritiesForToken(final String usernameOrEmail, final String separator); Map<String, List<BRole>> getRolesForUser(final Long id); List<BRole> getRolesForUserOverEntity(final Long userId, final Long entityId); Long getEntityIdByUser(final EUser u);  }### Answer:
@Test public void removeRolesFromUser() { EUser u = userRepository.save(EntityUtil.getSampleUser(random.nextString())); assertNotNull(u); BRole r1 = roleRepository.save(EntityUtil.getSampleRole(random.nextString())); assertNotNull(r1); BRole r2 = roleRepository.save(EntityUtil.getSampleRole(random.nextString())); assertNotNull(r2); EOwnedEntity e = entityRepository.save(EntityUtil.getSampleEntity(random.nextString())); assertNotNull(e); BAuthorization.BAuthorizationPk pk1 = new BAuthorization.BAuthorizationPk(u.getId(), e.getId(), r1.getId()); assertNotNull(pk1); BAuthorization auth1 = authorizationRepository.save(new BAuthorization(pk1, u, e, r1)); assertNotNull(auth1); BAuthorization.BAuthorizationPk pk2 = new BAuthorization.BAuthorizationPk(u.getId(), e.getId(), r2.getId()); assertNotNull(pk1); BAuthorization auth2 = authorizationRepository.save(new BAuthorization(pk2, u, e, r2)); assertNotNull(auth2); Collection<Long> ids = new LinkedList<>(); ids.add(r1.getId()); ids.add(r2.getId()); List<BRole> roles = authorizationRepository.getRolesForUserOverEntity(u.getId(), e.getId()); assertNotNull(roles); assertEquals(roles.size(), ids.size()); assertTrue(ids.contains(roles.get(0).getId())); assertTrue(ids.contains(roles.get(1).getId())); List<Long> removed = null; try { removed = userService.removeRolesFromUser(u.getId(), e.getId(), ids); } catch (NotFoundEntityException e1) { LOGGER.error(e1.getLocalizedMessage()); fail("Roles could not be removed"); } assertNotNull(removed); assertEquals(removed.size(), roles.size()); assertTrue(removed.contains(roles.get(0).getId())); assertTrue(removed.contains(roles.get(1).getId())); roles = authorizationRepository.getRolesForUserOverEntity(u.getId(), e.getId()); assertNotNull(roles); assertTrue(roles.isEmpty()); }