String buildCustomMessage(EventNotificationContext ctx, TeamsEventNotificationConfig config, String template) throws PermanentEventNotificationException {
        final List<MessageSummary> backlog = getMessageBacklog(ctx, config);
        Map<String, Object> model = getCustomMessageModel(ctx, config.type(), backlog, config.timeZone());
        try {
            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 {
        teamsEventNotificationConfig = buildInvalidTemplate();
        teamsEventNotification.buildCustomMessage(eventNotificationContext, teamsEventNotificationConfig, "Title:       ${does't exist}");
    }