@Test public void read() throws Exception { Judgment judgment1 = mock(Judgment.class); Judgment judgment2 = mock(Judgment.class); Judgment judgment3 = mock(Judgment.class); when(ccRemovedJudgmentsFinder.findCcRemovedJudgmentSourceIds()).thenReturn(Lists.newArrayList(1L, 2L, 3L)); when(judgmentRepository.findOne(1L)).thenReturn(judgment1); when(judgmentRepository.findOne(2L)).thenReturn(judgment2); when(judgmentRepository.findOne(3L)).thenReturn(judgment3); ccjDeleteRemovedReader.open(mock(ExecutionContext.class)); Judgment retJudgment1 = ccjDeleteRemovedReader.read(); Judgment retJudgment2 = ccjDeleteRemovedReader.read(); Judgment retJudgment3 = ccjDeleteRemovedReader.read(); Judgment retJudgment4 = ccjDeleteRemovedReader.read(); assertTrue(retJudgment1 == judgment1); assertTrue(retJudgment2 == judgment2); assertTrue(retJudgment3 == judgment3); assertNull(retJudgment4); }
@Override public Judgment read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { Long judgmentIdToDelete = judgmentIdsToDelete.poll(); if (judgmentIdToDelete == null) { return null; } Judgment judgmentToDelete = judgmentRepository.findOne(judgmentIdToDelete); return judgmentToDelete != null ? judgmentToDelete : read(); }
CcjDeleteRemovedReader implements ItemStreamReader<Judgment> { @Override public Judgment read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { Long judgmentIdToDelete = judgmentIdsToDelete.poll(); if (judgmentIdToDelete == null) { return null; } Judgment judgmentToDelete = judgmentRepository.findOne(judgmentIdToDelete); return judgmentToDelete != null ? judgmentToDelete : read(); } }
CcjDeleteRemovedReader implements ItemStreamReader<Judgment> { @Override public Judgment read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { Long judgmentIdToDelete = judgmentIdsToDelete.poll(); if (judgmentIdToDelete == null) { return null; } Judgment judgmentToDelete = judgmentRepository.findOne(judgmentIdToDelete); return judgmentToDelete != null ? judgmentToDelete : read(); }  }
CcjDeleteRemovedReader implements ItemStreamReader<Judgment> { @Override public Judgment read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { Long judgmentIdToDelete = judgmentIdsToDelete.poll(); if (judgmentIdToDelete == null) { return null; } Judgment judgmentToDelete = judgmentRepository.findOne(judgmentIdToDelete); return judgmentToDelete != null ? judgmentToDelete : read(); }  @Override void open(ExecutionContext executionContext); @Override Judgment read(); @Override void update(ExecutionContext executionContext); @Override void close(); }
CcjDeleteRemovedReader implements ItemStreamReader<Judgment> { @Override public Judgment read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { Long judgmentIdToDelete = judgmentIdsToDelete.poll(); if (judgmentIdToDelete == null) { return null; } Judgment judgmentToDelete = judgmentRepository.findOne(judgmentIdToDelete); return judgmentToDelete != null ? judgmentToDelete : read(); }  @Override void open(ExecutionContext executionContext); @Override Judgment read(); @Override void update(ExecutionContext executionContext); @Override void close();  }