use of org.infobip.mobile.messaging.gcm.MobileMessageHandler 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.gcm.MobileMessageHandler in project mobile-messaging-sdk-android by infobip.
the class MobileMessagingCore method messagesSynchronizer.
@NonNull
private MessagesSynchronizer messagesSynchronizer() {
if (messagesSynchronizer == null) {
MobileMessageHandler mobileMessageHandler = new MobileMessageHandler(this, broadcaster, getNotificationHandler(), getMessageStoreWrapper());
messagesSynchronizer = new MessagesSynchronizer(this, stats, registrationAlignedExecutor, broadcaster, retryPolicyProvider.DEFAULT(), mobileMessageHandler, mobileApiResourceProvider().getMobileApiMessages(context));
}
return messagesSynchronizer;
}
use of org.infobip.mobile.messaging.gcm.MobileMessageHandler in project mobile-messaging-sdk-android by infobip.
the class MobileMessageHandlerTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
enableMessageStoreForReceivedMessages();
PreferenceHelper.saveBoolean(context, MobileMessagingProperty.PUSH_REGISTRATION_ENABLED, true);
PreferenceHelper.saveBoolean(context, MobileMessagingProperty.GEOFENCING_ACTIVATED, true);
mobileMessageHandler = new MobileMessageHandler(mobileMessagingCore, coreBroadcaster, notificationHandler, mobileMessagingCore.getMessageStoreWrapper());
pushMessageHandler = new PushMessageHandler();
commonStore = mobileMessaging.getMessageStore();
}
use of org.infobip.mobile.messaging.gcm.MobileMessageHandler in project mobile-messaging-sdk-android by infobip.
the class PushUnregisteredTest method setUp.
@SuppressLint({ "CommitPrefEdits", "ApplySharedPref" })
@Override
public void setUp() throws Exception {
super.setUp();
ExecutorService taskExecutor = Executors.newSingleThreadExecutor();
MobileMessagingStats stats = mobileMessagingCore.getStats();
PreferenceHelper.saveLong(context, MobileMessagingProperty.BATCH_REPORTING_DELAY, 100L);
PreferenceHelper.saveBoolean(context, MobileMessagingProperty.GEOFENCING_ACTIVATED, true);
mobileApiMessages = mock(MobileApiMessages.class);
mobileApiGeo = mock(MobileApiGeo.class);
mobileMessageHandler = mock(MobileMessageHandler.class);
RetryPolicyProvider retryPolicyProvider = new RetryPolicyProvider(context);
retryPolicy = retryPolicyProvider.DEFAULT();
registrationSynchronizer = new RegistrationSynchronizer(context, mobileMessagingCore, stats, taskExecutor, coreBroadcaster, retryPolicyProvider, mobileApiRegistration);
seenStatusReporter = new SeenStatusReporter(mobileMessagingCore, stats, taskExecutor, coreBroadcaster, mobileApiMessages, new BatchReporter(100L));
geoReporter = new GeoReporter(context, mobileMessagingCore, geoBroadcaster, mobileMessagingCore.getStats(), mobileApiGeo);
messagesSynchronizer = new MessagesSynchronizer(mobileMessagingCore, stats, taskExecutor, coreBroadcaster, retryPolicy, mobileMessageHandler, mobileApiMessages);
captor = ArgumentCaptor.forClass(Boolean.class);
}
Aggregations