BatchDataflowWorker implements Closeable { void executeWork(DataflowWorkExecutor worker, DataflowWorkProgressUpdater progressUpdater) throws Exception { progressUpdater.startReportingProgress(); try { worker.execute(); } finally { progressUpdater.stopReportingProgress(); } } protected  BatchDataflowWorker(
      RunnerApi.@Nullable Pipeline pipeline,
      SdkHarnessRegistry sdkHarnessRegistry,
      WorkUnitClient workUnitClient,
      DataflowMapTaskExecutorFactory mapTaskExecutorFactory,
      DataflowWorkerHarnessOptions options); boolean getAndPerformWork(); void startStatusServer(); @Override void close();  }
@Test public void testStartAndStopProgressReport() throws Exception { BatchDataflowWorker worker = new BatchDataflowWorker( null , SdkHarnessRegistries.emptySdkHarnessRegistry(), mockWorkUnitClient, IntrinsicMapTaskExecutorFactory.defaultFactory(), options); worker.executeWork(mockWorkExecutor, mockProgressUpdater); verify(mockProgressUpdater, times(1)).startReportingProgress(); verify(mockProgressUpdater, times(1)).stopReportingProgress(); }
@Test public void testStopProgressReportInCaseOfFailure() throws Exception { doThrow(new WorkerException()).when(mockWorkExecutor).execute(); BatchDataflowWorker worker = new BatchDataflowWorker( null , SdkHarnessRegistries.emptySdkHarnessRegistry(), mockWorkUnitClient, IntrinsicMapTaskExecutorFactory.defaultFactory(), options); try { worker.executeWork(mockWorkExecutor, mockProgressUpdater); } catch (WorkerException e) { } verify(mockProgressUpdater, times(1)).stopReportingProgress(); }