ChangeConfig extends AbstractConsoleController { @RequestMapping(value = {"/config/sentinel/check/" + CLUSTER_NAME_PATH_VARIABLE + "/stop/{maintainMinutes}", "/config/sentinel/check/" + CLUSTER_NAME_PATH_VARIABLE + "/stop"}, method = RequestMethod.POST) public RetMessage stopSentinelCheck(HttpServletRequest request, @PathVariable String clusterName, @PathVariable(required = false) Integer maintainMinutes) throws DalException { if (null == maintainMinutes || maintainMinutes <= 0) maintainMinutes = consoleConfig.getNoAlarmMinutesForClusterUpdate(); maintainMinutes = Math.min(maintainMinutes, consoleConfig.getConfigDefaultRestoreHours() * 60); checkClusterName(clusterName); ConfigModel config = configModel(request, null); config.setSubKey(clusterName); configService.stopSentinelCheck(config, maintainMinutes); return RetMessage.createSuccessMessage("success"); }  @RequestMapping(value = "/config/sentinel_auto_process/start", method = RequestMethod.POST) void startSentinelAutoProcess(HttpServletRequest request,
                                         @RequestBody(required = false) ConfigModel configModel); @RequestMapping(value = "/config/sentinel_auto_process/stop", method = RequestMethod.POST) void stopSentinelAutoProcess(HttpServletRequest request,
                                        @RequestBody(required = false) ConfigModel configModel); @RequestMapping(value = "/config/alert_system/start", method = RequestMethod.POST) void startAlertSystem(HttpServletRequest request,
                                 @RequestBody(required = false) ConfigModel configModel); @RequestMapping(value = "/config/alert_system/stop", method = RequestMethod.POST) void stopAlertSystem(HttpServletRequest request,
                                @RequestBody(required = false) ConfigModel configModel); @RequestMapping(value = "/config/alert_system/stop/{hours}", method = RequestMethod.POST) void stopAlertSystem(HttpServletRequest request, @PathVariable int hours,
                                @RequestBody(required = false) ConfigModel configModel); @RequestMapping(value = "/config/ignore/migration/system/availability/{ignore}", method = RequestMethod.POST) void setIgnoreMigrationSystemAvailOrNot(HttpServletRequest request, @PathVariable boolean ignore); @RequestMapping(value = "/config/sentinel/check/" + CLUSTER_NAME_PATH_VARIABLE + "/start", method = RequestMethod.POST) RetMessage startSentinelCheck(HttpServletRequest request, @PathVariable String clusterName); @RequestMapping(value = {"/config/sentinel/check/" + CLUSTER_NAME_PATH_VARIABLE + "/stop/{maintainMinutes}", "/config/sentinel/check/" + CLUSTER_NAME_PATH_VARIABLE + "/stop"}, method = RequestMethod.POST) RetMessage stopSentinelCheck(HttpServletRequest request, @PathVariable String clusterName,
                                        @PathVariable(required = false) Integer maintainMinutes); @RequestMapping(value = "/config/sentinel/check/" + CLUSTER_NAME_PATH_VARIABLE, method = RequestMethod.GET) ClusterConfigModel getSentinelCheckConfig(@PathVariable String clusterName); @RequestMapping(value = "/config/sentinel/check/exclude/all", method = RequestMethod.GET) List<String> getAllSentinelCheckExcludeConfig();  }
@Test public void testStopSentinelCheck() throws Exception { AtomicInteger expectedMinutes = new AtomicInteger(0); Mockito.doAnswer(invocation -> { Integer minutes = invocation.getArgumentAt(1, Integer.class); Assert.assertEquals(minutes.intValue(), expectedMinutes.get()); return null; }).when(configService).stopSentinelCheck(Mockito.any(), Mockito.anyInt()); expectedMinutes.set(noAlarmMinutesForClusterUpdate); controller.stopSentinelCheck(Mockito.mock(HttpServletRequest.class), clusterName, null); Mockito.verify(configService, Mockito.times(1)).stopSentinelCheck(Mockito.any(), Mockito.anyInt()); expectedMinutes.set(30); controller.stopSentinelCheck(Mockito.mock(HttpServletRequest.class), clusterName, 30); Mockito.verify(configService, Mockito.times(2)).stopSentinelCheck(Mockito.any(), Mockito.anyInt()); expectedMinutes.set(configDefaultRestoreHours * 60); controller.stopSentinelCheck(Mockito.mock(HttpServletRequest.class), clusterName, configDefaultRestoreHours * 60 + 10); Mockito.verify(configService, Mockito.times(3)).stopSentinelCheck(Mockito.any(), Mockito.anyInt()); }