Search in sources :

Example 1 with MessagesSynchronizer

use of org.infobip.mobile.messaging.mobile.messages.MessagesSynchronizer 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);
}
Also used : MessagesSynchronizer(org.infobip.mobile.messaging.mobile.messages.MessagesSynchronizer) ApiIOException(org.infobip.mobile.messaging.api.support.ApiIOException) MobileApiData(org.infobip.mobile.messaging.api.data.MobileApiData) MobileApiRegistration(org.infobip.mobile.messaging.api.registration.MobileApiRegistration) SystemDataReport(org.infobip.mobile.messaging.api.data.SystemDataReport) MobileMessageHandler(org.infobip.mobile.messaging.gcm.MobileMessageHandler) MobileMessagingStats(org.infobip.mobile.messaging.stats.MobileMessagingStats) RetryPolicyProvider(org.infobip.mobile.messaging.mobile.common.RetryPolicyProvider) SyncMessagesBody(org.infobip.mobile.messaging.api.messages.SyncMessagesBody) MobileApiMessages(org.infobip.mobile.messaging.api.messages.MobileApiMessages) UserDataReport(org.infobip.mobile.messaging.api.data.UserDataReport) UserDataReporter(org.infobip.mobile.messaging.mobile.data.UserDataReporter) SystemDataReporter(org.infobip.mobile.messaging.mobile.data.SystemDataReporter) RegistrationSynchronizer(org.infobip.mobile.messaging.mobile.registration.RegistrationSynchronizer) BackendCommunicationException(org.infobip.mobile.messaging.mobile.common.exceptions.BackendCommunicationException) SuppressLint(android.annotation.SuppressLint)

Example 2 with MessagesSynchronizer

use of org.infobip.mobile.messaging.mobile.messages.MessagesSynchronizer 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;
}
Also used : MobileMessageHandler(org.infobip.mobile.messaging.gcm.MobileMessageHandler) MessagesSynchronizer(org.infobip.mobile.messaging.mobile.messages.MessagesSynchronizer) NonNull(android.support.annotation.NonNull)

Example 3 with MessagesSynchronizer

use of org.infobip.mobile.messaging.mobile.messages.MessagesSynchronizer 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);
}
Also used : MobileMessageHandler(org.infobip.mobile.messaging.gcm.MobileMessageHandler) MobileMessagingStats(org.infobip.mobile.messaging.stats.MobileMessagingStats) RetryPolicyProvider(org.infobip.mobile.messaging.mobile.common.RetryPolicyProvider) ExecutorService(java.util.concurrent.ExecutorService) MobileApiGeo(org.infobip.mobile.messaging.api.geo.MobileApiGeo) BatchReporter(org.infobip.mobile.messaging.mobile.BatchReporter) MessagesSynchronizer(org.infobip.mobile.messaging.mobile.messages.MessagesSynchronizer) MobileApiMessages(org.infobip.mobile.messaging.api.messages.MobileApiMessages) GeoReporter(org.infobip.mobile.messaging.geo.report.GeoReporter) Matchers.anyBoolean(org.mockito.Matchers.anyBoolean) RegistrationSynchronizer(org.infobip.mobile.messaging.mobile.registration.RegistrationSynchronizer) SeenStatusReporter(org.infobip.mobile.messaging.mobile.seen.SeenStatusReporter) SuppressLint(android.annotation.SuppressLint)

Aggregations

MobileMessageHandler (org.infobip.mobile.messaging.gcm.MobileMessageHandler)3 MessagesSynchronizer (org.infobip.mobile.messaging.mobile.messages.MessagesSynchronizer)3 SuppressLint (android.annotation.SuppressLint)2 MobileApiMessages (org.infobip.mobile.messaging.api.messages.MobileApiMessages)2 RetryPolicyProvider (org.infobip.mobile.messaging.mobile.common.RetryPolicyProvider)2 RegistrationSynchronizer (org.infobip.mobile.messaging.mobile.registration.RegistrationSynchronizer)2 MobileMessagingStats (org.infobip.mobile.messaging.stats.MobileMessagingStats)2 NonNull (android.support.annotation.NonNull)1 ExecutorService (java.util.concurrent.ExecutorService)1 MobileApiData (org.infobip.mobile.messaging.api.data.MobileApiData)1 SystemDataReport (org.infobip.mobile.messaging.api.data.SystemDataReport)1 UserDataReport (org.infobip.mobile.messaging.api.data.UserDataReport)1 MobileApiGeo (org.infobip.mobile.messaging.api.geo.MobileApiGeo)1 SyncMessagesBody (org.infobip.mobile.messaging.api.messages.SyncMessagesBody)1 MobileApiRegistration (org.infobip.mobile.messaging.api.registration.MobileApiRegistration)1 ApiIOException (org.infobip.mobile.messaging.api.support.ApiIOException)1 GeoReporter (org.infobip.mobile.messaging.geo.report.GeoReporter)1 BatchReporter (org.infobip.mobile.messaging.mobile.BatchReporter)1 BackendCommunicationException (org.infobip.mobile.messaging.mobile.common.exceptions.BackendCommunicationException)1 SystemDataReporter (org.infobip.mobile.messaging.mobile.data.SystemDataReporter)1