### Question:
TraverserWorkerManager { public static TraverserWorker newWorker(TraverserConfiguration conf, IndexingService indexingService) { return TraverserWorkerManager.newWorker(conf, indexingService, null); } private  TraverserWorkerManager(); static TraverserWorker newWorker(TraverserConfiguration conf,
      IndexingService indexingService); static TraverserWorker newWorker(TraverserConfiguration conf,
        IndexingService indexingService,  @Nullable ExecutorService executor);  }### Answer:
@Test public void testNewWorkerWithoutConf() { thrown.expect(NullPointerException.class); thrown.expectMessage("configuration should be defined"); TraverserWorkerManager.newWorker(null, indexingService); }
@Test public void testNewWorkerWithoutIndexingService() { thrown.expect(NullPointerException.class); thrown.expectMessage("indexingService should be defined"); TraverserConfiguration conf = (new TraverserConfiguration.Builder()) .name("name of worker") .itemRetriever(batchItemRetriever) .build(); TraverserWorkerManager.newWorker(conf, null); }
@Test public void testNewWorkerWithoutItemRetriever() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("one and only one itemRetriever or batchItemRetriever should be defined"); TraverserConfiguration conf = (new TraverserConfiguration.Builder()) .name("name of worker") .build(); TraverserWorkerManager.newWorker(conf, indexingService); }
@Test public void testNewWorkerWithBatchItemRetriever() { TraverserConfiguration conf = (new TraverserConfiguration.Builder("test")) .name("name of worker") .itemRetriever(batchItemRetriever) .build(); TraverserWorker worker = TraverserWorkerManager.newWorker(conf, indexingService); assertEquals("name of worker", worker.getName()); assertEquals(BatchProcessingTraverserWorker.class, worker.getClass()); }
@Test public void testNewWorkerWithItemRetriever() { TraverserConfiguration conf = (new TraverserConfiguration.Builder("test")) .name("name of worker") .itemRetriever(itemRetriever) .build(); TraverserWorker worker = TraverserWorkerManager.newWorker(conf, indexingService); assertEquals("name of worker", worker.getName()); assertEquals(ParallelProcessingTraverserWorker.class, worker.getClass()); }
@Test public void testNewWorkerwithExecutorService(){ TraverserConfiguration conf = (new TraverserConfiguration.Builder("test")) .name("test name") .itemRetriever(itemRetriever) .build(); TraverserWorker worker = TraverserWorkerManager.newWorker(conf, indexingService, executor); assertEquals("test name", worker.getName()); assertEquals(ParallelProcessingTraverserWorker.class, worker.getClass()); }