use of com.path.android.jobqueue.RetryConstraint in project dev-summit-architecture-demo by yigit.
the class FetchFeedJobTest method testFailure500.
@Test
public void testFailure500() throws Throwable {
FetchFeedJob job = new FetchFeedJob(BaseJob.BACKGROUND, null);
when(mApiService.feed(0L)).thenReturn(createCall(500, new FeedResponse()));
job.inject(getTestComponent());
Throwable exception = safeRun(job);
assertThat(exception, notNullValue());
assertThat(exception, instanceOf(NetworkException.class));
RetryConstraint retryConstraint = job.shouldReRunOnThrowable(exception, 1, 10);
assertThat(retryConstraint.shouldRetry(), is(true));
}
use of com.path.android.jobqueue.RetryConstraint in project dev-summit-architecture-demo by yigit.
the class SaveNewPostJob method shouldReRunOnThrowable.
@Override
protected RetryConstraint shouldReRunOnThrowable(Throwable throwable, int runCount, int maxRunCount) {
if (shouldRetry(throwable)) {
// For the purposes of the demo, just back off 250 ms.
RetryConstraint constraint = RetryConstraint.createExponentialBackoff(runCount, 250);
constraint.setApplyNewDelayToGroup(true);
return constraint;
}
return RetryConstraint.CANCEL;
}
use of com.path.android.jobqueue.RetryConstraint in project dev-summit-architecture-demo by yigit.
the class FetchFeedJobTest method testFailure404.
@Test
public void testFailure404() throws Throwable {
FetchFeedJob job = new FetchFeedJob(BaseJob.BACKGROUND, null);
when(mApiService.feed(0L)).thenReturn(createCall(404, new FeedResponse()));
job.inject(getTestComponent());
Throwable exception = safeRun(job);
assertThat(exception, notNullValue());
assertThat(exception, instanceOf(NetworkException.class));
RetryConstraint retryConstraint = job.shouldReRunOnThrowable(exception, 1, 10);
assertThat(retryConstraint.shouldRetry(), is(false));
}
Aggregations