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;
}
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);
}
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);
}
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);
}
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|ZZZ|ZZZ||body:asd|||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);
}
Aggregations