LocalStore { synchronized KeyValue get(long index, String key) throws KayVeeException { incrementLastAppliedIndex(index); String value = entries.get(key); if (value == null) { throw new KeyNotFoundException(key); } return new KeyValue(key, value); }    }
@Test public void shouldThrowKeyNotFoundExceptionIfKeyDoesNotExist() { final int newIndex = 1; KayVeeException thrownException = null; try { localStore.get(newIndex, "FAKE_KEY"); } catch (KayVeeException e) { thrownException = e; } thrownException = checkNotNull(thrownException); assertThat(thrownException, instanceOf(KeyNotFoundException.class)); assertThat(((KeyNotFoundException) thrownException).getKey(), equalTo("FAKE_KEY")); assertThatLocalStoreHasKeyValue("FAKE_KEY", null); assertThatLastAppliedIndexHasValue(newIndex); }