### Question:
FeatureActivator { public void changeStateOf(String code, boolean newState) { if (this.currentStates.containsKey(code)) { log.info("Switching state of {} to {}.", code, newState ? "ENABLED" : "DISABLED"); this.currentStates.put(code, newState); } }  @PostConstruct void load(); void load(FeatureCollection collection); boolean getState(String code); void changeStateOf(String code, boolean newState); boolean isEnabledByDefault(String code);  }### Answer:
@Test public void changeStateOf_should_change_current_state_of_feature() { String feature1 = "feature-2"; Mockito.doReturn(true).when(currentStateMock).containsKey(feature1); cut.changeStateOf(feature1, true); Mockito.verify(currentStateMock).put(feature1, true); }
@Test public void changeStateOf_should_not_change_state_if_bad_code() { String feature1 = "feature-3"; Mockito.doReturn(false).when(currentStateMock).containsKey(feature1); cut.changeStateOf(feature1, true); Mockito.verify(currentStateMock, Mockito.never()).put(Mockito.anyString(), Mockito.anyBoolean()); }
@Test public void changeStateOf_should_erase_and_not_flip() { String feature1 = "feature-4"; Mockito.doReturn(true).when(currentStateMock).containsKey(feature1); cut.changeStateOf(feature1, false); Mockito.verify(currentStateMock).put(feature1, false); }