### Question:
FeatureActivator { public boolean getState(String code) throws IllegalArgumentException { if (!this.currentStates.containsKey(code)) { throw new IllegalArgumentException("Unknown feature code : " + code); } return this.currentStates.get(code); }  @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 getState_should_return_the_current_state_of_a_feature() { String feature1 = "my-feature"; String feature2 = "second-one"; Mockito.doReturn(true).when(currentStateMock).containsKey(feature1); Mockito.doReturn(true).when(currentStateMock).containsKey(feature2); Mockito.doReturn(false).when(currentStateMock).get(feature1); Mockito.doReturn(true).when(currentStateMock).get(feature2); boolean stateFeature1 = cut.getState("my-feature"); boolean stateFeature2 = cut.getState("second-one"); Assertions.assertThat(stateFeature1).isFalse(); Assertions.assertThat(stateFeature2).isTrue(); }
@Test public void getState_should_throw_exception_if_not_found() { String feature1 = "feature-1"; Mockito.doReturn(false).when(currentStateMock).containsKey(feature1); assertThrows(IllegalArgumentException.class,() -> cut.getState("feature-1")); }