DecoratorManager { public Pair<String, String> generateTitleAndContent(AlertEntity alert, boolean isAlertMessage) { Decorator decorator = getDecorator(isAlertMessage); String content = decorator.generateContent(alert); String title = decorator.generateTitle(alert); return new Pair<>(title, content); }  Pair<String, String> generateTitleAndContent(AlertEntity alert, boolean isAlertMessage); Pair<String, String> generateTitleAndContent(Map<ALERT_TYPE, Set<AlertEntity>> alerts, boolean isAlertMessage);  }
@Test public void generateTitleAndContent() throws Exception { Pair<String, String> pair = decoratorManager.generateTitleAndContent(alert, true); String title = pair.getKey(); String content = pair.getValue(); logger.info("title: {}", title); logger.info("content: {}",content); }
@Test public void generateTitleTooLong() throws Exception { String message = "[PRO][XPipe 恢复]CLIENT_INCONSIS:train_tieyoubooking_redis:shard not equal:"; while(message.length() <= 1024) { message += "{cluster: test-cluster, shard: shard-test, hostport: {'192.168.1.10:6379', '192.168.1.10:6379'\n}}"; } alert.setMessage(message); Pair<String, String> pair = decoratorManager.generateTitleAndContent(alert, true); String title = pair.getKey(); Assert.assertTrue(title.length() < 1024); }