Search in sources :

Example 16 with ExpectedTask

use of com.evolveum.midpoint.wf.impl.ExpectedTask in project midpoint by Evolveum.

the class TestObjectLifecycleAdvanced method test045ActivateCompleteRole.

@Test
public void test045ActivateCompleteRole() throws Exception {
    login(userAdministrator);
    ObjectDelta<RoleType> activateRoleDelta = prismContext.deltaFor(RoleType.class).item(RoleType.F_LIFECYCLE_STATE).replace(SchemaConstants.LIFECYCLE_ACTIVE).item(RoleType.F_DESCRIPTION).replace("hi").asObjectDelta(roleEmployeeOid);
    executeTest(new TestDetails() {

        @Override
        protected LensContext createModelContext(OperationResult result) throws Exception {
            LensContext<RoleType> lensContext = createLensContext(RoleType.class);
            addFocusDeltaToContext(lensContext, activateRoleDelta);
            return lensContext;
        }

        @Override
        protected void afterFirstClockworkRun(CaseType rootCase, CaseType case0, List<CaseType> subcases, List<CaseWorkItemType> workItems, Task opTask, OperationResult result) throws Exception {
            ExpectedTask expectedTask = new ExpectedTask(null, "Matching state: after operation (\"active lifecycleState\")");
            ExpectedWorkItem expectedWorkItem = new ExpectedWorkItem(userEmployeeOwnerOid, null, expectedTask);
            assertWfContextAfterClockworkRun(rootCase, subcases, workItems, null, Collections.singletonList(expectedTask), Collections.singletonList(expectedWorkItem));
            ApprovalContextType wfc = subcases.get(0).getApprovalContext();
            assertEquals("Wrong # of attached policy rules entries", 1, wfc.getPolicyRules().getEntry().size());
            SchemaAttachedPolicyRuleType attachedRule = wfc.getPolicyRules().getEntry().get(0);
            assertEquals(1, attachedRule.getStageMin().intValue());
            assertEquals(1, attachedRule.getStageMax().intValue());
            assertEquals("Wrong # of attached triggers", 1, attachedRule.getRule().getTrigger().size());
            EvaluatedPolicyRuleTriggerType trigger = attachedRule.getRule().getTrigger().get(0);
            assertEquals("Wrong constraintKind in trigger", PolicyConstraintKindType.TRANSITION, trigger.getConstraintKind());
            CaseWorkItemType workItem = subcases.get(0).getWorkItem().get(0);
            assertEquals("Wrong # of additional information", 0, workItem.getAdditionalInformation().size());
        }

        @Override
        protected void afterCase0Finishes(CaseType rootCase, Task opTask, OperationResult result) {
        // assertNoObject(employee);
        }

        @Override
        protected void afterRootCaseFinishes(CaseType rootCase, List<CaseType> subcases, Task opTask, OperationResult result) {
        // assertObject(employee);
        }

        @Override
        protected boolean executeImmediately() {
            return false;
        }

        @Override
        protected Boolean decideOnApproval(CaseWorkItemType caseWorkItem) throws Exception {
            login(getUser(userEmployeeOwnerOid));
            return true;
        }
    }, 1);
}
Also used : ExpectedTask(com.evolveum.midpoint.wf.impl.ExpectedTask) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ExpectedWorkItem(com.evolveum.midpoint.wf.impl.ExpectedWorkItem) LensContext(com.evolveum.midpoint.model.impl.lens.LensContext) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ExpectedTask(com.evolveum.midpoint.wf.impl.ExpectedTask) Test(org.testng.annotations.Test)

Aggregations

ExpectedTask (com.evolveum.midpoint.wf.impl.ExpectedTask)16 ExpectedWorkItem (com.evolveum.midpoint.wf.impl.ExpectedWorkItem)16 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)14 Task (com.evolveum.midpoint.task.api.Task)14 Test (org.testng.annotations.Test)13 LensContext (com.evolveum.midpoint.model.impl.lens.LensContext)10 ApprovalInstruction (com.evolveum.midpoint.wf.impl.ApprovalInstruction)10 List (java.util.List)10 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)7 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)4 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)4 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 CaseWorkItemType (com.evolveum.midpoint.xml.ns._public.common.common_3.CaseWorkItemType)2 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)2 PrismObjectAsserter (com.evolveum.midpoint.test.asserter.prism.PrismObjectAsserter)1 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)1