ScannerContextImpl implements ScannerContext { @Override public <T> T peek(Class<T> key) { T value = getValues(key).peek(); if (value == null) { throw new IllegalStateException("Cannot find a value for '" + key.getName() + "' in the context"); } return value; } ScannerContextImpl(Store store, File outputDirectory); @Override void push(Class<T> key, T value); @Override T peek(Class<T> key); @Override T peekOrDefault(Class<T> key, T defaultValue); @Override T pop(Class<T> key); @Override void setCurrentDescriptor(D descriptor); @Override D getCurrentDescriptor(); @Override Store getStore(); @Override File getDataDirectory(String path);  }
@Test public void peekNonExistingValue() { assertThatThrownBy(() -> scannerContext.peek(String.class)).isInstanceOf(IllegalStateException.class); }