test_class.declarator: context = new SlingContext()
test_class.modifier: @Rule
      public final
test_class.original_string: @Rule
      public final SlingContext context = new SlingContext();
test_class.type: SlingContext
test_class.var_name: context
test_class.file: core/src/test/java/org/apache/sling/cms/core/publication/PublishPostOperationTest.java
test_class.identifier: PublishPostOperationTest
test_case.body: @Test
      public void testPublish() throws PublicationException {
          PublicationManagerFactory publicationManagerFactory = Mockito.mock(PublicationManagerFactory.class);
          PublicationManager publicationManager = Mockito.mock(PublicationManager.class);
          Mockito.when(publicationManagerFactory.getPublicationManager()).thenReturn(publicationManager);
          context.registerService(PublicationManagerFactory.class, publicationManagerFactory);
          PublishPostOperation publishPostOperation = context.registerInjectActivateService(new PublishPostOperation());
          PostResponse response = Mockito.mock(PostResponse.class);
  
          publishPostOperation.run(context.request(), response, null);
  
          Mockito.verify(publicationManager).publish(Mockito.any());
  
          Mockito.verify(response, Mockito.never()).setError(Mockito.any());
          Mockito.verify(response).setPath(context.currentResource().getPath());
      }
test_case.class_method_signature: PublishPostOperationTest.testPublish()
test_case.full_signature: @Test public void testPublish()
test_case.identifier: testPublish
test_case.invocations: mock mock thenReturn when getPublicationManager registerService registerInjectActivateService mock run request publish verify any setError verify never any setPath verify getPath currentResource
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPublish()
focal_class.declarator: log = LoggerFactory.getLogger(PublishPostOperation.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(PublishPostOperation.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: publicationManagerFactory
focal_class.modifier: @Reference
      private
focal_class.original_string: @Reference
      private PublicationManagerFactory publicationManagerFactory;
focal_class.type: PublicationManagerFactory
focal_class.var_name: publicationManagerFactory
focal_class.file: core/src/main/java/org/apache/sling/cms/core/publication/PublishPostOperation.java
focal_class.identifier: PublishPostOperation
focal_class.interfaces: implements PostOperation
focal_class.class_method_signature: PublishPostOperation.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 {
              response.setPath(request.getResource().getPath());
              publicationManagerFactory.getPublicationManager()
                      .publish(request.getResource().adaptTo(PublishableResource.class));
  
              if (processors != null) {
                  for (SlingPostProcessor processor : processors) {
                      processor.process(request, changes);
                  }
              }
  
              request.getResourceResolver().commit();
  
              response.onModified(request.getResource().getPath());
          } catch (Exception e) {
              log.error("Failed to publish", e);
              response.setError(e);
          }
      }
focal_method.class_method_signature: PublishPostOperation.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: setPath getPath getResource publish getPublicationManager adaptTo getResource process commit getResourceResolver onModified getPath getResource error 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)