### Question:
TDMDataPersisterJob extends QuartzJobBean { @Override protected void executeInternal(JobExecutionContext executionContext) throws JobExecutionException { persistvehicleAndCrewData(executionContext); persistDepotData(executionContext); }    }### Answer:
@Test public void testPersistData() throws JobExecutionException, DataAccessResourceFailureException { job.executeInternal(executionContext); verify(vehicleAndCrewDataPersisterService).saveVehiclePulloutData(); verify(vehicleAndCrewDataPersisterService).saveCrewAssignmentData(); verify(depotDataPersistenceService).saveDepotData(); }
@Test public void testPersistVehicleDataException() throws JobExecutionException, SQLException { doThrow(new DataAccessResourceFailureException("Test exception")).when(vehicleAndCrewDataPersisterService).saveVehiclePulloutData(); job.executeInternal(executionContext); verify(vehicleAndCrewDataPersisterService, times(2)).saveVehiclePulloutData(); verify(vehicleAndCrewDataPersisterService, times(1)).saveCrewAssignmentData(); verify(depotDataPersistenceService, times(1)).saveDepotData(); }
@Test public void testPersistCrewDataException() throws JobExecutionException, DataAccessResourceFailureException { doThrow(new DataAccessResourceFailureException("Test exception")).when(vehicleAndCrewDataPersisterService).saveCrewAssignmentData(); job.executeInternal(executionContext); verify(vehicleAndCrewDataPersisterService, times(1)).saveVehiclePulloutData(); verify(vehicleAndCrewDataPersisterService, times(2)).saveCrewAssignmentData(); verify(depotDataPersistenceService, times(1)).saveDepotData(); }
@Test public void testPersistDepotDataException() throws JobExecutionException, DataAccessResourceFailureException { doThrow(new DataAccessResourceFailureException("Test Exception")).when(depotDataPersistenceService).saveDepotData(); job.executeInternal(executionContext); verify(vehicleAndCrewDataPersisterService, times(1)).saveVehiclePulloutData(); verify(vehicleAndCrewDataPersisterService, times(1)).saveCrewAssignmentData(); verify(depotDataPersistenceService, times(2)).saveDepotData(); }