Search in sources :

Example 26 with Message

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Message(com.evolveum.midpoint.notifications.api.transports.Message) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 27 with Message

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Message(com.evolveum.midpoint.notifications.api.transports.Message) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 28 with Message

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) Message(com.evolveum.midpoint.notifications.api.transports.Message) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 29 with Message

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());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExecutionContext(com.evolveum.midpoint.model.impl.scripting.ExecutionContext) Message(com.evolveum.midpoint.notifications.api.transports.Message) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 30 with Message

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());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExecutionContext(com.evolveum.midpoint.model.impl.scripting.ExecutionContext) Message(com.evolveum.midpoint.notifications.api.transports.Message) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Aggregations

Message (com.evolveum.midpoint.notifications.api.transports.Message)49 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)41 Test (org.testng.annotations.Test)39 Task (com.evolveum.midpoint.task.api.Task)32 CustomEventImpl (com.evolveum.midpoint.notifications.impl.events.CustomEventImpl)8 AbstractIntegrationTest (com.evolveum.midpoint.test.AbstractIntegrationTest)8 ExecutionContext (com.evolveum.midpoint.model.impl.scripting.ExecutionContext)4 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 AuditEventRecord (com.evolveum.midpoint.audit.api.AuditEventRecord)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 ArrayList (java.util.ArrayList)3 ProgressInformation (com.evolveum.midpoint.model.api.ProgressInformation)2 NotificationManager (com.evolveum.midpoint.notifications.api.NotificationManager)2 ModelEvent (com.evolveum.midpoint.notifications.api.events.ModelEvent)2 Transport (com.evolveum.midpoint.notifications.api.transports.Transport)2 TransportService (com.evolveum.midpoint.notifications.api.transports.TransportService)2 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)2 S_ItemEntry (com.evolveum.midpoint.prism.delta.builder.S_ItemEntry)2 ExpressionVariables (com.evolveum.midpoint.repo.common.expression.ExpressionVariables)2