AlertManager { @VisibleForTesting public boolean shouldAlert(String cluster) { try { Date createTime = getClusterCreateTime(cluster); int minutes = consoleConfig.getNoAlarmMinutesForClusterUpdate(); Date current = new Date(); if (createTime != null && current.before(DateTimeUtils.getMinutesLaterThan(createTime, minutes))) { return false; } } catch (Exception e) { logger.warn("[shouldAlert]", e); } return !alertClusterWhiteList.contains(cluster); }  @PostConstruct void postConstruct(); void alert(String dc, String cluster, String shard, HostPort hostPort, ALERT_TYPE type, String message); void alert(RedisInstanceInfo info, ALERT_TYPE type, String message); void alert(String cluster, String shard, HostPort hostPort, ALERT_TYPE type, String message); @VisibleForTesting boolean shouldAlert(String cluster);  }
@Test public void testShouldAlert() { when(consoleConfig.getNoAlarmMinutesForClusterUpdate()).thenReturn(15); Map<String, Date> map = Maps.newHashMapWithExpectedSize(1); map.put("cluster", new Date()); alertManager.setClusterCreateTime(map); alertManager.setAlertClusterWhiteList(Sets.newHashSet()); Assert.assertFalse(alertManager.shouldAlert("cluster")); Assert.assertTrue(alertManager.shouldAlert("test")); }