test_class.declarator: context = new SlingContext()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public SlingContext context = new SlingContext();
test_class.type: SlingContext
test_class.var_name: context
test_class.declarator: user
test_class.modifier: private
test_class.original_string: private User user;
test_class.type: User
test_class.var_name: user
test_class.declarator: USER_PATH = "/home/users/test"
test_class.modifier: public static final
test_class.original_string: public static final String USER_PATH = "/home/users/test";
test_class.type: String
test_class.var_name: USER_PATH
test_class.file: core/src/test/java/org/apache/sling/cms/core/internal/operations/ChangePasswordOperationTest.java
test_class.identifier: ChangePasswordOperationTest
test_case.body: @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_case.class_method_signature: ChangePasswordOperationTest.testChangePassword()
test_case.full_signature: @Test public void testChangePassword()
test_case.identifier: testChangePassword
test_case.invocations: currentResource setParameterMap request build put builder run request mock assertNull getError changePassword verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testChangePassword()
focal_class.declarator: log = LoggerFactory.getLogger(ChangePasswordOperation.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(ChangePasswordOperation.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.file: core/src/main/java/org/apache/sling/cms/core/internal/operations/ChangePasswordOperation.java
focal_class.identifier: ChangePasswordOperation
focal_class.interfaces: implements PostOperation
focal_class.class_method_signature: ChangePasswordOperation.run(SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors)
focal_class.full_signature: @Override public void run(SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors)
focal_class.identifier: run
focal_class.modifiers: @Override public
focal_class.parameters: (SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors)
focal_class.return: void
focal_class.signature: void run(SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors)
focal_method.body: @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);
  
              // invoke processors
              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);
          }
      }
focal_method.class_method_signature: ChangePasswordOperation.run(SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors)
focal_method.full_signature: @Override public void run(SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors)
focal_method.identifier: run
focal_method.invocations: getParameter adaptTo getResource isGroup getAuthorizable getAuthorizable changePassword process commit getResourceResolver setPath getPath onModified getPath warn setError
focal_method.modifiers: @Override public
focal_method.parameters: (SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors)
focal_method.return: void
focal_method.signature: void run(SlingHttpServletRequest request, PostResponse response, SlingPostProcessor[] processors)