AccengageNotificationProvider implements NotificationProvider { @NonNull @Override public NotificationResult onCreateNotification(@NonNull Context context, @NonNull NotificationArguments arguments) { AccengageMessage message = AccengageMessage.fromAirshipPushMessage(arguments.getMessage()); if (!message.getAccengageForeground() && GlobalActivityMonitor.shared(context).isAppForegrounded()) { Logger.debug("AccengageNotificationProvider - Received Accengage Push message but application was in foreground, skip it..."); return NotificationResult.cancel(); } Logger.debug("AccengageNotificationProvider - Push message received from Accengage, displaying notification..."); NotificationCompat.Builder builder = new NotificationCompat.Builder(context, arguments.getNotificationChannelId()) .extend(new AccengageNotificationExtender(context, message, arguments)); builder = onExtendBuilder(context, builder, message, arguments); Notification notification = builder.build(); return NotificationResult.notification(notification); }  @NonNull @Override NotificationArguments onCreateNotificationArguments(@NonNull Context context, @NonNull PushMessage message); @NonNull @Override NotificationResult onCreateNotification(@NonNull Context context, @NonNull NotificationArguments arguments); @Override void onNotificationCreated(@NonNull Context context, @NonNull Notification notification, @NonNull NotificationArguments arguments);  }
@Test public void testOnCreateNotification() { Application application = ApplicationProvider.getApplicationContext(); Context context = Mockito.spy(application); Bundle extras = new Bundle(); extras.putString("a4scontent", "accengageContent"); extras.putInt("a4ssysid", 77); extras.putString("a4stitle", "title test"); extras.putString("a4sforeground", "true"); PushMessage pushMessage = new PushMessage(extras); AccengageMessage message = AccengageMessage.fromAirshipPushMessage(pushMessage); AccengageNotificationProvider accengageNotificationProvider = new AccengageNotificationProvider(); NotificationArguments arguments = accengageNotificationProvider.onCreateNotificationArguments(context, pushMessage); NotificationResult result = accengageNotificationProvider.onCreateNotification(context, arguments); Notification notification = result.getNotification(); Assert.assertEquals("com.urbanairship.default", arguments.getNotificationChannelId()); Assert.assertEquals(77, arguments.getNotificationId()); Assert.assertEquals("title test", String.valueOf(notification.extras.getCharSequence("android.title"))); Assert.assertEquals("accengageContent", String.valueOf(notification.extras.getCharSequence("android.text"))); }