NotificationLedDecorator extends HaloNotificationDecorator { @Override public NotificationCompat.Builder decorate(@NonNull NotificationCompat.Builder builder, @NonNull Bundle bundle) { String color = bundle.getString("color"); if (!TextUtils.isEmpty(color)) { builder.setLights(HaloUtils.getArgb(color), ON_TIME, OFF_TIME); } return chain(builder, bundle); } NotificationLedDecorator(HaloNotificationDecorator decorator); @Override NotificationCompat.Builder decorate(@NonNull NotificationCompat.Builder builder, @NonNull Bundle bundle);  }
@Test public void addLedColorTest() { final boolean[] marker = new boolean[1]; Bundle bundle = BundleTestUtils.builder().putString("color", "#00000000").build(); when(getBuilder().setLights(any(Integer.class), eq(NotificationLedDecorator.ON_TIME), eq(NotificationLedDecorator.OFF_TIME))).then(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { Assert.assertEquals(0, invocation.getArguments()[0]); marker[0] = true; return null; } }); getDecorator().decorate(getBuilder(), bundle); Assert.assertTrue(marker[0]); }
@Test public void noLedColorSetTest() { final boolean[] marker = new boolean[1]; Bundle bundle = BundleTestUtils.builder().build(); when(getBuilder().setLights(any(Integer.class), eq(NotificationLedDecorator.ON_TIME), eq(NotificationLedDecorator.OFF_TIME))).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]); }