### Question:
AppUtils { @SuppressWarnings("unchecked") public void addNotification(final RedirectAttributes redirectAttributes, final Notification notification) { List<Notification> notifications = new LinkedList<>(); if (redirectAttributes.getFlashAttributes().containsKey(NOTIFICATION_LIST_ATTRIBUTE)) { notifications = (List<Notification>) redirectAttributes.getFlashAttributes() .get(NOTIFICATION_LIST_ATTRIBUTE); } notifications.add(notification); redirectAttributes.addFlashAttribute(NOTIFICATION_LIST_ATTRIBUTE, notifications); }  List<String> getModelErrors(final BindingResult bindingResult, final String... excludedFields); void setCurrentPage(final Model model, final String currentPage); @SuppressWarnings("unchecked") void addNotification(final RedirectAttributes redirectAttributes, final Notification notification); List<String> getUnexpectedErrorMessageAsList(); String getUnexpectedErrorMessage(); List<String> getMessages(final String... messageKeys); String getMessage(final String messageKey); String getReturnUrl(final String url, final String fallback); String getLocalUrl(final HttpServletRequest request);  }### Answer:
@Test public void test_addNotification_withEmptyList() { final Notification notification = new Notification(NotificationType.INFO, "message"); appUtils.addNotification(redirectAttributes, notification); verify(redirectAttributes).addFlashAttribute(eq(NOTIFICATION_LIST_ATTRIBUTE), notificationListCaptor.capture()); assertEquals(1, notificationListCaptor.getValue().size()); assertTrue(notificationListCaptor.getValue().contains(notification)); }
@Test public void test_addNotification_withNonEmptyList() { final Notification newNotification = new Notification(NotificationType.INFO, "message"); final Notification currentNotification = new Notification(NotificationType.INFO, "other message"); flashAttributes.put(NOTIFICATION_LIST_ATTRIBUTE, new LinkedList<>(Arrays.asList(currentNotification))); appUtils.addNotification(redirectAttributes, newNotification); verify(redirectAttributes).addFlashAttribute(eq(NOTIFICATION_LIST_ATTRIBUTE), notificationListCaptor.capture()); assertEquals(2, notificationListCaptor.getValue().size()); assertTrue(notificationListCaptor.getValue().contains(newNotification)); assertTrue(notificationListCaptor.getValue().contains(currentNotification)); }