RdfEngine implements Engine { @Override public void deleteUser(String username) { try (RepositoryConnection conn = repository.getConnection()) { Optional<Resource> optId = getUserId(username, conn); if (!optId.isPresent()) { throw new IllegalArgumentException("User with that id does not exist"); } conn.remove(optId.get(), null, null, context); conn.remove(null, null, (Value) optId.get(), context); } }  @Override Optional<Role> getRole(String roleName); @Override Set<User> getUsers(); @Override User createUser(UserConfig userConfig); @Override void storeUser(User user); @Override boolean userExists(String username); @Override boolean userExists(Resource userId); @Override Optional<User> retrieveUser(String username); @Override void updateUser(User newUser); @Override void deleteUser(String username); @Override Set<Group> getGroups(); @Override Group createGroup(GroupConfig groupConfig); @Override void storeGroup(Group group); @Override boolean groupExists(String groupTitle); @Override boolean groupExists(Resource groupId); @Override Optional<Group> retrieveGroup(String groupTitle); @Override void updateGroup(Group newGroup); @Override void deleteGroup(String groupTitle); @Override Set<Role> getUserRoles(String username); @Override boolean checkPassword(String username, String password); @Override String getEngineName(); static final String ENGINE_NAME; }
@Test public void testDeleteUser() { engine.deleteUser(username); RepositoryConnection connection = repo.getConnection(); RepositoryResult<Statement> statements = connection.getStatements(VALUE_FACTORY.createIRI(userId), null, null); assertFalse(statements.hasNext()); statements = connection.getStatements(null, null, VALUE_FACTORY.createIRI(userId)); assertFalse(statements.hasNext()); connection.close(); }
@Test(expected = IllegalArgumentException.class) public void testDeleteUserThatDoesNotExist() { engine.deleteUser("http: }