AlertPolicyManager { public Map<EmailReceiverModel, Map<ALERT_TYPE, Set<AlertEntity>>> queryGroupedEmailReceivers( AlertEntityHolderManager alerts) { return groupEmailReceiver.getGroupedEmailReceiver(alerts); }  @PostConstruct void initPolicies(); List<AlertChannel> queryChannels(AlertEntity alert); long queryRecoverMilli(AlertEntity alert); long querySuspendMilli(AlertEntity alert); EmailReceiverModel queryEmailReceivers(AlertEntity alert); void markCheckInterval(ALERT_TYPE alertType, LongSupplier checkInterval); Map<EmailReceiverModel, Map<ALERT_TYPE, Set<AlertEntity>>> queryGroupedEmailReceivers(
            AlertEntityHolderManager alerts);  }
@Test public void testQueryGroupedEmailReceivers() throws Exception { HostPort hostPort = new HostPort("192.168.1.10", 6379); Map<ALERT_TYPE, Set<AlertEntity>> alerts = new HashMap<>(); alerts.put(ALERT_TYPE.CLIENT_INCONSIS, Collections.singleton( new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.CLIENT_INCONSIS ))); alerts.put(ALERT_TYPE.XREDIS_VERSION_NOT_VALID, Collections.singleton( new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.XREDIS_VERSION_NOT_VALID ))); alerts.put(ALERT_TYPE.QUORUM_DOWN_FAIL, Collections.singleton( new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.QUORUM_DOWN_FAIL ))); alerts.put(ALERT_TYPE.SENTINEL_RESET, Collections.singleton( new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.SENTINEL_RESET ))); alerts.put(ALERT_TYPE.REDIS_CONF_REWRITE_FAILURE, Collections.singleton( new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.REDIS_CONF_REWRITE_FAILURE ))); alerts.put(ALERT_TYPE.REDIS_REPL_DISKLESS_SYNC_ERROR, Collections.singleton( new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.REDIS_REPL_DISKLESS_SYNC_ERROR ))); alerts.put(ALERT_TYPE.MIGRATION_MANY_UNFINISHED, Collections.singleton( new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.MIGRATION_MANY_UNFINISHED ))); Map<EmailReceiverModel, Map<ALERT_TYPE, Set<AlertEntity>>> expect = Maps.newHashMap(); Map<ALERT_TYPE, Set<AlertEntity>> dbaMap = Maps.newHashMap(); dbaMap.put(ALERT_TYPE.CLIENT_INCONSIS, alerts.get(ALERT_TYPE.CLIENT_INCONSIS)); dbaMap.put(ALERT_TYPE.XREDIS_VERSION_NOT_VALID, alerts.get(ALERT_TYPE.XREDIS_VERSION_NOT_VALID)); dbaMap.put(ALERT_TYPE.REDIS_CONF_REWRITE_FAILURE, alerts.get(ALERT_TYPE.REDIS_CONF_REWRITE_FAILURE)); dbaMap.put(ALERT_TYPE.REDIS_REPL_DISKLESS_SYNC_ERROR, alerts.get(ALERT_TYPE.REDIS_REPL_DISKLESS_SYNC_ERROR)); Map<ALERT_TYPE, Set<AlertEntity>> xpipeAdminMap = Maps.newHashMap(); xpipeAdminMap.put(ALERT_TYPE.QUORUM_DOWN_FAIL, alerts.get(ALERT_TYPE.QUORUM_DOWN_FAIL)); xpipeAdminMap.put(ALERT_TYPE.SENTINEL_RESET, alerts.get(ALERT_TYPE.SENTINEL_RESET)); xpipeAdminMap.put(ALERT_TYPE.MIGRATION_MANY_UNFINISHED, alerts.get(ALERT_TYPE.MIGRATION_MANY_UNFINISHED)); expect.put(new EmailReceiverModel(Lists.newArrayList(consoleConfig.getDBAEmails()), Lists.newArrayList(consoleConfig.getXPipeAdminEmails())), dbaMap); expect.put(new EmailReceiverModel(Lists.newArrayList(consoleConfig.getXPipeAdminEmails()), null), xpipeAdminMap); Assert.assertEquals(expect, policyManager.queryGroupedEmailReceivers(convertToHolderManager(alerts))); configService.stopAlertSystem(new ConfigModel(), 1); expect.clear(); expect.put(new EmailReceiverModel(Lists.newArrayList(consoleConfig.getXPipeAdminEmails()), null), alerts); Assert.assertEquals(expect, policyManager.queryGroupedEmailReceivers(convertToHolderManager(alerts))); }