### Question:
SlackNotificationAjaxEditPageController extends BaseController { protected static void checkAndAddBuildState(HttpServletRequest r, BuildState state, BuildStateEnum myBuildState, String varName){ if ((r.getParameter(varName) != null) && ("on".equalsIgnoreCase(r.getParameter(varName)))){ state.enable(myBuildState); } else { state.disable(myBuildState);; } } SlackNotificationAjaxEditPageController(SBuildServer server, WebControllerManager webManager,
                                                       ProjectSettingsManager settings, SlackNotificationProjectSettings whSettings, SlackNotificationPayloadManager manager,
                                                       PluginDescriptor pluginDescriptor, SlackNotificationMainSettings mainSettings); void register();  }### Answer:
@Test public void testCheckAndAddBuildState() { assertFalse(states.enabled(BuildStateEnum.BUILD_SUCCESSFUL)); checkAndAddBuildState(requestSuccessOnAndFailureOff, states, BuildStateEnum.BUILD_SUCCESSFUL, BUILD_SUCCESSFUL); assertTrue(states.enabled(BuildStateEnum.BUILD_SUCCESSFUL)); assertFalse(states.enabled(BuildStateEnum.BUILD_FINISHED)); checkAndAddBuildState(requestSuccessOnAndFailureOff, states, BuildStateEnum.BUILD_FINISHED, BUILD_SUCCESSFUL); assertTrue(states.enabled(BuildStateEnum.BUILD_FINISHED)); assertFalse(states.enabled(BuildStateEnum.BUILD_FAILED)); checkAndAddBuildState(requestSuccessOnAndFailureOff, states, BuildStateEnum.BUILD_FINISHED, BUILD_FAILED); assertFalse(states.enabled(BuildStateEnum.BUILD_FAILED)); assertFalse(states.enabled(BuildStateEnum.BUILD_FINISHED)); }