ConfigLocationFileStore { public void add(String location) { List<String> configLocations = new ArrayList<>(loadAll()); configLocations.add(location); save(configLocations); } @Autowired  ConfigLocationFileStore(PropertiesConfiguration propertiesConfiguration); Iterable<ConfigLocation> getAll(); void add(String location); static final String CONFIG_LOCATION_PROPERTY_KEY; }
@Test public void shouldAddConfigLocation() { PropertiesConfiguration propertiesConfiguration = mock(PropertiesConfiguration.class); ConfigLocationFileStore configLocationFileStore = new ConfigLocationFileStore(propertiesConfiguration); when(propertiesConfiguration.getStringArray("config.location")).thenReturn(new String[]{"value1", "value2"}); configLocationFileStore.add("file:newlocation"); verify(propertiesConfiguration).setProperty("config.location", "value1,value2,file:newlocation"); }