CommentNotificationEventListener implements CaseEventListener, Cacheable { protected Map<String, Object> buildParams(CaseCommentEvent event, StringBuilder commentContent) { Map<String, Object> parameters = new HashMap<>(); parameters.put(CASE_ID_PARAM, event.getCaseId()); parameters.put(AUTHOR_PARAM, event.getComment().getAuthor()); parameters.put(COMMENT_ID_PARAM, event.getComment().getId()); parameters.put(COMMENT_PARAM, commentContent.toString()); parameters.put(CREATED_AT_PARAM, event.getComment().getCreatedAt()); return parameters; } CommentNotificationEventListener();  CommentNotificationEventListener(String sender, String template, String subject); @Override void afterCaseCommentAdded(CaseCommentEvent event); @Override void afterCaseCommentUpdated(CaseCommentEvent event); void addPublisher(NotificationPublisher publisher); @Override void close(); static final String DEFAULT_SENDER; static final String DEFAULT_TEMPLATE; static final String DEFAULT_SUBJECT; static final String CASE_ID_PARAM; static final String AUTHOR_PARAM; static final String COMMENT_PARAM; static final String COMMENT_ID_PARAM; static final String CREATED_AT_PARAM; }
@Test public void testBuildParametersMap() { CommentNotificationEventListener listener = new CommentNotificationEventListener(); CommentInstanceImpl comment = new CommentInstanceImpl("john", "simple comment for @owner and @manager", new ArrayList<>()); CaseCommentEvent event = new CaseCommentEvent("john", "CASE-00001" , null, comment); StringBuilder commentContent = new StringBuilder(comment.getComment()); Map<String, Object> parameters = listener.buildParams(event, commentContent); assertThat(parameters).hasSize(5); assertThat(parameters) .containsEntry(AUTHOR_PARAM, comment.getAuthor()) .containsEntry(CASE_ID_PARAM, "CASE-00001") .containsEntry(COMMENT_ID_PARAM, comment.getId()) .containsEntry(COMMENT_PARAM, commentContent.toString()) .containsEntry(CREATED_AT_PARAM, comment.getCreatedAt()); }