Search in sources :

Example 1 with NotificationHandler

use of org.infobip.mobile.messaging.notification.NotificationHandler in project mobile-messaging-sdk-android by infobip.

the class NotificationHandlerResolverTest method should_get_core_notification_handler_when_no_handlers_in_manifest.

@Test
public void should_get_core_notification_handler_when_no_handlers_in_manifest() throws InterruptedException {
    // Given
    given(moduleLoaderMock.loadModules(eq(NotificationHandler.class))).willReturn(new HashMap<String, NotificationHandler>());
    MobileMessagingCore givenCore = new MobileMessagingCore(context, new AndroidBroadcaster(context), Executors.newSingleThreadExecutor(), moduleLoaderMock);
    // When
    NotificationHandler notificationHandler = givenCore.getNotificationHandler();
    // Then
    assertTrue(notificationHandler instanceof CoreNotificationHandler);
}
Also used : CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler) MockNotificationHandler(org.infobip.mobile.messaging.notification.MockNotificationHandler) NotificationHandler(org.infobip.mobile.messaging.notification.NotificationHandler) CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler) AndroidBroadcaster(org.infobip.mobile.messaging.platform.AndroidBroadcaster) Test(org.junit.Test)

Example 2 with NotificationHandler

use of org.infobip.mobile.messaging.notification.NotificationHandler in project mobile-messaging-sdk-android by infobip.

the class NotificationHandlerResolverTest method should_get_test_notification_handler.

@Test
public void should_get_test_notification_handler() throws InterruptedException {
    // Given
    given(moduleLoaderMock.loadModules(eq(NotificationHandler.class))).willReturn(new HashMap<String, NotificationHandler>() {

        {
            put(MockNotificationHandler.class.getName(), new MockNotificationHandler());
        }
    });
    MobileMessagingCore givenCore = new MobileMessagingCore(context, new AndroidBroadcaster(context), Executors.newSingleThreadExecutor(), moduleLoaderMock);
    // When
    NotificationHandler notificationHandler = givenCore.getNotificationHandler();
    // Then
    assertFalse(notificationHandler instanceof CoreNotificationHandler);
    assertTrue(notificationHandler instanceof MockNotificationHandler);
}
Also used : CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler) MockNotificationHandler(org.infobip.mobile.messaging.notification.MockNotificationHandler) NotificationHandler(org.infobip.mobile.messaging.notification.NotificationHandler) CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler) AndroidBroadcaster(org.infobip.mobile.messaging.platform.AndroidBroadcaster) MockNotificationHandler(org.infobip.mobile.messaging.notification.MockNotificationHandler) Test(org.junit.Test)

Example 3 with NotificationHandler

use of org.infobip.mobile.messaging.notification.NotificationHandler 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 4 with NotificationHandler

use of org.infobip.mobile.messaging.notification.NotificationHandler in project mobile-messaging-sdk-android by infobip.

the class MobileMessagingGcmIntentService method mobileMessageHandler.

private MobileMessageHandler mobileMessageHandler() {
    if (mobileMessageHandler == null) {
        MobileMessagingCore mobileMessagingCore = MobileMessagingCore.getInstance(this);
        NotificationHandler notificationHandler = mobileMessagingCore.getNotificationHandler();
        mobileMessageHandler = new MobileMessageHandler(mobileMessagingCore, new AndroidBroadcaster(this), notificationHandler, mobileMessagingCore.getMessageStoreWrapper());
    }
    return mobileMessageHandler;
}
Also used : NotificationHandler(org.infobip.mobile.messaging.notification.NotificationHandler) AndroidBroadcaster(org.infobip.mobile.messaging.platform.AndroidBroadcaster) MobileMessagingCore(org.infobip.mobile.messaging.MobileMessagingCore)

Example 5 with NotificationHandler

use of org.infobip.mobile.messaging.notification.NotificationHandler in project mobile-messaging-sdk-android by infobip.

the class MobileMessagingCore method loadNotificationHandler.

private NotificationHandler loadNotificationHandler() {
    Map<String, NotificationHandler> handlers = moduleLoader.loadModules(NotificationHandler.class);
    NotificationHandler handler;
    if (!handlers.isEmpty()) {
        handler = handlers.values().iterator().next();
    } else {
        handler = new CoreNotificationHandler();
    }
    handler.setContext(context);
    return handler;
}
Also used : CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler) NotificationHandler(org.infobip.mobile.messaging.notification.NotificationHandler) CoreNotificationHandler(org.infobip.mobile.messaging.notification.CoreNotificationHandler)

Aggregations

NotificationHandler (org.infobip.mobile.messaging.notification.NotificationHandler)6 CoreNotificationHandler (org.infobip.mobile.messaging.notification.CoreNotificationHandler)3 AndroidBroadcaster (org.infobip.mobile.messaging.platform.AndroidBroadcaster)3 SuppressLint (android.annotation.SuppressLint)2 Context (android.content.Context)2 MobileApiMessages (org.infobip.mobile.messaging.api.messages.MobileApiMessages)2 MobileApiResourceProvider (org.infobip.mobile.messaging.mobile.MobileApiResourceProvider)2 MockNotificationHandler (org.infobip.mobile.messaging.notification.MockNotificationHandler)2 Broadcaster (org.infobip.mobile.messaging.platform.Broadcaster)2 Before (org.junit.Before)2 Test (org.junit.Test)2 MobileMessagingCore (org.infobip.mobile.messaging.MobileMessagingCore)1 MobileApiData (org.infobip.mobile.messaging.api.data.MobileApiData)1 MobileApiRegistration (org.infobip.mobile.messaging.api.registration.MobileApiRegistration)1 GeofencingHelper (org.infobip.mobile.messaging.geo.geofencing.GeofencingHelper)1 GeoBroadcaster (org.infobip.mobile.messaging.geo.platform.GeoBroadcaster)1