String buildCustomMessage(EventNotificationContext ctx, SlackEventNotificationConfig config, String template) throws PermanentEventNotificationException {
        final List<MessageSummary> backlog = getMessageBacklog(ctx, config);
        Map<String, Object> model = getCustomMessageModel(ctx, config.type(), backlog, config.timeZone());
        try {
            LOG.debug("customMessage: template = {} model = {}", template, model);
            return templateEngine.transform(template, model);
        } catch (Exception e) {
            String error = "Invalid Custom Message template.";
            LOG.error(error + "[{}]", e.toString());
            throw new PermanentEventNotificationException(error + e, e.getCause());
        }
    }
@Test(expected = PermanentEventNotificationException.class)
    public void buildCustomMessageWithInvalidTemplate() throws EventNotificationException {
        slackEventNotificationConfig = buildInvalidTemplate();
        slackEventNotification.buildCustomMessage(eventNotificationContext, slackEventNotificationConfig, "Title:       ${does't exist}");
    }