urbanairship-core/src/test/java/com/urbanairship/push/IncomingPushRunnableTest.java
@Test
    public void testDisplayNotification() {
        when(pushManager.isComponentEnabled()).thenReturn(true);
        when(pushManager.isPushEnabled()).thenReturn(true);
        when(pushManager.isOptIn()).thenReturn(true);
        when(pushManager.isUniqueCanonicalId("testPushID")).thenReturn(true);

        pushRunnable.run();

        verify(notificationManager).notify("testNotificationTag", TEST_NOTIFICATION_ID, notification);
        verify(analytics).addEvent(any(PushArrivedEvent.class));

        ShadowPendingIntent shadowPendingIntent = Shadows.shadowOf(notification.contentIntent);
        assertTrue("The pending intent is broadcast intent.", shadowPendingIntent.isBroadcastIntent());

        Intent intent = shadowPendingIntent.getSavedIntent();
        assertEquals("The intent action should match.", intent.getAction(), PushManager.ACTION_NOTIFICATION_OPENED_PROXY);
        assertBundlesEquals("The push message bundles should match.", pushBundle, intent.getExtras().getBundle(PushManager.EXTRA_PUSH_MESSAGE_BUNDLE));
        assertEquals("One category should exist.", 1, intent.getCategories().size());
    }
/**
     * Test displaying a notification from a push message.
     */
Test displaying a notification from a push message.
Test displaying a notification from a push message .
@Test
    public void testDisplayNotification() {
        when(pushManager.isComponentEnabled()).thenReturn(true);
        when(pushManager.isPushEnabled()).thenReturn(true);
        when(pushManager.isOptIn()).thenReturn(true);
        when(pushManager.isUniqueCanonicalId("testPushID")).thenReturn(true);
        pushRunnable.run();
        verify(notificationManager).notify("testNotificationTag", TEST_NOTIFICATION_ID, notification);
        verify(analytics).addEvent(any(PushArrivedEvent.class));
        ShadowPendingIntent shadowPendingIntent = Shadows.shadowOf(notification.contentIntent);
        assertTrue("The pending intent is broadcast intent.", shadowPendingIntent.isBroadcastIntent());
        Intent intent = shadowPendingIntent.getSavedIntent();
        assertEquals("The intent action should match.", intent.getAction(), PushManager.ACTION_NOTIFICATION_OPENED_PROXY);
        assertBundlesEquals("The push message bundles should match.", pushBundle, intent.getExtras().getBundle(PushManager.EXTRA_PUSH_MESSAGE_BUNDLE));
        assertEquals("One category should exist.", 1, intent.getCategories().size());
    }
@ Test public void testDisplayNotification ( ) { when ( pushManager . isComponentEnabled ( ) ) . thenReturn ( true ) ; when ( pushManager . isPushEnabled ( ) ) . thenReturn ( true ) ; when ( pushManager . isOptIn ( ) ) . thenReturn ( true ) ; when ( pushManager . isUniqueCanonicalId ( "testPushID" ) ) . thenReturn ( true ) ; pushRunnable . run ( ) ; verify ( notificationManager ) . notify ( "testNotificationTag" , TEST_NOTIFICATION_ID , notification ) ; verify ( analytics ) . addEvent ( any ( PushArrivedEvent . class ) ) ; ShadowPendingIntent shadowPendingIntent = Shadows . shadowOf ( notification . contentIntent ) ; assertTrue ( "The pending intent is broadcast intent." , shadowPendingIntent . isBroadcastIntent ( ) ) ; Intent intent = shadowPendingIntent . getSavedIntent ( ) ; assertEquals ( "The intent action should match." , intent . getAction ( ) , PushManager . ACTION_NOTIFICATION_OPENED_PROXY ) ; assertBundlesEquals ( "The push message bundles should match." , pushBundle , intent . getExtras ( ) . getBundle ( PushManager . EXTRA_PUSH_MESSAGE_BUNDLE ) ) ; assertEquals ( "One category should exist." , 1 , intent . getCategories ( ) . size ( ) ) ; }
Test displaying a notification from a push message.
Test displaying a notification from a push message .