use of com.evolveum.midpoint.notifications.api.transports.Message in project midpoint by Evolveum.
the class TestStrings method test104SimpleAssignmentApproveByAdministrator.
/**
* User `administrator` approves the work item belonging to `elaine`.
*
* The case is moved to stage 3 of 3 (role approvers).
*/
@Test
public void test104SimpleAssignmentApproveByAdministrator() throws Exception {
Task task = getTestTask();
OperationResult result = task.getResult();
dummyAuditService.clear();
dummyTransport.clearMessages();
given();
login(userAdministrator);
List<CaseWorkItemType> workItems = getWorkItems(task, result);
displayWorkItems("Work item after 1st approval", workItems);
CaseWorkItemType elaineWorkItem = workItems.stream().filter(wi -> USER_ELAINE.oid.equals(wi.getOriginalAssigneeRef().getOid())).findFirst().orElseThrow(() -> new AssertionError("No work item for elaine"));
when();
// Second approval
caseService.completeWorkItem(WorkItemId.of(elaineWorkItem), ApprovalUtils.createApproveOutput(prismContext).comment("OK. Security."), task, result);
then();
workItems = getWorkItems(task, result);
displayWorkItems("Work item after 2nd approval", workItems);
assertEquals("Wrong # of work items on level 3", 2, workItems.size());
CaseType aCase = CaseWorkItemUtil.getCaseRequired(workItems.get(0));
display("wfTask after 2nd approval", aCase);
assertStage(aCase, 3, 3, "Role approvers (all)", null);
assertTriggers(aCase, 4);
Map<String, CaseWorkItemType> workItemsMap = sortByOriginalAssignee(workItems);
assertNotNull("chef is not an approver", workItemsMap.get(USER_CHEF.oid));
assertNotNull("cheese is not an approver", workItemsMap.get(USER_CHEESE.oid));
List<Message> lifecycleMessages = dummyTransport.getMessages(DUMMY_WORK_ITEM_LIFECYCLE);
List<Message> allocationMessages = dummyTransport.getMessages(DUMMY_WORK_ITEM_ALLOCATION);
List<Message> processMessages = dummyTransport.getMessages(DUMMY_PROCESS);
display("work items lifecycle notifications", lifecycleMessages);
display("work items allocation notifications", allocationMessages);
display("processes notifications", processMessages);
dummyTransport.clearMessages();
assertEquals("Wrong # of work items lifecycle messages", 4, lifecycleMessages.size());
assertEquals("Wrong # of work items allocation messages", 4, allocationMessages.size());
assertNull("process messages", processMessages);
Map<String, Message> sorted = sortByRecipientsSingle(lifecycleMessages);
assertMessage(sorted.get("elaine@evolveum.com"), "elaine@evolveum.com", "Work item has been completed", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Security (2/3)", "Allocated to: Elaine Marley (elaine)", "Carried out by: midPoint Administrator (administrator)", "Result: Approved", "^Deadline:");
assertMessage(sorted.get("barkeeper@evolveum.com"), "barkeeper@evolveum.com", "Work item has been cancelled", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Security (2/3)", "Allocated to: Horridly Scarred Barkeep (barkeeper)", "^Result:", "^Deadline:", "^Carried out by:");
assertMessage(sorted.get("cheese@evolveum.com"), "cheese@evolveum.com", "A new work item has been created", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Role approvers (all) (3/3)", "Allocated to: Ignatius Cheese (cheese)", "^Result:", "(in 5 days)");
assertMessage(sorted.get("chef@evolveum.com"), "chef@evolveum.com", "A new work item has been created", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Role approvers (all) (3/3)", "Allocated to: Scumm Bar Chef (chef)", "^Result:", "(in 5 days)");
Map<String, Message> sorted2 = sortByRecipientsSingle(allocationMessages);
assertMessage(sorted2.get("elaine@evolveum.com"), "elaine@evolveum.com", "Work item has been completed", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Security (2/3)", "Allocated to: Elaine Marley (elaine)", "Carried out by: midPoint Administrator (administrator)", "Result: Approved", "^Deadline:");
assertMessage(sorted2.get("barkeeper@evolveum.com"), "barkeeper@evolveum.com", "Work item has been cancelled", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Security (2/3)", "Allocated to: Horridly Scarred Barkeep (barkeeper)", "^Result:", "^Deadline:", "^Carried out by:");
assertMessage(sorted2.get("cheese@evolveum.com"), "cheese@evolveum.com", "Work item has been allocated to you", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Role approvers (all) (3/3)", "Allocated to: Ignatius Cheese (cheese)", "^Result:", "(in 5 days)");
assertMessage(sorted2.get("chef@evolveum.com"), "chef@evolveum.com", "Work item has been allocated to you", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Role approvers (all) (3/3)", "Allocated to: Scumm Bar Chef (chef)", "^Result:", "(in 5 days)");
displayDumpable("audit", dummyAuditService);
}
use of com.evolveum.midpoint.notifications.api.transports.Message in project midpoint by Evolveum.
the class TestStrings method test209EightDaysLater.
@Test
public void test209EightDaysLater() throws Exception {
final String TEST_NAME = "test209EightDaysLater";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = createTask(TestStrings.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
dummyAuditService.clear();
dummyTransport.clearMessages();
// GIVEN
clock.resetOverride();
clock.overrideDuration("P8D");
// WHEN
waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true);
// THEN
List<Message> lifecycleMessages = dummyTransport.getMessages(DUMMY_WORK_ITEM_LIFECYCLE);
List<Message> allocationMessages = dummyTransport.getMessages(DUMMY_WORK_ITEM_ALLOCATION);
List<Message> processMessages = dummyTransport.getMessages(DUMMY_PROCESS);
display("work items lifecycle notifications", lifecycleMessages);
display("work items allocation notifications", allocationMessages);
display("processes notifications", processMessages);
dummyTransport.clearMessages();
assertEquals("Wrong # of work items lifecycle messages", 2, lifecycleMessages.size());
assertEquals("Wrong # of work items allocation messages", 2, allocationMessages.size());
assertEquals("Wrong # of process messages", 1, processMessages.size());
checkTwoCompleted(lifecycleMessages);
checkTwoCompleted(allocationMessages);
assertMessage(processMessages.get(0), "administrator@evolveum.com", "Workflow process instance has finished", "Process instance name: Assigning a-test-1 to carla", "Result: REJECTED");
display("audit", dummyAuditService);
}
use of com.evolveum.midpoint.notifications.api.transports.Message in project midpoint by Evolveum.
the class TestStrings method test205EightDaysLater.
@Test
public void test205EightDaysLater() throws Exception {
final String TEST_NAME = "test205EightDaysLater";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = createTask(TestStrings.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
dummyAuditService.clear();
dummyTransport.clearMessages();
// WHEN
clock.resetOverride();
clock.overrideDuration("P8D");
waitForTaskNextRun(TASK_TRIGGER_SCANNER_OID, true, 20000, true);
// THEN
List<Message> lifecycleMessages = dummyTransport.getMessages(DUMMY_WORK_ITEM_LIFECYCLE);
List<Message> allocationMessages = dummyTransport.getMessages(DUMMY_WORK_ITEM_ALLOCATION);
List<Message> processMessages = dummyTransport.getMessages(DUMMY_PROCESS);
display("work items lifecycle notifications", lifecycleMessages);
display("work items allocation notifications", allocationMessages);
display("processes notifications", processMessages);
dummyTransport.clearMessages();
assertNull("lifecycle messages", lifecycleMessages);
assertNull("process messages", processMessages);
assertEquals("Wrong # of work items allocation messages", 4, allocationMessages.size());
ArrayListValuedHashMap<String, Message> sorted = sortByRecipients(allocationMessages);
assertMessage(sorted.get("guybrush@evolveum.com").get(0), "guybrush@evolveum.com", "Work item will be automatically completed in 2 days 12 hours", "Work item: Approve assigning a-test-1 to carla", "Stage: Line managers (1/3)", "Escalation level: Line manager escalation (1)", "|Allocated to: Guybrush Threepwood (guybrush), Ignatius Cheese (cheese)|Allocated to: Ignatius Cheese (cheese), Guybrush Threepwood (guybrush)", "(in 9 days)");
assertMessage(sorted.get("guybrush@evolveum.com").get(1), "guybrush@evolveum.com", "Work item will be automatically completed in 2 days", "Work item: Approve assigning a-test-1 to carla", "Stage: Line managers (1/3)", "Escalation level: Line manager escalation (1)", "|Allocated to: Guybrush Threepwood (guybrush), Ignatius Cheese (cheese)|Allocated to: Ignatius Cheese (cheese), Guybrush Threepwood (guybrush)", "(in 9 days)");
assertMessage(sorted.get("cheese@evolveum.com").get(0), "cheese@evolveum.com", "Work item will be automatically completed in 2 days 12 hours", "Work item: Approve assigning a-test-1 to carla", "Stage: Line managers (1/3)", "Escalation level: Line manager escalation (1)", "|Allocated to: Guybrush Threepwood (guybrush), Ignatius Cheese (cheese)|Allocated to: Ignatius Cheese (cheese), Guybrush Threepwood (guybrush)", "(in 9 days)");
assertMessage(sorted.get("cheese@evolveum.com").get(1), "cheese@evolveum.com", "Work item will be automatically completed in 2 days", "Work item: Approve assigning a-test-1 to carla", "Stage: Line managers (1/3)", "Escalation level: Line manager escalation (1)", "|Allocated to: Guybrush Threepwood (guybrush), Ignatius Cheese (cheese)|Allocated to: Ignatius Cheese (cheese), Guybrush Threepwood (guybrush)", "(in 9 days)");
display("audit", dummyAuditService);
}
use of com.evolveum.midpoint.notifications.api.transports.Message in project midpoint by Evolveum.
the class TestScriptingBasic method test430NotificationAboutJackType2.
@Test
public void test430NotificationAboutJackType2() throws Exception {
final String TEST_NAME = "test430NotificationAboutJackType2";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<ScriptingExpressionType> expression = parseAnyData(NOTIFICATION_ABOUT_JACK_TYPE2_FILE);
prepareNotifications();
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
TestUtil.assertSuccess(result);
assertOutputData(output, 1, OperationResultStatus.SUCCESS);
assertEquals("Produced 1 event(s)\n", output.getConsoleOutput());
display("Dummy transport", dummyTransport);
checkDummyTransportMessages("Custom", 1);
Message m = dummyTransport.getMessages("dummy:Custom").get(0);
assertEquals("Wrong message body", "1", m.getBody());
assertEquals("Wrong message subject", "Ad hoc notification 2", m.getSubject());
checkDummyTransportMessages("CustomType2", 1);
m = dummyTransport.getMessages("dummy:CustomType2").get(0);
assertEquals("Wrong message body", "POV:user:c0c010c0-d34d-b33f-f00d-111111111111(jack)", m.getBody());
assertEquals("Wrong message subject", "Failure notification of type 2", m.getSubject());
}
use of com.evolveum.midpoint.notifications.api.transports.Message in project midpoint by Evolveum.
the class TestScriptingBasic method test420NotificationAboutJack.
@Test
public void test420NotificationAboutJack() throws Exception {
final String TEST_NAME = "test420NotificationAboutJack";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<ScriptingExpressionType> expression = parseAnyData(NOTIFICATION_ABOUT_JACK_FILE);
prepareNotifications();
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
TestUtil.assertSuccess(result);
assertOutputData(output, 1, OperationResultStatus.SUCCESS);
assertEquals("Produced 1 event(s)\n", output.getConsoleOutput());
display("Dummy transport", dummyTransport);
checkDummyTransportMessages("Custom", 1);
Message m = dummyTransport.getMessages("dummy:Custom").get(0);
assertEquals("Wrong message body", "jack/" + USER_JACK_OID, m.getBody());
assertEquals("Wrong message subject", "Ad hoc notification", m.getSubject());
}
Aggregations