    @Test
    public void fetchRetry() throws Exception {

        AtomicInteger atomicInteger = new AtomicInteger(0);
        when(placesApi.placesResult()).thenReturn(
                Observable.create(subscriber -> {
                    if (atomicInteger.getAndIncrement() < 3) {
                        subscriber.onError(new Exception());
                    } else {
                        subscriber.onNext(TestDataUtils.nearByData());
                        subscriber.onCompleted();
                    }
                })
        );
        try {
            boolean success = placesViewModel.fetchAllPlaces().toBlocking().first();
            verify(placesApi).placesResult();
            assertTrue(success);
        } catch (Exception ignored) {
            fail("Have to retry three times");
        }
    }