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.declarator: publicationManager
test_class.modifier: private
test_class.original_string: private PublicationManager publicationManager;
test_class.type: PublicationManager
test_class.var_name: publicationManager
test_class.file: core/src/test/java/org/apache/sling/cms/core/publication/BulkPublicationJobTest.java
test_class.identifier: BulkPublicationJobTest
test_case.body: @Test
      public void testDeep() throws PublicationException {
  
          BulkPublicationJob pubJob = context.registerInjectActivateService(new BulkPublicationJob());
  
          JobExecutionContext jobContext = Mockito.mock(JobExecutionContext.class);
          ResultBuilder result = Mockito.mock(ResultBuilder.class);
          Mockito.when(jobContext.result()).thenReturn(result);
          Job job = Mockito.mock(Job.class);
  
          Mockito.when(job.getProperty(Mockito.matches("paths"), Mockito.any())).thenReturn(new String[] { "/content" });
          Mockito.when(job.getProperty(Mockito.matches("type"), Mockito.any()))
                  .thenReturn(PublicationType.ADD.toString());
          Mockito.when(job.getProperty(Mockito.matches("deep"), Mockito.anyBoolean())).thenReturn(true);
  
          pubJob.doProcess(job, jobContext, context.resourceResolver());
  
          Mockito.verify(publicationManager, Mockito.atLeast(5)).publish(Mockito.any());
          Mockito.verify(result).succeeded();
      }
test_case.class_method_signature: BulkPublicationJobTest.testDeep()
test_case.full_signature: @Test public void testDeep()
test_case.identifier: testDeep
test_case.invocations: registerInjectActivateService mock mock thenReturn when result mock thenReturn when getProperty matches any thenReturn when getProperty matches any toString thenReturn when getProperty matches anyBoolean doProcess resourceResolver publish verify atLeast any succeeded verify
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testDeep()
focal_class.declarator: log = LoggerFactory.getLogger(BulkPublicationJob.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(BulkPublicationJob.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: TOPIC = "cmsjob/org/apache/sling/cms/publication/Bulk"
focal_class.modifier: public static final
focal_class.original_string: public static final String TOPIC = "cmsjob/org/apache/sling/cms/publication/Bulk";
focal_class.type: String
focal_class.var_name: TOPIC
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.declarator: factory
focal_class.modifier: @Reference
      private
focal_class.original_string: @Reference
      private ResourceResolverFactory factory;
focal_class.type: ResourceResolverFactory
focal_class.var_name: factory
focal_class.file: core/src/main/java/org/apache/sling/cms/core/publication/BulkPublicationJob.java
focal_class.identifier: BulkPublicationJob
focal_class.class_method_signature: BulkPublicationJob.doProcess(Job job, JobExecutionContext context, ResourceResolver resolver)
focal_class.full_signature: @Override public JobExecutionResult doProcess(Job job, JobExecutionContext context, ResourceResolver resolver)
focal_class.identifier: doProcess
focal_class.modifiers: @Override public
focal_class.parameters: (Job job, JobExecutionContext context, ResourceResolver resolver)
focal_class.return: JobExecutionResult
focal_class.signature: JobExecutionResult doProcess(Job job, JobExecutionContext context, ResourceResolver resolver)
focal_class.class_method_signature: BulkPublicationJob.getConfigurationPath()
focal_class.full_signature: @Override public String getConfigurationPath()
focal_class.identifier: getConfigurationPath
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getConfigurationPath()
focal_class.class_method_signature: BulkPublicationJob.getResolverFactory()
focal_class.full_signature: @Override public ResourceResolverFactory getResolverFactory()
focal_class.identifier: getResolverFactory
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: ResourceResolverFactory
focal_class.signature: ResourceResolverFactory getResolverFactory()
focal_class.class_method_signature: BulkPublicationJob.getTitleKey()
focal_class.full_signature: @Override public String getTitleKey()
focal_class.identifier: getTitleKey
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getTitleKey()
focal_class.class_method_signature: BulkPublicationJob.getTopic()
focal_class.full_signature: @Override public String getTopic()
focal_class.identifier: getTopic
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getTopic()
focal_class.superclass: extends ConfigurableJobExecutor
focal_method.body: @Override
      public JobExecutionResult doProcess(Job job, JobExecutionContext context, ResourceResolver resolver) {
          String[] paths = job.getProperty("paths", String[].class);
          PublicationType type = PublicationType.valueOf(job.getProperty("type", String.class));
          boolean deep = job.getProperty("deep", false);
  
          PublicationManager publicationManager = publicationManagerFactory.getPublicationManager();
  
          context.initProgress(paths.length, paths.length * 5000L);
  
          log.info("Starting bulk publication: paths={}, type={}, deep={}", paths, type, deep);
  
          for (String path : paths) {
              Stream<PublishableResource> toPublish = null;
              Resource resource = resolver.getResource(path);
              if (deep) {
                  toPublish = ResourceTree
                          .stream(resource, new IsPublishableResourceContainer(), new IsPublishableResourceType())
                          .map(rt -> rt.getResource().adaptTo(PublishableResource.class));
              } else {
                  toPublish = Collections.singletonList(resource.adaptTo(PublishableResource.class)).stream();
              }
              toPublish.forEach(pr -> {
                  try {
                      if (type == PublicationType.ADD) {
                          publicationManager.publish(pr);
                      } else {
                          publicationManager.unpublish(pr);
                      }
                      context.log("{0} complete for {1}", type, pr.getPath());
                  } catch (PublicationException e) {
                      context.log("{0} failed for {1}", type, pr.getPath());
                      log.warn("Failed to publish {}", pr, e);
                  }
              });
  
              context.log("Publication complete for path: {0}", path);
              context.incrementProgressCount(1);
          }
  
          context.log("Publication complete!");
          return context.result().succeeded();
      }
focal_method.class_method_signature: BulkPublicationJob.doProcess(Job job, JobExecutionContext context, ResourceResolver resolver)
focal_method.full_signature: @Override public JobExecutionResult doProcess(Job job, JobExecutionContext context, ResourceResolver resolver)
focal_method.identifier: doProcess
focal_method.invocations: getProperty valueOf getProperty getProperty getPublicationManager initProgress info getResource map stream adaptTo getResource stream singletonList adaptTo forEach publish unpublish log getPath log getPath warn log incrementProgressCount log succeeded result
focal_method.modifiers: @Override public
focal_method.parameters: (Job job, JobExecutionContext context, ResourceResolver resolver)
focal_method.return: JobExecutionResult
focal_method.signature: JobExecutionResult doProcess(Job job, JobExecutionContext context, ResourceResolver resolver)