NotificationListAddition extends UpdateValue.Update<NotificationListObject> { @Override public NotificationListObject apply(@Nullable NotificationListObject original) { if (original == null) { LOGGER.debug("original is null, creating new notification list"); original = new NotificationListObject(); } original.addNotification(notification); return original; } NotificationListAddition(final Notification notification); @Override NotificationListObject apply(@Nullable NotificationListObject original);  }
@Test public void testAddsToNotification() { final Notification notification = Notification.create("1"); final NotificationListAddition update = new NotificationListAddition(notification); final NotificationListObject original = new NotificationListObject(); final NotificationListObject expected = new NotificationListObject(); expected.addNotification(notification); final NotificationListObject actual = update.apply(original); assertThat(actual).isEqualTo(expected); }
@Test public void testNoOriginal() { final Notification notification = Notification.create("1"); final NotificationListAddition update = new NotificationListAddition(notification); final NotificationListObject expected = new NotificationListObject(); expected.addNotification(notification); final NotificationListObject actual = update.apply(null); assertThat(actual).isEqualTo(expected); }