Search in sources :

Example 11 with NotificationValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue in project kie-wb-common by kiegroup.

the class ParsedNotificationsInfos method of.

public static NotificationValue of(String type, String body) {
    NotificationValue notification = new NotificationValue();
    notification.setType(type);
    if (nonEmpty(body)) {
        String tBody;
        if (body.contains("]@[")) {
            String[] parts = body.split("\\]@\\[");
            notification.setExpiresAt(parts[1].substring(0, parts[1].length() - 1));
            tBody = parts[0].replaceFirst("\\[", "");
        } else {
            tBody = body;
            tBody = removeBracket(tBody);
        }
        notification.setFrom(parseElement(tBody, "from"));
        notification.setUsers(parseGroup(tBody, "tousers"));
        notification.setGroups(parseGroup(tBody, "togroups"));
        notification.setEmails(join(",", parseGroup(tBody, "toemails")));
        notification.setReplyTo(parseElement(tBody, "replyTo"));
        notification.setSubject(replaceAsciiSymbols(parseElement(tBody, "subject")));
        notification.setBody(replaceAsciiSymbols(parseElement(tBody, "body")));
    }
    return notification;
}
Also used : NotificationValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue)

Example 12 with NotificationValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue in project kie-wb-common by kiegroup.

the class ParsedNotificationsInfosTest method testNotificationEmpty.

@Test
public void testNotificationEmpty() {
    NotificationValue value = ParsedNotificationsInfos.of(AssociationType.NOT_COMPLETED_NOTIFY.getName(), "");
    NotificationValue valid = new NotificationValue();
    valid.setType(AssociationType.NOT_COMPLETED_NOTIFY.getName());
    assertEquals(valid, value);
}
Also used : NotificationValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue) Test(org.junit.Test)

Example 13 with NotificationValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue in project kie-wb-common by kiegroup.

the class ParsedNotificationsInfosTest method testNotification.

@Test
public void testNotification() {
    String body = "[from:director|tousers:director,jack,katy|togroups:Forms,IT|replyTo:guest|subject:^asd|body:asd]@[11h]";
    NotificationValue actual = ParsedNotificationsInfos.of(AssociationType.NOT_COMPLETED_NOTIFY.getName(), body);
    NotificationValue expected = new NotificationValue();
    expected.setType(AssociationType.NOT_COMPLETED_NOTIFY.getName());
    expected.setFrom("director");
    expected.setReplyTo("guest");
    expected.setSubject("^asd");
    expected.setBody("asd");
    expected.setExpiresAt("11h");
    expected.setGroups(new ArrayList<>(Arrays.asList("Forms", "IT")));
    expected.setUsers(new ArrayList<>(Arrays.asList("director", "jack", "katy")));
    assertEquals(expected, actual);
}
Also used : NotificationValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue) Test(org.junit.Test)

Example 14 with NotificationValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue in project kie-wb-common by kiegroup.

the class ParsedNotificationsInfosTest method testNotificationPartial.

@Test
public void testNotificationPartial() {
    String body = "[from:|tousers:|togroups:|toemails:|replyTo:|subject:|body:]@[0h]";
    NotificationValue actual = ParsedNotificationsInfos.of(AssociationType.NOT_COMPLETED_NOTIFY.getName(), body);
    NotificationValue expected = new NotificationValue();
    expected.setType(AssociationType.NOT_COMPLETED_NOTIFY.getName());
    expected.setExpiresAt("0h");
    assertEquals(expected.toString(), actual.toString());
    assertEquals(expected.toCDATAFormat(), actual.toCDATAFormat());
    assertEquals(expected, actual);
}
Also used : NotificationValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue) Test(org.junit.Test)

Example 15 with NotificationValue

use of org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue in project kie-wb-common by kiegroup.

the class ParsedNotificationsInfosTest method testNotificationPartialVerticalBarBadFormat.

@Test
public void testNotificationPartialVerticalBarBadFormat() {
    // Testing for bad format, an extra closing bracket was being used in the validation tests
    String bodyError = "[from:|tousers:|togroups:|replyTo:|subject:ZZZ&#124;ZZZ&#124;ZZZ&#124;|body:asd&#124;&#124;&#124;asd]@[0h]]";
    NotificationValue actualError = ParsedNotificationsInfos.of(AssociationType.NOT_COMPLETED_NOTIFY.getName(), bodyError);
    NotificationValue unexpected = new NotificationValue();
    unexpected.setType(AssociationType.NOT_COMPLETED_NOTIFY.getName());
    unexpected.setExpiresAt("0h");
    unexpected.setBody("asd|||asd");
    unexpected.setSubject("ZZZ|ZZZ|ZZZ|");
    assertNotEquals(unexpected.toString(), actualError.toString());
    assertNotEquals(unexpected.toCDATAFormat(), actualError.toCDATAFormat());
    assertNotEquals(unexpected, actualError);
}
Also used : NotificationValue(org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue) Test(org.junit.Test)

Aggregations

NotificationValue (org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationValue)16 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)3 HTMLInputElement (elemental2.dom.HTMLInputElement)1 ValidNotificationValue (org.kie.workbench.common.stunner.bpmn.client.forms.fields.notificationsEditor.validation.ValidNotificationValue)1 ReflectionUtilsTest (org.kie.workbench.common.stunner.bpmn.client.forms.util.ReflectionUtilsTest)1 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)1 NotificationTypeListValue (org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationTypeListValue)1 NotificationsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.notification.NotificationsInfo)1 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)1 Graph (org.kie.workbench.common.stunner.core.graph.Graph)1