Search in sources :

Example 21 with Message

use of com.evolveum.midpoint.notifications.api.transports.Message in project midpoint by Evolveum.

the class TestStrings method test100SimpleAssignmentStart.

// region Basic approval of a-test-1 to bob
/**
 * Assigns role `a-test-1` to `bob`. Checks the case and notifications.
 *
 * The case is in stage 1 of 3 (line manager).
 */
@Test
public void test100SimpleAssignmentStart() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    dummyTransport.clearMessages();
    when();
    assignRole(USER_BOB.oid, ROLE_A_TEST_1.oid, task, task.getResult());
    then();
    assertNotAssignedRole(getUser(USER_BOB.oid), ROLE_A_TEST_1.oid);
    CaseWorkItemType workItem = getWorkItem(task, result);
    display("Work item", workItem);
    CaseType aCase = CaseWorkItemUtil.getCaseRequired(workItem);
    display("wfTask", aCase);
    assertTriggers(aCase, 2);
    ApprovalContextType actx = aCase.getApprovalContext();
    ApprovalSchemaType schema = actx.getApprovalSchema();
    assertEquals("Wrong # of approval levels", 3, schema.getStage().size());
    assertApprovalLevel(schema, 1, "Line managers", "P5D", 2);
    assertApprovalLevel(schema, 2, "Security", "P7D", 1);
    assertApprovalLevel(schema, 3, "Role approvers (all)", "P5D", 2);
    assertStage(aCase, 1, 3, "Line managers", null);
    assertAssignee(workItem, USER_LECHUCK.oid, USER_LECHUCK.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);
    assertEquals("Wrong # of work items lifecycle messages", 3, lifecycleMessages.size());
    Map<String, Message> sorted = sortByRecipientsSingle(lifecycleMessages);
    assertMessage(sorted.get("lechuck@evolveum.com"), "lechuck@evolveum.com", "A new work item has been created", "Stage: Line managers (1/3)", "Allocated to: Captain LeChuck (lechuck)", "(in 5 days)");
    assertMessage(sorted.get("lechuck-deputy@evolveum.com"), "lechuck-deputy@evolveum.com", "A new work item has been created", "Stage: Line managers (1/3)", "Allocated to: Captain LeChuck (lechuck)", "(in 5 days)");
    assertMessage(sorted.get("lechuck-deputy-deputy@evolveum.com"), "lechuck-deputy-deputy@evolveum.com", "A new work item has been created", "Stage: Line managers (1/3)", "Allocated to: Captain LeChuck (lechuck)", "(in 5 days)");
    assertEquals("Wrong # of work items allocation messages", 3, allocationMessages.size());
    Map<String, Message> sorted2 = sortByRecipientsSingle(allocationMessages);
    assertMessage(sorted2.get("lechuck@evolveum.com"), "lechuck@evolveum.com", "Work item has been allocated to you", "Stage: Line managers (1/3)", "Allocated to: Captain LeChuck (lechuck)", "(in 5 days)");
    assertMessage(sorted2.get("lechuck-deputy@evolveum.com"), "lechuck-deputy@evolveum.com", "Work item has been allocated to you", "Stage: Line managers (1/3)", "Allocated to: Captain LeChuck (lechuck)", "(in 5 days)");
    assertMessage(sorted2.get("lechuck-deputy-deputy@evolveum.com"), "lechuck-deputy-deputy@evolveum.com", "Work item has been allocated to you", "Stage: Line managers (1/3)", "Allocated to: Captain LeChuck (lechuck)", "(in 5 days)");
    assertEquals("Wrong # of process messages", 1, processMessages.size());
    assertMessage(processMessages.get(0), "administrator@evolveum.com", "An approval case has been opened", "Case name: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"");
    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 22 with Message

use of com.evolveum.midpoint.notifications.api.transports.Message in project midpoint by Evolveum.

the class TestStrings method test220FormRoleAssignmentStart.

// endregion
// region Test form fulfillment
/**
 * Role `a-test-4` has `metarole-approval-role-approvers-form`,
 * so it is being approved with gathering additional information.
 *
 * Here we assign the role, starting the approval case.
 */
@Test
public void test220FormRoleAssignmentStart() throws Exception {
    PrismObject<UserType> bob = getUserFromRepo(USER_BOB.oid);
    login(bob);
    Task task = getTestTask();
    task.setOwner(bob);
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    dummyTransport.clearMessages();
    when();
    assignRole(USER_BOB.oid, ROLE_A_TEST_4.oid, task, task.getResult());
    then();
    login(userAdministrator);
    assertNotAssignedRole(getUser(USER_BOB.oid), ROLE_A_TEST_4.oid);
    List<CaseWorkItemType> workItems = getWorkItems(task, result);
    displayWorkItems("Work item after start", workItems);
    CaseType aCase = CaseWorkItemUtil.getCaseRequired(workItems.get(0));
    display("aCase", aCase);
    ApprovalContextType actx = aCase.getApprovalContext();
    ApprovalSchemaType schema = actx.getApprovalSchema();
    assertEquals("Wrong # of approval levels", 2, schema.getStage().size());
    assertApprovalLevel(schema, 1, "Line managers", "P5D", 2);
    assertApprovalLevel(schema, 2, "Role approvers (first)", "P5D", 2);
    assertStage(aCase, 1, 2, "Line managers", null);
    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);
    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 23 with Message

use of com.evolveum.midpoint.notifications.api.transports.Message in project midpoint by Evolveum.

the class TestStrings method test206ApproveByCheese.

/**
 * The work item is approved by `cheese`, stepping into stage 2 (security).
 *
 * Assigned to `elaine` and `barkeeper`.
 */
@Test
public void test206ApproveByCheese() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    dummyTransport.clearMessages();
    given();
    login(userAdministrator);
    clock.resetOverride();
    CaseWorkItemType workItem = getWorkItem(task, result);
    PrismObject<UserType> cheese = getUserFromRepo(USER_CHEESE.oid);
    login(cheese);
    when();
    caseService.completeWorkItem(WorkItemId.of(workItem), ApprovalUtils.createApproveOutput(prismContext).comment("OK. Cheese."), task, result);
    then();
    login(userAdministrator);
    List<CaseWorkItemType> workItems = getWorkItems(task, result);
    assertEquals("Wrong # of work items on level 2", 2, workItems.size());
    displayWorkItems("Work item after 1st approval", workItems);
    CaseType aCase = CaseWorkItemUtil.getCaseRequired(workItems.get(0));
    display("aCase after 1st approval", aCase);
    assertStage(aCase, 2, 3, "Security", null);
    assertTriggers(aCase, 4);
    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("guybrush@evolveum.com"), "guybrush@evolveum.com", "Work item has been completed", "Work item: Assigning role \"a-test-1\" to user \"Carla the Swordmaster\"", "Stage: Line managers (1/3)", "Escalation level: Line manager escalation (1)", "Originally allocated to: Guybrush Threepwood (guybrush)", "|Allocated to: Guybrush Threepwood (guybrush), Ignatius Cheese (cheese)|Allocated to: Ignatius Cheese (cheese), Guybrush Threepwood (guybrush)", "Carried out by: Ignatius Cheese (cheese)", "Result: Approved", "^Deadline:");
    assertMessage(sorted.get("cheese@evolveum.com"), "cheese@evolveum.com", "Work item has been completed", "Work item: Assigning role \"a-test-1\" to user \"Carla the Swordmaster\"", "Stage: Line managers (1/3)", "Escalation level: Line manager escalation (1)", "Originally allocated to: Guybrush Threepwood (guybrush)", "|Allocated to: Guybrush Threepwood (guybrush), Ignatius Cheese (cheese)|Allocated to: Ignatius Cheese (cheese), Guybrush Threepwood (guybrush)", "Carried out by: Ignatius Cheese (cheese)", "Result: Approved", "^Deadline:");
    assertMessage(sorted.get("elaine@evolveum.com"), "elaine@evolveum.com", "A new work item has been created", "Work item: Assigning role \"a-test-1\" to user \"Carla the Swordmaster\"", "Stage: Security (2/3)", "Allocated to: Elaine Marley (elaine)", "(in 7 days)", "^Result:");
    assertMessage(sorted.get("barkeeper@evolveum.com"), "barkeeper@evolveum.com", "A new work item has been created", "Work item: Assigning role \"a-test-1\" to user \"Carla the Swordmaster\"", "Stage: Security (2/3)", "Allocated to: Horridly Scarred Barkeep (barkeeper)", "(in 7 days)", "^Result:");
    Map<String, Message> sorted2 = sortByRecipientsSingle(allocationMessages);
    assertMessage(sorted2.get("guybrush@evolveum.com"), "guybrush@evolveum.com", "Work item has been completed", "Work item: Assigning role \"a-test-1\" to user \"Carla the Swordmaster\"", "Stage: Line managers (1/3)", "Escalation level: Line manager escalation (1)", "Originally allocated to: Guybrush Threepwood (guybrush)", "|Allocated to: Guybrush Threepwood (guybrush), Ignatius Cheese (cheese)|Allocated to: Ignatius Cheese (cheese), Guybrush Threepwood (guybrush)", "Carried out by: Ignatius Cheese (cheese)", "Result: Approved", "^Deadline:");
    assertMessage(sorted2.get("cheese@evolveum.com"), "cheese@evolveum.com", "Work item has been completed", "Work item: Assigning role \"a-test-1\" to user \"Carla the Swordmaster\"", "Stage: Line managers (1/3)", "Escalation level: Line manager escalation (1)", "Originally allocated to: Guybrush Threepwood (guybrush)", "|Allocated to: Guybrush Threepwood (guybrush), Ignatius Cheese (cheese)|Allocated to: Ignatius Cheese (cheese), Guybrush Threepwood (guybrush)", "Carried out by: Ignatius Cheese (cheese)", "Result: Approved", "^Deadline:");
    assertMessage(sorted2.get("elaine@evolveum.com"), "elaine@evolveum.com", "Work item has been allocated to you", "Work item: Assigning role \"a-test-1\" to user \"Carla the Swordmaster\"", "Stage: Security (2/3)", "Allocated to: Elaine Marley (elaine)", "(in 7 days)", "^Result:");
    assertMessage(sorted2.get("barkeeper@evolveum.com"), "barkeeper@evolveum.com", "Work item has been allocated to you", "Work item: Assigning role \"a-test-1\" to user \"Carla the Swordmaster\"", "Stage: Security (2/3)", "Allocated to: Horridly Scarred Barkeep (barkeeper)", "(in 7 days)", "^Result:");
    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 24 with Message

use of com.evolveum.midpoint.notifications.api.transports.Message in project midpoint by Evolveum.

the class TestStrings method test221FormApproveByLechuck.

/**
 * LeChuck approves, without providing the form. We move to stage 2 of 2 (Role approvers).
 */
@Test
public void test221FormApproveByLechuck() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    dummyTransport.clearMessages();
    given();
    login(userAdministrator);
    CaseWorkItemType workItem = getWorkItem(task, result);
    when();
    PrismObject<UserType> lechuck = getUserFromRepo(USER_LECHUCK.oid);
    login(lechuck);
    caseService.completeWorkItem(WorkItemId.of(workItem), ApprovalUtils.createApproveOutput(prismContext).comment("OK. LeChuck"), task, result);
    then();
    login(userAdministrator);
    assertNotAssignedRole(getUser(USER_BOB.oid), ROLE_A_TEST_4.oid);
    List<CaseWorkItemType> workItems = getWorkItems(task, result);
    displayWorkItems("Work item after 1st approval", workItems);
    CaseType aCase = CaseWorkItemUtil.getCaseRequired(workItems.get(0));
    assertStage(aCase, 2, 2, "Role approvers (first)", null);
    ApprovalStageDefinitionType level = ApprovalContextUtil.getCurrentStageDefinition(aCase);
    assertEquals("Wrong evaluation strategy", LevelEvaluationStrategyType.FIRST_DECIDES, level.getEvaluationStrategy());
    // notifications
    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();
    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 25 with Message

use of com.evolveum.midpoint.notifications.api.transports.Message in project midpoint by Evolveum.

the class TestStrings method test102SimpleAssignmentApproveByLechuck.

/**
 * User `lechuck` approves the assignment.
 *
 * The case is moved to stage 2 of 3 (security approval).
 */
@Test
public void test102SimpleAssignmentApproveByLechuck() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    dummyTransport.clearMessages();
    given();
    login(userAdministrator);
    CaseWorkItemType workItem = getWorkItem(task, result);
    when();
    PrismObject<UserType> lechuck = getUserFromRepo(USER_LECHUCK.oid);
    login(lechuck);
    caseService.completeWorkItem(WorkItemId.of(workItem), ApprovalUtils.createApproveOutput(prismContext).comment("OK. LeChuck"), task, result);
    then();
    login(userAdministrator);
    List<CaseWorkItemType> workItems = getWorkItems(task, result);
    displayWorkItems("Work item after 1st approval", workItems);
    assertEquals("Wrong # of work items on level 2", 2, workItems.size());
    CaseType aCase = getCase(CaseWorkItemUtil.getCaseRequired(workItem).getOid());
    display("case after 1st approval", aCase);
    assertStage(aCase, 2, 3, "Security", null);
    assertTriggers(aCase, 4);
    // notifications
    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", 5, lifecycleMessages.size());
    assertEquals("Wrong # of work items allocation messages", 5, allocationMessages.size());
    assertNull("process messages", processMessages);
    Map<String, Message> sorted = sortByRecipientsSingle(lifecycleMessages);
    assertMessage(sorted.get("lechuck@evolveum.com"), "lechuck@evolveum.com", "Work item has been completed", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Line managers (1/3)", "Allocated to: Captain LeChuck (lechuck)", "Result: Approved", "^Deadline:");
    assertMessage(sorted.get("lechuck-deputy@evolveum.com"), "lechuck-deputy@evolveum.com", "Work item has been completed", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Line managers (1/3)", "Allocated to: Captain LeChuck (lechuck)", "Result: Approved", "^Deadline:");
    assertMessage(sorted.get("lechuck-deputy-deputy@evolveum.com"), "lechuck-deputy-deputy@evolveum.com", "Work item has been completed", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Line managers (1/3)", "Allocated to: Captain LeChuck (lechuck)", "Result: Approved", "^Deadline:");
    assertMessage(sorted.get("elaine@evolveum.com"), "elaine@evolveum.com", "A new work item has been created", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Security (2/3)", "Allocated to: Elaine Marley (elaine)", "(in 7 days)", "^Result:");
    assertMessage(sorted.get("barkeeper@evolveum.com"), "barkeeper@evolveum.com", "A new work item has been created", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Security (2/3)", "Allocated to: Horridly Scarred Barkeep (barkeeper)", "(in 7 days)", "^Result:");
    Map<String, Message> sorted2 = sortByRecipientsSingle(allocationMessages);
    assertMessage(sorted2.get("lechuck@evolveum.com"), "lechuck@evolveum.com", "Work item has been completed", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Line managers (1/3)", "Allocated to: Captain LeChuck (lechuck)", "Result: Approved", "^Deadline:");
    assertMessage(sorted2.get("lechuck-deputy@evolveum.com"), "lechuck-deputy@evolveum.com", "Work item has been completed", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Line managers (1/3)", "Allocated to: Captain LeChuck (lechuck)", "Result: Approved", "^Deadline:");
    assertMessage(sorted2.get("lechuck-deputy-deputy@evolveum.com"), "lechuck-deputy-deputy@evolveum.com", "Work item has been completed", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Line managers (1/3)", "Allocated to: Captain LeChuck (lechuck)", "Result: Approved", "^Deadline:");
    assertMessage(sorted2.get("elaine@evolveum.com"), "elaine@evolveum.com", "Work item has been allocated to you", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Security (2/3)", "Allocated to: Elaine Marley (elaine)", "(in 7 days)", "^Result:");
    assertMessage(sorted2.get("barkeeper@evolveum.com"), "barkeeper@evolveum.com", "Work item has been allocated to you", "Work item: Assigning role \"a-test-1\" to user \"Ghost Pirate Bob\"", "Stage: Security (2/3)", "Allocated to: Horridly Scarred Barkeep (barkeeper)", "(in 7 days)", "^Result:");
    // events
    List<CaseEventType> events = assertEvents(aCase, 2);
    assertCompletionEvent(events.get(1), USER_LECHUCK.oid, USER_LECHUCK.oid, 1, WorkItemOutcomeType.APPROVE, "OK. LeChuck");
    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)

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