### Question:
BatchStateUpdater implements Runnable { @Override public void run() { IndexerDefinition indexerDefinition = null; try { indexerDefinition = indexerModel.getIndexer(indexerName); } catch (IndexerNotFoundException e) { log.info("Could not find index " + indexerName + " while checking batch rebuild status.",e); } if (indexerDefinition != null) { log.debug("Checking batch state for " + indexerDefinition.getName()); BatchBuildInfo batchBuildInfo = indexerDefinition.getActiveBatchBuildInfo(); if (batchBuildInfo != null) { Set<String> jobs = batchBuildInfo.getMapReduceJobTrackingUrls().keySet(); boolean batchDone = true; boolean overAllSuccess = true; for (String jobId : jobs) { RunningJob job; try { job = jobClient.getJob(JobID.forName(jobId)); } catch (IOException e) { log.error("Could not get job " + jobId + " for index " + indexerDefinition.getName() + " while checking active build info.",e); batchDone = false; break; } if (job != null) { int jobState; try { jobState = job.getJobState(); } catch (IOException e) { log.error("Could not get jobstate for job " + jobId + " for index " + indexerDefinition.getName() + " while checking active build info.",e); batchDone = false; break; } batchDone = batchDone && jobState != JobStatus.RUNNING; overAllSuccess = overAllSuccess && jobState == JobStatus.SUCCEEDED; } else { log.warn("Could not find job " + jobId + " while checking active batch builds for indexer " + indexerDefinition.getName()); } } if (batchDone) { markBatchBuildCompleted(indexerDefinition.getName(), overAllSuccess); } else { executor.schedule(this, pollInterval, TimeUnit.MILLISECONDS); } } } } protected  BatchStateUpdater(String indexerName, WriteableIndexerModel indexerModel, JobClient jobClient,
                      ScheduledExecutorService executor, int pollInterval); @Override void run();  }### Answer:
@Test public void testRun() throws Exception { String jobId = "job_201407251005_0815"; createDefinition("mytest", jobId); createJob(jobId, JobStatus.SUCCEEDED); checkAllIndexes(); verify(model, VerificationModeFactory.atLeastOnce()).updateIndexerInternal(any(IndexerDefinition.class)); }