urbanairship-core/src/test/java/com/urbanairship/CoreReceiverTest.java
@Test
    public void testOnNotificationButtonOpenedProxy() {
        // Create the push message with the matching send ID
        Bundle pushBundle = new Bundle();
        pushBundle.putString(PushMessage.EXTRA_SEND_ID, "sendId");
        PushMessage message = new PushMessage(pushBundle);

        // Create the intent
        final Intent intent = new Intent()
                .setAction(PushManager.ACTION_NOTIFICATION_BUTTON_OPENED_PROXY)
                .putExtra(PushManager.EXTRA_PUSH_MESSAGE_BUNDLE, message.getPushBundle())
                .putExtra(PushManager.EXTRA_NOTIFICATION_BUTTON_ID, "buttonId")
                .putExtra(PushManager.EXTRA_NOTIFICATION_ID, 150)
                .putExtra(PushManager.EXTRA_NOTIFICATION_BUTTON_FOREGROUND, true);

        receiver.onReceive(context, intent);

        // Verify the notification was dismissed
        verify(notificationManager).cancel(null, 150);

        // Verify the conversion send id was set
        verify(analytics).setConversionSendId("sendId");

        // Verify we added an interactive notification event
        verify(analytics).addEvent(any(InteractiveNotificationEvent.class));

        // Verify the ordered broadcast is sent to notify the apps intent receiver
        verify(context).sendOrderedBroadcast(argThat(new ArgumentMatcher<Intent>() {
            @Override
            public boolean matches(Intent other) {
                return PushManager.ACTION_NOTIFICATION_OPENED.equals(other.getAction()) &&
                        areEqual(intent.getExtras(), other.getExtras()) &&
                        UAirship.getPackageName().equals(other.getPackage()) &&
                        other.getCategories().contains(UAirship.getPackageName());
            }
        }), isNull(String.class));
    }
/**
     * Test open notification button proxy intent action.
     */
Test open notification button proxy intent action.
Test open notification button proxy intent action .
@Test
    public void testOnNotificationButtonOpenedProxy() {
        Bundle pushBundle = new Bundle();
        pushBundle.putString(PushMessage.EXTRA_SEND_ID, "sendId");
        PushMessage message = new PushMessage(pushBundle);
        final Intent intent = new Intent()
                .setAction(PushManager.ACTION_NOTIFICATION_BUTTON_OPENED_PROXY)
                .putExtra(PushManager.EXTRA_PUSH_MESSAGE_BUNDLE, message.getPushBundle())
                .putExtra(PushManager.EXTRA_NOTIFICATION_BUTTON_ID, "buttonId")
                .putExtra(PushManager.EXTRA_NOTIFICATION_ID, 150)
                .putExtra(PushManager.EXTRA_NOTIFICATION_BUTTON_FOREGROUND, true);
        receiver.onReceive(context, intent);
        verify(notificationManager).cancel(null, 150);
        verify(analytics).setConversionSendId("sendId");
        verify(analytics).addEvent(any(InteractiveNotificationEvent.class));
        verify(context).sendOrderedBroadcast(argThat(new ArgumentMatcher<Intent>() {
            @Override
            public boolean matches(Intent other) {
                return PushManager.ACTION_NOTIFICATION_OPENED.equals(other.getAction()) &&
                        areEqual(intent.getExtras(), other.getExtras()) &&
                        UAirship.getPackageName().equals(other.getPackage()) &&
                        other.getCategories().contains(UAirship.getPackageName());
            }
        }), isNull(String.class));
    }
@ Test public void testOnNotificationButtonOpenedProxy ( ) { Bundle pushBundle = new Bundle ( ) ; pushBundle . putString ( PushMessage . EXTRA_SEND_ID , "sendId" ) ; PushMessage message = new PushMessage ( pushBundle ) ; final Intent intent = new Intent ( ) . setAction ( PushManager . ACTION_NOTIFICATION_BUTTON_OPENED_PROXY ) . putExtra ( PushManager . EXTRA_PUSH_MESSAGE_BUNDLE , message . getPushBundle ( ) ) . putExtra ( PushManager . EXTRA_NOTIFICATION_BUTTON_ID , "buttonId" ) . putExtra ( PushManager . EXTRA_NOTIFICATION_ID , 150 ) . putExtra ( PushManager . EXTRA_NOTIFICATION_BUTTON_FOREGROUND , true ) ; receiver . onReceive ( context , intent ) ; verify ( notificationManager ) . cancel ( null , 150 ) ; verify ( analytics ) . setConversionSendId ( "sendId" ) ; verify ( analytics ) . addEvent ( any ( InteractiveNotificationEvent . class ) ) ; verify ( context ) . sendOrderedBroadcast ( argThat ( new ArgumentMatcher < Intent > ( ) { @ Override public boolean matches ( Intent other ) { return PushManager . ACTION_NOTIFICATION_OPENED . equals ( other . getAction ( ) ) && areEqual ( intent . getExtras ( ) , other . getExtras ( ) ) && UAirship . getPackageName ( ) . equals ( other . getPackage ( ) ) && other . getCategories ( ) . contains ( UAirship . getPackageName ( ) ) ; } } ) , isNull ( String . class ) ) ; }
Test open notification button proxy intent action.
Test open notification button proxy intent action .
// Create the push message with the matching send ID // Create the intent // Verify the notification was dismissed // Verify the conversion send id was set // Verify we added an interactive notification event // Verify the ordered broadcast is sent to notify the apps intent receiver