use of org.jbpm.casemgmt.impl.model.instance.CommentInstanceImpl in project jbpm by kiegroup.
the class CommentNotificationEventListenerTest method testNotificationOnCommentAdded.
@Test
public void testNotificationOnCommentAdded() {
CommentNotificationEventListener listener = new CommentNotificationEventListener();
List<String> mentionedRoles = new ArrayList<>();
mentionedRoles.add("owner");
mentionedRoles.add("manager");
CaseFileInstance caseFile = buildCaseFile(mentionedRoles);
CommentInstanceImpl comment = new CommentInstanceImpl("john", "simple comment for @owner and @manager", new ArrayList<>());
CaseCommentEvent event = new CaseCommentEvent("john", caseFile.getCaseId(), caseFile, comment);
TestNotificationPublisher publisher = new TestNotificationPublisher(false);
listener.addPublisher(publisher);
listener.afterCaseCommentAdded(event);
String expectedNotification = "Publishing notification from cases@jbpm.org, with subject You have been mentioned in case (CASE-00001) comment to [[UserImpl:'mary'], [UserImpl:'john']] with template mentioned-in-comment";
List<String> published = publisher.get();
assertThat(published).hasSize(1);
assertThat(published.get(0)).isEqualTo(expectedNotification);
}
use of org.jbpm.casemgmt.impl.model.instance.CommentInstanceImpl in project jbpm by kiegroup.
the class CommentNotificationEventListenerTest method testCollectOrgEntitiesByRoleNotExistingRole.
@Test
public void testCollectOrgEntitiesByRoleNotExistingRole() {
CommentNotificationEventListener listener = new CommentNotificationEventListener();
List<String> mentionedRoles = new ArrayList<>();
mentionedRoles.add("owner");
mentionedRoles.add("manager");
CommentInstanceImpl comment = new CommentInstanceImpl("john", "simple comment for @owner and @manager", new ArrayList<>());
CaseFileInstance caseFile = buildCaseFile(mentionedRoles);
CaseCommentEvent event = new CaseCommentEvent("john", caseFile.getCaseId(), caseFile, comment);
// add additional role that is not in case file
mentionedRoles.add("notexisting");
StringBuilder commentContent = new StringBuilder(comment.getComment());
Set<OrganizationalEntity> collected = listener.collectOrgEntitiesByRole(mentionedRoles, event, commentContent);
assertThat(collected).hasSize(2);
assertThat(collected).allMatch(item -> item instanceof User);
assertThat(commentContent.toString()).isEqualTo("simple comment for john and mary");
}
use of org.jbpm.casemgmt.impl.model.instance.CommentInstanceImpl in project jbpm by kiegroup.
the class CommentNotificationEventListenerTest method testBuildParametersMap.
@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());
}
Aggregations