### Question:
DefaultSettingsKeyAccessor implements SettingsKeyAccessor { @Override public SettingsKeyModel saveSettingsKey(String key, String value) { Optional<SettingsKeyEntity> settingsKeyOptional = settingsKeyRepository.findByKey(key); if (settingsKeyOptional.isPresent()) { Long id = settingsKeyOptional.get().getId(); SettingsKeyEntity settingsKeyEntity = new SettingsKeyEntity(key, value); settingsKeyEntity.setId(id); SettingsKeyEntity updatedSettingsKeyEntity = settingsKeyRepository.save(settingsKeyEntity); return convertToSettingsKeyModel(updatedSettingsKeyEntity); } SettingsKeyEntity newSettingsKeyEntity = settingsKeyRepository.save(new SettingsKeyEntity(key, value)); return convertToSettingsKeyModel(newSettingsKeyEntity); } DefaultSettingsKeyAccessor(SettingsKeyRepository settingsKeyRepository); @Override List<SettingsKeyModel> getSettingsKeys(); @Override Optional<SettingsKeyModel> getSettingsKeyByKey(String key); @Override SettingsKeyModel saveSettingsKey(String key, String value); @Override void deleteSettingsKeyByKey(String key); @Override void deleteSettingsKeyById(Long id);  }### Answer:
@Test public void saveSettingsKeyTest() { final String key = "key1"; final String key2 = "key2"; final String originalValue = "originalValue"; final String newValue = "newValue"; final String newValue2 = "newValue-2"; SettingsKeyEntity settingsKeyEntity = new SettingsKeyEntity(key, originalValue); settingsKeyEntity.setId(1L); SettingsKeyRepository settingsKeyRepository = new MockSettingsKeyRepository(); settingsKeyRepository.save(settingsKeyEntity); DefaultSettingsKeyAccessor settingsKeyAccessor = new DefaultSettingsKeyAccessor(settingsKeyRepository); SettingsKeyModel settingsKeyModel = settingsKeyAccessor.saveSettingsKey(key, newValue); SettingsKeyModel settingsKeyModelKeyNotPresent = settingsKeyAccessor.saveSettingsKey(key2, newValue2); assertEquals(key, settingsKeyModel.getKey()); assertEquals(newValue, settingsKeyModel.getValue()); assertEquals(key2, settingsKeyModelKeyNotPresent.getKey()); assertEquals(newValue2, settingsKeyModelKeyNotPresent.getValue()); }