Search in sources :

Example 1 with MobileApiMessages

use of org.infobip.mobile.messaging.api.messages.MobileApiMessages in project mobile-messaging-sdk-android by infobip.

the class SeenStatusReporterTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    batchReporter = new BatchReporter(100L);
    mobileApiMessages = mock(MobileApiMessages.class);
    executor = newSingleThreadExecutor();
    MobileMessagingStats stats = mobileMessagingCore.getStats();
    executor = mock(Executor.class);
    seenStatusReporter = new SeenStatusReporter(mobileMessagingCore, stats, executor, broadcaster, mobileApiMessages, batchReporter);
}
Also used : MobileMessagingStats(org.infobip.mobile.messaging.stats.MobileMessagingStats) Executor(java.util.concurrent.Executor) Executors.newSingleThreadExecutor(java.util.concurrent.Executors.newSingleThreadExecutor) BatchReporter(org.infobip.mobile.messaging.mobile.BatchReporter) MobileApiMessages(org.infobip.mobile.messaging.api.messages.MobileApiMessages) SeenStatusReporter(org.infobip.mobile.messaging.mobile.seen.SeenStatusReporter)

Example 2 with MobileApiMessages

use of org.infobip.mobile.messaging.api.messages.MobileApiMessages in project mobile-messaging-sdk-android by infobip.

the class MobileMessagingTestCase method setUp.

@SuppressLint("ApplySharedPref")
@Before
public void setUp() throws Exception {
    super.setUp();
    PreferenceManager.getDefaultSharedPreferences(context).edit().clear().commit();
    PreferenceHelper.saveString(context, MobileMessagingProperty.API_URI, "http://127.0.0.1:" + debugServer.getListeningPort() + "/");
    PreferenceHelper.saveString(context, MobileMessagingProperty.APPLICATION_CODE, "TestApplicationCode");
    PreferenceHelper.saveString(context, MobileMessagingProperty.INFOBIP_REGISTRATION_ID, "TestDeviceInstanceId");
    PreferenceHelper.saveString(context, MobileMessagingProperty.GCM_REGISTRATION_ID, "TestRegistrationId");
    PreferenceHelper.saveBoolean(context, MobileMessagingProperty.GCM_REGISTRATION_ID_REPORTED, true);
    MobileMessagingLogger.enforce();
    time = new TestTimeProvider();
    Time.reset(time);
    MobileApiResourceProvider mobileApiResourceProvider = mock(MobileApiResourceProvider.class);
    mobileApiMessages = mock(MobileApiMessages.class);
    mobileApiData = mock(MobileApiData.class);
    given(mobileApiResourceProvider.getMobileApiMessages(any(Context.class))).willReturn(mobileApiMessages);
    given(mobileApiResourceProvider.getMobileApiData(any(Context.class))).willReturn(mobileApiData);
    notificationHandler = mock(NotificationHandler.class);
    broadcaster = mock(Broadcaster.class);
    mobileMessagingCore = MobileMessagingTestable.create(context, broadcaster, mobileApiResourceProvider);
    mobileMessaging = mobileMessagingCore;
    databaseHelper = MobileMessagingCore.getDatabaseHelper(context);
    databaseProvider = MobileMessagingCore.getDatabaseProvider(context);
}
Also used : Context(android.content.Context) MobileApiResourceProvider(org.infobip.mobile.messaging.mobile.MobileApiResourceProvider) NotificationHandler(org.infobip.mobile.messaging.notification.NotificationHandler) MobileApiMessages(org.infobip.mobile.messaging.api.messages.MobileApiMessages) Broadcaster(org.infobip.mobile.messaging.platform.Broadcaster) MobileApiData(org.infobip.mobile.messaging.api.data.MobileApiData) Before(org.junit.Before) SuppressLint(android.annotation.SuppressLint)

Example 3 with MobileApiMessages

use of org.infobip.mobile.messaging.api.messages.MobileApiMessages 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 4 with MobileApiMessages

use of org.infobip.mobile.messaging.api.messages.MobileApiMessages in project mobile-messaging-sdk-android by infobip.

the class MobileApiMessagesTest method setUp.

@Before
public void setUp() throws Exception {
    debugServer = new DebugServer();
    debugServer.start();
    Properties properties = new Properties();
    properties.put("api.key", "my_API_key");
    Generator generator = new Generator.Builder().withBaseUrl("http://127.0.0.1:" + debugServer.getListeningPort() + "/").withProperties(properties).build();
    mobileApiMessages = generator.create(MobileApiMessages.class);
}
Also used : DebugServer(org.infobip.mobile.messaging.api.tools.DebugServer) MobileApiMessages(org.infobip.mobile.messaging.api.messages.MobileApiMessages) Properties(java.util.Properties) Generator(org.infobip.mobile.messaging.api.support.Generator) Before(org.junit.Before)

Example 5 with MobileApiMessages

use of org.infobip.mobile.messaging.api.messages.MobileApiMessages in project mobile-messaging-sdk-android by infobip.

the class MobileMessagingTestCase method setUp.

@SuppressLint("ApplySharedPref")
@Before
public void setUp() throws Exception {
    super.setUp();
    PreferenceManager.getDefaultSharedPreferences(context).edit().clear().commit();
    PreferenceHelper.saveString(context, MobileMessagingProperty.API_URI, "http://127.0.0.1:" + debugServer.getListeningPort() + "/");
    PreferenceHelper.saveString(context, MobileMessagingProperty.APPLICATION_CODE, "TestApplicationCode");
    PreferenceHelper.saveString(context, MobileMessagingProperty.INFOBIP_REGISTRATION_ID, "TestDeviceInstanceId");
    PreferenceHelper.saveString(context, MobileMessagingProperty.GCM_REGISTRATION_ID, "TestRegistrationId");
    PreferenceHelper.saveBoolean(context, MobileMessagingProperty.GCM_REGISTRATION_ID_REPORTED, true);
    MobileMessagingLogger.enforce();
    time = new TestTimeProvider();
    Time.reset(time);
    notificationHandler = mock(NotificationHandler.class);
    coreBroadcaster = mock(Broadcaster.class);
    mobileApiMessages = mock(MobileApiMessages.class);
    mobileApiRegistration = mock(MobileApiRegistration.class);
    mobileApiResourceProvider = mock(MobileApiResourceProvider.class);
    given(mobileApiResourceProvider.getMobileApiMessages(any(Context.class))).willReturn(mobileApiMessages);
    given(mobileApiResourceProvider.getMobileApiRegistration(any(Context.class))).willReturn(mobileApiRegistration);
    mobileMessagingCore = MobileMessagingTestable.create(context, coreBroadcaster, mobileApiResourceProvider);
    mobileMessaging = mobileMessagingCore;
    geofencingHelper = new GeofencingHelper(context);
    geoBroadcaster = mock(GeoBroadcaster.class);
    geofencingHelper.removeUnreportedGeoEvents();
    databaseHelper = MobileMessagingCore.getDatabaseHelper(context);
    databaseProvider = MobileMessagingCore.getDatabaseProvider(context);
    geoStore = geofencingHelper.getMessageStoreForGeo();
}
Also used : Context(android.content.Context) MobileApiResourceProvider(org.infobip.mobile.messaging.mobile.MobileApiResourceProvider) GeofencingHelper(org.infobip.mobile.messaging.geo.geofencing.GeofencingHelper) GeoBroadcaster(org.infobip.mobile.messaging.geo.platform.GeoBroadcaster) NotificationHandler(org.infobip.mobile.messaging.notification.NotificationHandler) Broadcaster(org.infobip.mobile.messaging.platform.Broadcaster) GeoBroadcaster(org.infobip.mobile.messaging.geo.platform.GeoBroadcaster) MobileApiMessages(org.infobip.mobile.messaging.api.messages.MobileApiMessages) MobileApiRegistration(org.infobip.mobile.messaging.api.registration.MobileApiRegistration) Before(org.junit.Before) SuppressLint(android.annotation.SuppressLint)

Aggregations

MobileApiMessages (org.infobip.mobile.messaging.api.messages.MobileApiMessages)6 SuppressLint (android.annotation.SuppressLint)4 MobileMessagingStats (org.infobip.mobile.messaging.stats.MobileMessagingStats)3 Before (org.junit.Before)3 Context (android.content.Context)2 MobileApiData (org.infobip.mobile.messaging.api.data.MobileApiData)2 MobileApiRegistration (org.infobip.mobile.messaging.api.registration.MobileApiRegistration)2 MobileMessageHandler (org.infobip.mobile.messaging.gcm.MobileMessageHandler)2 BatchReporter (org.infobip.mobile.messaging.mobile.BatchReporter)2 MobileApiResourceProvider (org.infobip.mobile.messaging.mobile.MobileApiResourceProvider)2 RetryPolicyProvider (org.infobip.mobile.messaging.mobile.common.RetryPolicyProvider)2 MessagesSynchronizer (org.infobip.mobile.messaging.mobile.messages.MessagesSynchronizer)2 RegistrationSynchronizer (org.infobip.mobile.messaging.mobile.registration.RegistrationSynchronizer)2 SeenStatusReporter (org.infobip.mobile.messaging.mobile.seen.SeenStatusReporter)2 NotificationHandler (org.infobip.mobile.messaging.notification.NotificationHandler)2 Broadcaster (org.infobip.mobile.messaging.platform.Broadcaster)2 Properties (java.util.Properties)1 Executor (java.util.concurrent.Executor)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors.newSingleThreadExecutor (java.util.concurrent.Executors.newSingleThreadExecutor)1