@Test public void deleteSettingsKeyByKeyTest() { final String key = "key1"; final String originalValue = "originalValue"; SettingsKeyEntity settingsKeyEntity = new SettingsKeyEntity(key, originalValue); settingsKeyEntity.setId(1L); SettingsKeyRepository settingsKeyRepository = new MockSettingsKeyRepository(); settingsKeyRepository.save(settingsKeyEntity); DefaultSettingsKeyAccessor settingsKeyAccessor = new DefaultSettingsKeyAccessor(settingsKeyRepository); assertTrue(settingsKeyRepository.findByKey(key).isPresent()); settingsKeyAccessor.deleteSettingsKeyByKey(key); assertFalse(settingsKeyRepository.findByKey(key).isPresent()); }
@Override public void deleteSettingsKeyByKey(String key) { getSettingsKeyByKey(key).ifPresent(settingsKeyModel -> deleteSettingsKeyById(settingsKeyModel.getId())); }
DefaultSettingsKeyAccessor implements SettingsKeyAccessor { @Override public void deleteSettingsKeyByKey(String key) { getSettingsKeyByKey(key).ifPresent(settingsKeyModel -> deleteSettingsKeyById(settingsKeyModel.getId())); } }
DefaultSettingsKeyAccessor implements SettingsKeyAccessor { @Override public void deleteSettingsKeyByKey(String key) { getSettingsKeyByKey(key).ifPresent(settingsKeyModel -> deleteSettingsKeyById(settingsKeyModel.getId())); } DefaultSettingsKeyAccessor(SettingsKeyRepository settingsKeyRepository); }
DefaultSettingsKeyAccessor implements SettingsKeyAccessor { @Override public void deleteSettingsKeyByKey(String key) { getSettingsKeyByKey(key).ifPresent(settingsKeyModel -> deleteSettingsKeyById(settingsKeyModel.getId())); } 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); }
DefaultSettingsKeyAccessor implements SettingsKeyAccessor { @Override public void deleteSettingsKeyByKey(String key) { getSettingsKeyByKey(key).ifPresent(settingsKeyModel -> deleteSettingsKeyById(settingsKeyModel.getId())); } 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);  }