@Test
public void shouldThrowIllegalArgumentExceptionIfCallerSpecifiesIndexGreaterThanLastLogIndexInCallToGetNextCommitted() throws Exception {

    final LogEntry[] entries = new LogEntry[] {
            SENTINEL(),
            NOOP(1, 1),
            CLIENT(2, 1, new UnitTestCommand()),
            CLIENT(3, 1, new UnitTestCommand()),
            CLIENT(4, 1, new UnitTestCommand()),
            CLIENT(5, 1, new UnitTestCommand()),
            CLIENT(6, 1, new UnitTestCommand())  // <-- committed until here (i.e. _everything_ is committed)
    };
    final long currentTerm = 2;
    final long commitIndex = entries.length - 1;
    // setup the starting state
    insertIntoLog(entries);
    store.setCurrentTerm(currentTerm);
    store.setCommitIndex(commitIndex);
    //
    // situation is as follows:
    //
    //                                    +----------- COMMITTED
    //                                    V
    //   ------------------------------------
    //   | 00 | 01 | 02 | 03 | 04 | 05 | 06 | (LOG)
    //   -----------------------------------
    //                                         ^
    //                                         +----------- INDEX TO SEARCH FROM = 7
    //
    IllegalArgumentException callException = null;
    try {
        algorithm.getNextCommitted(entries.length); // the caller is acting as if it got an entry at lastLogIndex + 1
    } catch (IllegalArgumentException e) {
        callException = e;
    }
    assertThat(callException, notNullValue());
    // verify that the state hasn't changed
    assertThatLogContains(entries);
    assertThatTermAndCommitIndexHaveValues(currentTerm, commitIndex);
}