### Question:
ChangePasswordOperation implements PostOperation { @Override public void run(SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors) { final List<Modification> changes = new ArrayList<>(); try { String password = request.getParameter(CreateUserOperation.PN_PASSWORD); AuthorizableWrapper authWrapper = request.getResource().adaptTo(AuthorizableWrapper.class); if (authWrapper.getAuthorizable().isGroup()) { throw new RepositoryException("Authorizable is a group!"); } User user = (User) authWrapper.getAuthorizable(); user.changePassword(password); if (processors != null) { for (SlingPostProcessor processor : processors) { processor.process(request, changes); } } request.getResourceResolver().commit(); response.setPath(user.getPath()); response.onModified(user.getPath()); } catch (Exception e) { log.warn("Failed to change user password", e); response.setError(e); } }  @Override void run(SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors);  }### Answer:
@Test public void testChangePassword() throws RepositoryException { ChangePasswordOperation operation = new ChangePasswordOperation(); PostResponse response = new JSONResponse(); context.currentResource(USER_PATH); context.request().setParameterMap( ImmutableMap.<String, Object>builder().put(CreateUserOperation.PN_PASSWORD, "test1").build()); operation.run(context.request(), response, new SlingPostProcessor[] { Mockito.mock(SlingPostProcessor.class) }); assertNull(response.getError()); Mockito.verify(user).changePassword("test1"); }
@Test public void testGroup() throws RepositoryException { ChangePasswordOperation operation = new ChangePasswordOperation(); PostResponse response = new JSONResponse(); context.currentResource("/home/groups/sling-cms/authors"); context.request().setParameterMap( ImmutableMap.<String, Object>builder().put(CreateUserOperation.PN_PASSWORD, "test1").build()); operation.run(context.request(), response, null); assertNotNull(response.getError()); }