@Test public void saveOption_updates_option_in_store() throws Exception { when(store.read(eq(ConfigManager.ORDER))).thenReturn(Collections.singletonList("old")); configManager.saveOption("old", Arrays.asList("1", "2")); verify(store).save(eq(ConfigManager.KEY_PREFIX + "old"), eq(Arrays.asList("1", "2"))); verify(store).save(anyString(), any()); }
void saveOption(String name, List<String> values) { if (!hasSameSizeAsConfig(values)) { throw new IllegalArgumentException("unexpected size of options!. Should be " + fillConfig.getTargetIds().size() + "; But was " + values.size() ); } final List<String> optionNames = store.read(ORDER); if (!optionNames.contains(name)) { List<String> newOptions = new ArrayList<>(optionNames); newOptions.add(name); store.save(ORDER, newOptions); } store.save(KEY_PREFIX + name, values); }
ConfigManager { void saveOption(String name, List<String> values) { if (!hasSameSizeAsConfig(values)) { throw new IllegalArgumentException("unexpected size of options!. Should be " + fillConfig.getTargetIds().size() + "; But was " + values.size() ); } final List<String> optionNames = store.read(ORDER); if (!optionNames.contains(name)) { List<String> newOptions = new ArrayList<>(optionNames); newOptions.add(name); store.save(ORDER, newOptions); } store.save(KEY_PREFIX + name, values); } }
ConfigManager { void saveOption(String name, List<String> values) { if (!hasSameSizeAsConfig(values)) { throw new IllegalArgumentException("unexpected size of options!. Should be " + fillConfig.getTargetIds().size() + "; But was " + values.size() ); } final List<String> optionNames = store.read(ORDER); if (!optionNames.contains(name)) { List<String> newOptions = new ArrayList<>(optionNames); newOptions.add(name); store.save(ORDER, newOptions); } store.save(KEY_PREFIX + name, values); } ConfigManager(FillConfig fillConfig, Store store); }
ConfigManager { void saveOption(String name, List<String> values) { if (!hasSameSizeAsConfig(values)) { throw new IllegalArgumentException("unexpected size of options!. Should be " + fillConfig.getTargetIds().size() + "; But was " + values.size() ); } final List<String> optionNames = store.read(ORDER); if (!optionNames.contains(name)) { List<String> newOptions = new ArrayList<>(optionNames); newOptions.add(name); store.save(ORDER, newOptions); } store.save(KEY_PREFIX + name, values); } ConfigManager(FillConfig fillConfig, Store store);  }
ConfigManager { void saveOption(String name, List<String> values) { if (!hasSameSizeAsConfig(values)) { throw new IllegalArgumentException("unexpected size of options!. Should be " + fillConfig.getTargetIds().size() + "; But was " + values.size() ); } final List<String> optionNames = store.read(ORDER); if (!optionNames.contains(name)) { List<String> newOptions = new ArrayList<>(optionNames); newOptions.add(name); store.save(ORDER, newOptions); } store.save(KEY_PREFIX + name, values); } ConfigManager(FillConfig fillConfig, Store store);   }