NotificationMessageDecorator extends HaloNotificationDecorator { @Override public NotificationCompat.Builder decorate(@NonNull NotificationCompat.Builder builder, @NonNull Bundle bundle) { String message = bundle.getString("body"); if (!TextUtils.isEmpty(message)) { builder.setContentText(message); } return chain(builder, bundle); } NotificationMessageDecorator(HaloNotificationDecorator decorator); @Override NotificationCompat.Builder decorate(@NonNull NotificationCompat.Builder builder, @NonNull Bundle bundle);  }
@Test public void messageTest() { final boolean[] marker = new boolean[1]; final String text = "This is my Text"; Bundle bundle = BundleTestUtils.builder().putString("body", text).build(); when(getBuilder().setContentText(any(String.class))).then(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { marker[0] = true; Assert.assertEquals(text, invocation.getArguments()[0]); return null; } }); getDecorator().decorate(getBuilder(), bundle); Assert.assertTrue(marker[0]); }
@Test public void emptyMessageTest() { final boolean[] marker = new boolean[1]; Bundle bundle = BundleTestUtils.builder().build(); when(getBuilder().setContentText(any(String.class))).then(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { marker[0] = true; return null; } }); getDecorator().decorate(getBuilder(), bundle); Assert.assertFalse(marker[0]); }