use of com.braintreepayments.api.exceptions.ServerException in project braintree_android by braintree.
the class AnalyticsSenderUnitTest method doesNothingOnAsynchronousErrorResponse.
@Test
public void doesNothingOnAsynchronousErrorResponse() throws Exception {
AnalyticsEvent one = new AnalyticsEvent(RuntimeEnvironment.application, "sessionId", "custom", "started");
AnalyticsEvent two = new AnalyticsEvent(RuntimeEnvironment.application, "sessionId", "custom", "finished");
AnalyticsDatabase database = AnalyticsDatabase.getInstance(RuntimeEnvironment.application);
database.addEvent(one);
database.addEvent(two);
awaitTasksFinished(database);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((HttpResponseCallback) invocation.getArguments()[2]).failure(new ServerException(""));
return null;
}
}).when(mHttpClient).post(anyString(), anyString(), any(HttpResponseCallback.class));
AnalyticsSender.send(RuntimeEnvironment.application, mAuthorization, mHttpClient, "", false);
List<List<AnalyticsEvent>> pendingEvents = database.getPendingRequests();
assertEquals(1, pendingEvents.size());
}
Aggregations