Source:
<code>public void read_FOUND() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception { Judgment firstJudgment = createCcJudgment(1); Judgment secondJudgment = createCcJudgment(2); Judgment thirdJudgment = createCcJudgment(3); Page<Judgment> firstPage = new PageImpl<Judgment>(Lists.newArrayList(firstJudgment, secondJudgment), new PageRequest(0, 2), 3); Page<Judgment> secondPage = new PageImpl<Judgment>(Lists.newArrayList(thirdJudgment), new PageRequest(1, 1), 3); Page<Judgment> thirdPage = new PageImpl<Judgment>(Lists.newArrayList()); when(judgmentRepository.findAllToIndex(any(Pageable.class))).thenReturn(firstPage, secondPage, thirdPage); <START> <END> Judgment actualFirst = judgmentIndexingReader.read(); Judgment actualSecond = judgmentIndexingReader.read(); Judgment actualThird = judgmentIndexingReader.read(); Judgment actualFourth = judgmentIndexingReader.read(); ArgumentCaptor<Pageable> pageArgCapture = ArgumentCaptor.forClass(Pageable.class); verify(judgmentRepository, atLeast(2)).findAllToIndex(pageArgCapture.capture()); Pageable firstPageRequestArg = pageArgCapture.getAllValues().get(0); assertEquals(0, firstPageRequestArg.getPageNumber()); Pageable secondPageRequestArg = pageArgCapture.getAllValues().get(1); assertEquals(1, secondPageRequestArg.getPageNumber()); assertEquals(firstJudgment.getId(), actualFirst.getId()); assertEquals(secondJudgment.getId(), actualSecond.getId()); assertEquals(thirdJudgment.getId(), actualThird.getId()); assertNull(actualFourth); }</code><technical_language>Instead of suppressWarnings method level, I suggest: @SuppressWarnings({ "unused", "unchecked" }) OngoingStubbing<Page<Judgment>> thenReturn = when(judgmentRepository.findAllToIndex(any(Pageable.class))).thenReturn(firstPage, secondPage, thirdPage);</technical_language>

Target:
public void read_FOUND() throws UnexpectedInputException, ParseException, NonTransientResourceException, Exception { Judgment firstJudgment = createCcJudgment(1); Judgment secondJudgment = createCcJudgment(2); Judgment thirdJudgment = createCcJudgment(3); Page<Judgment> firstPage = new PageImpl<Judgment>(Lists.newArrayList(firstJudgment, secondJudgment), new PageRequest(0, 2), 3); Page<Judgment> secondPage = new PageImpl<Judgment>(Lists.newArrayList(thirdJudgment), new PageRequest(1, 1), 3); Page<Judgment> thirdPage = new PageImpl<Judgment>(Lists.newArrayList()); @SuppressWarnings({ "unused", "unchecked" }) OngoingStubbing<Page<Judgment>> thenReturn = when(judgmentRepository.findAllToIndex(any(Pageable.class))).thenReturn(firstPage, secondPage, thirdPage); Judgment actualFirst = judgmentIndexingReader.read(); Judgment actualSecond = judgmentIndexingReader.read(); Judgment actualThird = judgmentIndexingReader.read(); Judgment actualFourth = judgmentIndexingReader.read(); ArgumentCaptor<Pageable> pageArgCapture = ArgumentCaptor.forClass(Pageable.class); verify(judgmentRepository, atLeast(2)).findAllToIndex(pageArgCapture.capture()); Pageable firstPageRequestArg = pageArgCapture.getAllValues().get(0); assertEquals(0, firstPageRequestArg.getPageNumber()); Pageable secondPageRequestArg = pageArgCapture.getAllValues().get(1); assertEquals(1, secondPageRequestArg.getPageNumber()); assertEquals(firstJudgment.getId(), actualFirst.getId()); assertEquals(secondJudgment.getId(), actualSecond.getId()); assertEquals(thirdJudgment.getId(), actualThird.getId()); assertNull(actualFourth); }