GroupedAlertMessageDecorator extends Decorator { public String generateBody(Map<ALERT_TYPE, Set<AlertEntity>> alerts) { VelocityContext context = generateCommonContext(); context.put("redisAlerts", alerts); context.put("title", generateTitle()); return getRenderedString(getTemplateName(), context); }  @Override String doGenerateTitle(AlertEntity alert); String generateTitle(); String generateBody(Map<ALERT_TYPE, Set<AlertEntity>> alerts); static final String ID; }
@Test public void generateBody() 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.CLIENT_INSTANCE_NOT_OK, Sets.newHashSet( new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.CLIENT_INSTANCE_NOT_OK), new AlertEntity(hostPort, dcNames[0], "cluster-test-1", "shard-test-1", "", ALERT_TYPE.CLIENT_INSTANCE_NOT_OK), new AlertEntity(hostPort, dcNames[0], "cluster-test-2", "shard-test-2", "", ALERT_TYPE.CLIENT_INSTANCE_NOT_OK) )); String body = decorator.generateBody(alerts); logger.info("{}", body); }