@Test public void whenRecordWriterThrowException_thenWriterListenerShouldBeInvoked() throws Exception { Batch<String> batch = new Batch<>(record1, record2); doThrow(exception).when(writer).writeRecords(batch); job = new JobBuilder<String, String>() .reader(reader) .writer(writer) .writerListener(recordWriterListener) .build(); job.call(); verify(recordWriterListener).onRecordWritingException(batch, exception); }
@Override public JobReport call() { start(); try { openReader(); openWriter(); setStatus(JobStatus.STARTED); while (moreRecords() && !isInterrupted()) { Batch<O> batch = readAndProcessBatch(); writeBatch(batch); } setStatus(JobStatus.STOPPING); } catch (Exception exception) { fail(exception); return report; } finally { closeReader(); closeWriter(); } teardown(); return report; }
BatchJob implements Job { @Override public JobReport call() { start(); try { openReader(); openWriter(); setStatus(JobStatus.STARTED); while (moreRecords() && !isInterrupted()) { Batch<O> batch = readAndProcessBatch(); writeBatch(batch); } setStatus(JobStatus.STOPPING); } catch (Exception exception) { fail(exception); return report; } finally { closeReader(); closeWriter(); } teardown(); return report; } }
BatchJob implements Job { @Override public JobReport call() { start(); try { openReader(); openWriter(); setStatus(JobStatus.STARTED); while (moreRecords() && !isInterrupted()) { Batch<O> batch = readAndProcessBatch(); writeBatch(batch); } setStatus(JobStatus.STOPPING); } catch (Exception exception) { fail(exception); return report; } finally { closeReader(); closeWriter(); } teardown(); return report; } BatchJob(JobParameters parameters); }
BatchJob implements Job { @Override public JobReport call() { start(); try { openReader(); openWriter(); setStatus(JobStatus.STARTED); while (moreRecords() && !isInterrupted()) { Batch<O> batch = readAndProcessBatch(); writeBatch(batch); } setStatus(JobStatus.STOPPING); } catch (Exception exception) { fail(exception); return report; } finally { closeReader(); closeWriter(); } teardown(); return report; } BatchJob(JobParameters parameters); @Override String getName(); @Override JobReport call(); void setRecordReader(RecordReader<I> recordReader); void setRecordWriter(RecordWriter<O> recordWriter); void addRecordProcessor(RecordProcessor<?, ?> recordProcessor); void addBatchListener(BatchListener<O> batchListener); void addJobListener(JobListener jobListener); void addRecordReaderListener(RecordReaderListener<I> recordReaderListener); void addRecordWriterListener(RecordWriterListener<O> recordWriterListener); void addPipelineListener(PipelineListener pipelineListener); void setName(String name); }
BatchJob implements Job { @Override public JobReport call() { start(); try { openReader(); openWriter(); setStatus(JobStatus.STARTED); while (moreRecords() && !isInterrupted()) { Batch<O> batch = readAndProcessBatch(); writeBatch(batch); } setStatus(JobStatus.STOPPING); } catch (Exception exception) { fail(exception); return report; } finally { closeReader(); closeWriter(); } teardown(); return report; } BatchJob(JobParameters parameters); @Override String getName(); @Override JobReport call(); void setRecordReader(RecordReader<I> recordReader); void setRecordWriter(RecordWriter<O> recordWriter); void addRecordProcessor(RecordProcessor<?, ?> recordProcessor); void addBatchListener(BatchListener<O> batchListener); void addJobListener(JobListener jobListener); void addRecordReaderListener(RecordReaderListener<I> recordReaderListener); void addRecordWriterListener(RecordWriterListener<O> recordWriterListener); void addPipelineListener(PipelineListener pipelineListener); void setName(String name);  }