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

        pushRunnable.run();

        ShadowApplication shadowApplication = Shadows.shadowOf(RuntimeEnvironment.application);
        List<Intent> intents = shadowApplication.getBroadcastIntents();
        Intent i = intents.get(intents.size() - 1);

        PushMessage push = PushMessage.fromIntent(i);
        assertEquals("Intent action should be push received", i.getAction(), PushManager.ACTION_PUSH_RECEIVED);
        assertEquals("Push ID should equal pushMessage ID", "testPushID", push.getCanonicalPushId());
        assertEquals("No notification ID should be present", -1, i.getIntExtra(PushManager.EXTRA_NOTIFICATION_ID, -1));
    }
/**
     * Test handling a background push.
     */
Test handling a background push.
Test handling a background push .
@Test
    public void testBackgroundPush() {
        notification = null;
        when(pushManager.isComponentEnabled()).thenReturn(true);
        when(pushManager.isPushEnabled()).thenReturn(true);
        when(pushManager.isOptIn()).thenReturn(true);
        when(pushManager.isUniqueCanonicalId("testPushID")).thenReturn(true);
        pushRunnable.run();
        ShadowApplication shadowApplication = Shadows.shadowOf(RuntimeEnvironment.application);
        List<Intent> intents = shadowApplication.getBroadcastIntents();
        Intent i = intents.get(intents.size() - 1);
        PushMessage push = PushMessage.fromIntent(i);
        assertEquals("Intent action should be push received", i.getAction(), PushManager.ACTION_PUSH_RECEIVED);
        assertEquals("Push ID should equal pushMessage ID", "testPushID", push.getCanonicalPushId());
        assertEquals("No notification ID should be present", -1, i.getIntExtra(PushManager.EXTRA_NOTIFICATION_ID, -1));
    }
@ Test public void testBackgroundPush ( ) { notification = null ; when ( pushManager . isComponentEnabled ( ) ) . thenReturn ( true ) ; when ( pushManager . isPushEnabled ( ) ) . thenReturn ( true ) ; when ( pushManager . isOptIn ( ) ) . thenReturn ( true ) ; when ( pushManager . isUniqueCanonicalId ( "testPushID" ) ) . thenReturn ( true ) ; pushRunnable . run ( ) ; ShadowApplication shadowApplication = Shadows . shadowOf ( RuntimeEnvironment . application ) ; List < Intent > intents = shadowApplication . getBroadcastIntents ( ) ; Intent i = intents . get ( intents . size ( ) - 1 ) ; PushMessage push = PushMessage . fromIntent ( i ) ; assertEquals ( "Intent action should be push received" , i . getAction ( ) , PushManager . ACTION_PUSH_RECEIVED ) ; assertEquals ( "Push ID should equal pushMessage ID" , "testPushID" , push . getCanonicalPushId ( ) ) ; assertEquals ( "No notification ID should be present" , - 1 , i . getIntExtra ( PushManager . EXTRA_NOTIFICATION_ID , - 1 ) ) ; }
Test handling a background push.
Test handling a background push .