### Question:
HistoryList { public void goBack() { if (historyIndex == 0) { return; } T leaving = getCurrentHistoryItem(); T t = historyStack.get(--historyIndex); dropNull(); broadcast(t, leaving); } HistoryList(int size, Consumer<T> itemSelectedCallback);  HistoryList(int size, BiConsumer<T, T> itemSelectedCallback); void setAllowDuplicates(boolean allowDuplicates); void setAllowNulls(boolean allowNulls); void add(T t); boolean hasNext(); boolean hasPrevious(); void goBack(); void goBackTo(T t); void goForward(); void goForwardTo(T t); T getCurrentHistoryItem(); List<T> getPreviousHistoryItems(); List<T> getNextHistoryItems(); void clear(); int size(); @Override String toString();  }### Answer:
@Test public void testAddingNewItem_AtBeginningOfStack() { addHistory(A); addHistory(B); addHistory(C); addHistory(D); goBack(); assertNotified(C); goBack(); assertNotified(B); goBack(); assertNotified(A); assertCannotGoBack(); assertCanGoForward(); addHistory(E); assertCanGoBack(); assertCannotGoForward(); assertHistory(A, E); }
@Test public void testAddingNewItem_AtMiddleOfStack() { addHistory(A); addHistory(B); addHistory(C); addHistory(D); goBack(); assertNotified(C); assertCanGoBack(); assertCanGoForward(); addHistory(E); assertCanGoBack(); assertCannotGoForward(); assertHistory(A, B, C, E); }
@Test public void testNavigationMixedWithHistoryAddition() { addHistory(A); addHistory(B); assertHistory(A, B); goBack(); assertHistory(A, B); addHistory(C); assertHistory(A, C); addHistory(A); assertHistory(C, A); }
@Test public void testRepeatedAdds_WhenInMiddleOfHistory_NoChanges() { addHistory(A); addHistory(B); addHistory(C); assertHistory(A, B, C); goBack(); assertHistory(A, B, C); assertNotified(B); addHistory(B); assertHistory(A, B, C); assertNotified(B); }