public void deleteUser(final User user) {
        if (provider.isReadOnly()) {
            throw new UnsupportedOperationException("User provider is read-only.");
        }

        final String username = user.getUsername();
        // Make sure that the username is valid.
        try {
            /*username =*/ Stringprep.nodeprep(username);
        }
        catch (final StringprepException se) {
            throw new IllegalArgumentException("Invalid username: " + username,  se);
        }

        // Fire event.
        final Map<String,Object> params = Collections.emptyMap();
        UserEventDispatcher.dispatchEvent(user, UserEventDispatcher.EventType.user_deleting, params);

        provider.deleteUser(user.getUsername());
        // Remove the user from cache.
        userCache.remove(user.getUsername());
    }
@Test
    public void deleteInvalidUserWillGetError()  throws Exception{
    	User user = new User("!@#ED",null,null,null,null);	
    	assertThrows(IllegalArgumentException.class, () -> userManager.deleteUser(user));
    }