@Test(expected = Exception.class) public void saveOption_throws_on_bad_size() throws Exception { when(store.read(eq(ConfigManager.ORDER))).thenReturn(Collections.emptyList()); configManager.saveOption("test", Collections.singletonList("1")); }
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);   }