Search in sources :

Example 6 with CommentInstanceImpl

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);
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) CommentInstanceImpl(org.jbpm.casemgmt.impl.model.instance.CommentInstanceImpl) CaseCommentEvent(org.jbpm.casemgmt.api.event.CaseCommentEvent) TestNotificationPublisher(org.jbpm.casemgmt.impl.util.TestNotificationPublisher) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with CommentInstanceImpl

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");
}
Also used : CaseFileInstance(org.jbpm.casemgmt.api.model.instance.CaseFileInstance) User(org.kie.api.task.model.User) OrganizationalEntity(org.kie.api.task.model.OrganizationalEntity) CommentInstanceImpl(org.jbpm.casemgmt.impl.model.instance.CommentInstanceImpl) CaseCommentEvent(org.jbpm.casemgmt.api.event.CaseCommentEvent) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 8 with CommentInstanceImpl

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());
}
Also used : CommentInstanceImpl(org.jbpm.casemgmt.impl.model.instance.CommentInstanceImpl) CaseCommentEvent(org.jbpm.casemgmt.api.event.CaseCommentEvent) Test(org.junit.Test)

Aggregations

CommentInstanceImpl (org.jbpm.casemgmt.impl.model.instance.CommentInstanceImpl)8 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)7 ArrayList (java.util.ArrayList)6 CaseCommentEvent (org.jbpm.casemgmt.api.event.CaseCommentEvent)5 Test (org.junit.Test)5 Collection (java.util.Collection)3 List (java.util.List)3 AuthorizationManager (org.jbpm.casemgmt.api.auth.AuthorizationManager)3 CommentInstance (org.jbpm.casemgmt.api.model.instance.CommentInstance)3 CaseFileInstanceImpl (org.jbpm.casemgmt.impl.model.instance.CaseFileInstanceImpl)3 IdentityProvider (org.kie.internal.identity.IdentityProvider)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 MessageFormat (java.text.MessageFormat)2 Arrays (java.util.Arrays)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 Properties (java.util.Properties)2 Stream (java.util.stream.Stream)2