@Test
public void testRunIngestCrawler() throws Exception {

   // Case: UpdateStatus Success, VerifyIngest Success,
   PGETaskInstance pgeTask = createTestInstance();
   pgeTask.pgeConfig.addOuputDirAndExpressions(new OutputDir("/tmp/dir1", true));
   pgeTask.pgeConfig.addOuputDirAndExpressions(new OutputDir("/tmp/dir2", true));
   pgeTask.pgeMetadata.replaceMetadata(ATTEMPT_INGEST_ALL, Boolean.toString(true));
   pgeTask.setWorkflowInstId("WorkflowInstanceId");
   pgeTask.setWmClient(createMock(WorkflowManagerClient.class));
   expect(pgeTask.getWorkflowManagerClient()
           .updateWorkflowInstanceStatus(pgeTask.getWorkflowInstId(), CRAWLING.getWorkflowStatusName())
   ).andReturn(true);
   replay(pgeTask.getWorkflowManagerClient());
   AutoDetectProductCrawler pc = createMock(AutoDetectProductCrawler.class);
   pc.crawl(new File("/tmp/dir1"));
   pc.crawl(new File("/tmp/dir2"));
   expect(pc.getIngestStatus()).andReturn(Collections.<IngestStatus>emptyList());
   replay(pc);
   pgeTask.runIngestCrawler(pc);
   verify(pgeTask.getWorkflowManagerClient());
   verify(pc);
   // Case: UpdateStatus Fail
   pgeTask.setWmClient(createMock(WorkflowManagerClient.class));
   expect(pgeTask.getWorkflowManagerClient().updateWorkflowInstanceStatus(pgeTask.getWorkflowInstId(),
         CRAWLING.getWorkflowStatusName())).andReturn(false);
   replay(pgeTask.getWorkflowManagerClient());
   pc = createMock(AutoDetectProductCrawler.class);
   replay(pc);
   try {
      pgeTask.runIngestCrawler(pc);
      fail("Should have thrown");
   } catch (Exception e) { /* expect throw */ }
   verify(pgeTask.getWorkflowManagerClient());
   verify(pc);
   // Case: UpdateStatus Success, VerifyIngest Fail
   pgeTask.setWmClient(createMock(WorkflowManagerClient.class));
   expect(pgeTask.getWorkflowManagerClient().updateWorkflowInstanceStatus(pgeTask.getWorkflowInstId(),
         CRAWLING.getWorkflowStatusName())).andReturn(true);
   replay(pgeTask.getWorkflowManagerClient());
   pc = createMock(AutoDetectProductCrawler.class);
   pc.crawl(new File("/tmp/dir1"));
   pc.crawl(new File("/tmp/dir2"));
   IngestStatus failedIngestStatus = new IngestStatus() {
      @Override
      public String getMessage() {
         return "Ingest Failure";
      }
      @Override
      public File getProduct() {
         return new File("/tmp/dir1");
      }
      @Override
      public Result getResult() {
         return Result.FAILURE;
      }
   };
   expect(pc.getIngestStatus()).andReturn(
         Lists.newArrayList(failedIngestStatus));
   replay(pc);
   try {
      pgeTask.runIngestCrawler(pc);
      fail("Should have thrown");
   } catch (Exception e) { /* expect throw */ }
   verify(pgeTask.getWorkflowManagerClient());
   verify(pc);
}