### Question:
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);   }### Answer:
@Test public void saveOption_add_options_in_store() throws Exception { when(store.read(eq(ConfigManager.ORDER))).thenReturn(Collections.singletonList("old")); configManager.saveOption("new", Arrays.asList("1", "2")); InOrder inOrder = Mockito.inOrder(store); inOrder.verify(store).save(eq(ConfigManager.ORDER), eq(Arrays.asList("old", "new"))); inOrder.verify(store).save(eq(ConfigManager.KEY_PREFIX + "new"), eq(Arrays.asList("1", "2"))); }
@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()); }
@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")); }