InitialConfigStorage implements ConfigStorage { @Override public Config getConfig(long version) throws ConfigStorageException { if (version == INITIAL_VERSION) { throw new NoSuchElementException("No config for version: " + INITIAL_VERSION); } return underlying.getConfig(version); } InitialConfigStorage(ConfigStorage underlying); @Override Config getConfig(long version); @Override void saveConfig(long version, NodeContext config); @Override void reset();  }
@Test public void getInitialVersion() throws Exception { InitialConfigStorage storage = new InitialConfigStorage(underlying); assertThat(() -> storage.getConfig(0L), is(throwing(instanceOf(NoSuchElementException.class)))); }
@Test public void getOtherVersion() throws Exception { when(underlying.getConfig(1L)).thenReturn(new Config(topology, Version.CURRENT)); InitialConfigStorage storage = new InitialConfigStorage(underlying); assertEquals(new Config(topology, Version.CURRENT), storage.getConfig(1L)); }