@Test public void getSettingsKeysTest() { final String key = "key1"; final String key2 = "key2"; final String value1 = "value1"; final String value2 = "value2"; SettingsKeyEntity settingsKeyEntity1 = new SettingsKeyEntity(key, value1); SettingsKeyEntity settingsKeyEntity2 = new SettingsKeyEntity(key2, value2); settingsKeyEntity1.setId(1L); settingsKeyEntity2.setId(2L); SettingsKeyRepository settingsKeyRepository = new MockSettingsKeyRepository(); settingsKeyRepository.save(settingsKeyEntity1); settingsKeyRepository.save(settingsKeyEntity2); DefaultSettingsKeyAccessor settingsKeyAccessor = new DefaultSettingsKeyAccessor(settingsKeyRepository); List<SettingsKeyModel> settingsKeyModelList = settingsKeyAccessor.getSettingsKeys(); assertEquals(2, settingsKeyModelList.size()); SettingsKeyModel settingsKeyModel1 = settingsKeyModelList.get(0); SettingsKeyModel settingsKeyModel2 = settingsKeyModelList.get(1); assertEquals(key, settingsKeyModel1.getKey()); assertEquals(value1, settingsKeyModel1.getValue()); assertEquals(key2, settingsKeyModel2.getKey()); assertEquals(value2, settingsKeyModel2.getValue()); }
@Override public List<SettingsKeyModel> getSettingsKeys() { return settingsKeyRepository.findAll() .stream() .map(this::convertToSettingsKeyModel) .collect(Collectors.toList()); }
DefaultSettingsKeyAccessor implements SettingsKeyAccessor { @Override public List<SettingsKeyModel> getSettingsKeys() { return settingsKeyRepository.findAll() .stream() .map(this::convertToSettingsKeyModel) .collect(Collectors.toList()); } }
DefaultSettingsKeyAccessor implements SettingsKeyAccessor { @Override public List<SettingsKeyModel> getSettingsKeys() { return settingsKeyRepository.findAll() .stream() .map(this::convertToSettingsKeyModel) .collect(Collectors.toList()); } DefaultSettingsKeyAccessor(SettingsKeyRepository settingsKeyRepository); }
DefaultSettingsKeyAccessor implements SettingsKeyAccessor { @Override public List<SettingsKeyModel> getSettingsKeys() { return settingsKeyRepository.findAll() .stream() .map(this::convertToSettingsKeyModel) .collect(Collectors.toList()); } 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 List<SettingsKeyModel> getSettingsKeys() { return settingsKeyRepository.findAll() .stream() .map(this::convertToSettingsKeyModel) .collect(Collectors.toList()); } 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);  }