@SuppressWarnings("unchecked")
@Test
public void shouldRetryThreeTimes() throws Exception {

    when(fetcher.fetchData())
            .thenThrow(CrawlerRetryException.class)
            .thenThrow(CrawlerRetryException.class)
            .thenReturn(true);
    retryableFetcher.tryFetchData();
    verify(fetcher, times(3)).fetchData();
}