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

        final int notificationId = 0;
        final Notification notification = notificationFactory.createNotification(new PushMessage(pushBundle), notificationId);

        notificationFactory = new NotificationFactory(TestApplication.getApplication()) {
            @Override
            public NotificationFactory.Result createNotificationResult(@NonNull PushMessage pushMessage, int notificationId) {
                return NotificationFactory.Result.notification(notification);
            }

            @Override
            public int getNextId(@NonNull PushMessage pushMessage) {
                return notificationId;
            }
        };

        displayRunnable.run();

        verify(notificationManager).notify(Mockito.anyString(), Mockito.eq(notificationId), Mockito.eq(notification));
        verify(jobDispatcher, Mockito.never()).dispatch(any(JobInfo.class));
    }
/**
     * Test that when the factory returns a successful result, a notification is posted and no jobs are scheduled.
     */
Test that when the factory returns a successful result, a notification is posted and no jobs are scheduled.
Test that when the factory returns a successful result a notification is posted and no jobs are scheduled .
@Test
    public void testNotificationFactoryResultOK() {
        when(pushManager.isComponentEnabled()).thenReturn(true);
        when(pushManager.isPushEnabled()).thenReturn(true);
        when(pushManager.isOptIn()).thenReturn(true);
        when(pushManager.isUniqueCanonicalId("testPushID")).thenReturn(true);
        final int notificationId = 0;
        final Notification notification = notificationFactory.createNotification(new PushMessage(pushBundle), notificationId);
        notificationFactory = new NotificationFactory(TestApplication.getApplication()) {
            @Override
            public NotificationFactory.Result createNotificationResult(@NonNull PushMessage pushMessage, int notificationId) {
                return NotificationFactory.Result.notification(notification);
            }
            @Override
            public int getNextId(@NonNull PushMessage pushMessage) {
                return notificationId;
            }
        };
        displayRunnable.run();
        verify(notificationManager).notify(Mockito.anyString(), Mockito.eq(notificationId), Mockito.eq(notification));
        verify(jobDispatcher, Mockito.never()).dispatch(any(JobInfo.class));
    }
@ Test public void testNotificationFactoryResultOK ( ) { when ( pushManager . isComponentEnabled ( ) ) . thenReturn ( true ) ; when ( pushManager . isPushEnabled ( ) ) . thenReturn ( true ) ; when ( pushManager . isOptIn ( ) ) . thenReturn ( true ) ; when ( pushManager . isUniqueCanonicalId ( "testPushID" ) ) . thenReturn ( true ) ; final int notificationId = 0 ; final Notification notification = notificationFactory . createNotification ( new PushMessage ( pushBundle ) , notificationId ) ; notificationFactory = new NotificationFactory ( TestApplication . getApplication ( ) ) { @ Override public NotificationFactory . Result createNotificationResult ( @ NonNull PushMessage pushMessage , int notificationId ) { return NotificationFactory . Result . notification ( notification ) ; } @ Override public int getNextId ( @ NonNull PushMessage pushMessage ) { return notificationId ; } } ; displayRunnable . run ( ) ; verify ( notificationManager ) . notify ( Mockito . anyString ( ) , Mockito . eq ( notificationId ) , Mockito . eq ( notification ) ) ; verify ( jobDispatcher , Mockito . never ( ) ) . dispatch ( any ( JobInfo . class ) ) ; }
Test that when the factory returns a successful result, a notification is posted and no jobs are scheduled.
Test that when the factory returns a successful result a notification is posted and no jobs are scheduled .