### Question:
InMemoryPersister implements ConfigPersister { @Override public void saveConfiguration(final ComplexConfigDTO configDTO) { if (savedObjects.containsKey(configDTO.getDefiningScopePath())) { throw new StaleConfigException(configDTO.getDefiningScopePath(), "Can't save a configuration which already exists."); } savedObjects.put(configDTO.getDefiningScopePath(), configDTO); } InMemoryPersister(); @Override void saveConfiguration(final ComplexConfigDTO configDTO); @Override ComplexConfigDTO loadConfiguration(final ScopePath scopePath); @Override void updateConfiguration(final ComplexConfigDTO configDTO); @Override String getId(); @Override Collection<ScopePath> listScopes(final String scopeName, final Map<String, String> properties); @Override void delete(final ScopePath scopePath, final boolean deleteChildren); @Override void deleteAllOccurences(final String scopeName, final Map<String, String> properties); static final String ID; }### Answer:
@Test public void testExceptionOnSaveExisting() { expectedException.expect(StaleConfigException.class); expectedException.expectMessage("Can't save a configuration which already exists."); persister.saveConfiguration(testConfig); persister.saveConfiguration(testConfig); }