AccengageNotificationExtender implements NotificationCompat.Extender { @NonNull @Override public NotificationCompat.Builder extend(@NonNull NotificationCompat.Builder builder) { setCommonFields(builder); boolean isCollapsedFieldsSet = false; if (message.getAccengageTemplateId(context) != 0) { setCustomCollapsedFields(builder); } else { setCollapsedFields(builder); isCollapsedFieldsSet = true; } if (message.getAccengageBigTemplateId(context) != 0) { setCustomExpandedFields(builder); } else { if (!isCollapsedFieldsSet) { setCollapsedFields(builder); } setExpandedFields(builder); } return builder; } AccengageNotificationExtender(@NonNull Context context, @NonNull AccengageMessage message, @NonNull NotificationArguments arguments); @NonNull @Override NotificationCompat.Builder extend(@NonNull NotificationCompat.Builder builder);  }
@Test public void testExtend() { Application application = ApplicationProvider.getApplicationContext(); Context context = Mockito.spy(application); Bundle extras = new Bundle(); extras.putString("a4saccentcolor", "#FF0000"); extras.putString("a4scategory", "general"); extras.putString("a4scontent", "accengageContent"); extras.putString("a4sbigcontenthtml", "bigAccengageContentHtml"); extras.putString("a4stitle", "title test"); extras.putString("a4sgroup", "general"); extras.putString("a4sgroupsummary", "generalsummary"); extras.putString("a4sbigtemplate", "BigTextStyle"); extras.putInt("a4spriority", 3); extras.putBoolean("a4smultiplelines", true); PushMessage pushMessage = new PushMessage(extras); AccengageMessage message = AccengageMessage.fromAirshipPushMessage(pushMessage); NotificationArguments.Builder naBuilder = NotificationArguments.newBuilder(pushMessage); NotificationArguments arguments = naBuilder .setNotificationId("",77) .setNotificationChannelId("id") .build(); AccengageNotificationExtender accengageNotificationExtender = new AccengageNotificationExtender(context, message, arguments); NotificationCompat.Builder builder = new NotificationCompat.Builder(context, "acc_channel_general") .setCategory(message.getAccengageCategory()) .setGroup(message.getAccengageGroup()) .setGroupSummary(message.getAccengageGroupSummary()) .setPriority(message.getAccengagePriority()) .setLights(0xFFFFFFFF, 1000, 3000) .setAutoCancel(true); builder = accengageNotificationExtender.extend(builder); Notification notification = builder.build(); String notificationTitle = String.valueOf(notification.extras.getCharSequence("android.title")); String notificationContent = String.valueOf(notification.extras.getCharSequence("android.text")); String notificationBigContent = String.valueOf(notification.extras.getCharSequence("android.bigText")); String notificationTickerText = String.valueOf(notification.tickerText); Assert.assertEquals("title test", notificationTitle); Assert.assertEquals("accengageContent", notificationContent); Assert.assertEquals("accengageContent", notificationTickerText); Assert.assertEquals(Color.parseColor("#FF0000"), notification.color); }