use of org.infobip.mobile.messaging.mobile.common.exceptions.BackendCommunicationException in project mobile-messaging-sdk-android by infobip.
the class RetryableSynchronizersTest method setUp.
@SuppressLint("CommitPrefEdits")
@Override
public void setUp() throws Exception {
super.setUp();
MobileMessagingStats stats = mobileMessagingCore.getStats();
PreferenceHelper.saveBoolean(context, MobileMessagingProperty.REPORT_SYSTEM_INFO, true);
PreferenceHelper.saveInt(context, MobileMessagingProperty.DEFAULT_EXP_BACKOFF_MULTIPLIER, 0);
PreferenceHelper.remove(context, MobileMessagingProperty.REPORTED_SYSTEM_DATA_HASH);
mobileMessageHandler = mock(MobileMessageHandler.class);
mobileApiData = mock(MobileApiData.class);
mobileApiMessages = mock(MobileApiMessages.class);
mobileApiRegistration = mock(MobileApiRegistration.class);
given(mobileApiData.reportUserData(anyString(), any(UserDataReport.class))).willThrow(new BackendCommunicationException("Backend error", new ApiIOException("0", "Backend error")));
doThrow(new BackendCommunicationException("Backend error", new ApiIOException("0", "Backend error"))).when(mobileApiData).reportSystemData(any(SystemDataReport.class));
given(mobileApiMessages.sync(any(SyncMessagesBody.class))).willThrow(new BackendCommunicationException("Backend error", new ApiIOException("0", "Backend error")));
given(mobileApiRegistration.upsert(anyString(), anyBoolean())).willThrow(new BackendCommunicationException("Backend error", new ApiIOException("0", "Backend error")));
RetryPolicyProvider retryPolicyProvider = new RetryPolicyProvider(context);
retryPolicy = retryPolicyProvider.DEFAULT();
executor = Executors.newSingleThreadExecutor();
systemDataReporter = new SystemDataReporter(mobileMessagingCore, stats, retryPolicy, executor, broadcaster, mobileApiData);
messagesSynchronizer = new MessagesSynchronizer(mobileMessagingCore, stats, executor, broadcaster, retryPolicy, mobileMessageHandler, mobileApiMessages);
registrationSynchronizer = new RegistrationSynchronizer(context, mobileMessagingCore, stats, executor, broadcaster, retryPolicyProvider, mobileApiRegistration);
userDataReporter = new UserDataReporter(mobileMessagingCore, executor, broadcaster, retryPolicyProvider, stats, mobileApiData);
}
use of org.infobip.mobile.messaging.mobile.common.exceptions.BackendCommunicationException in project mobile-messaging-sdk-android by infobip.
the class RetryableSynchronizerTest method test_geo_report_retry.
@Test
public void test_geo_report_retry() {
// Given
createReport(context, "signalingMessageId1", "campaignId1", "messageId1", true, createArea("areaId1"));
createReport(context, "signalingMessageId2", "campaignId2", "messageId2", true, createArea("areaId2"));
createReport(context, "signalingMessageId2", "campaignId2", "messageId3", true, createArea("areaId3"));
given(mobileApiGeo.report(any(EventReportBody.class))).willThrow(new BackendCommunicationException("Backend error", new ApiIOException("0", "Backend error")));
// When
geoReporter.synchronize();
// Then
verify(geoBroadcaster, Mockito.after(8000).times(1)).error(any(MobileMessagingError.class));
verify(mobileApiGeo, times(4)).report(any(EventReportBody.class));
}
Aggregations