Search in sources :

Example 66 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestTracing method test200ClassLessValues.

/**
 * Tests class-less PCVs.
 */
@Test
public void test200ClassLessValues() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = getTestOperationResult();
    deleteReportDataObjects(result);
    when();
    ModelExecuteOptions options = executeOptions();
    options.tracingProfile(createModelAndProvisioningLoggingTracingProfile());
    ObjectDelta<UserType> delta = deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).add(new AssignmentType(prismContext).targetRef(ROLE_CLASS_LESS_VALUES.oid, RoleType.COMPLEX_TYPE)).asObjectDelta(USER_JIM.oid);
    executeChanges(delta, options, task, result);
    then();
    assertSuccess(result);
    assertUserAfter(USER_JIM.oid).assignments().assertAssignments(1).end().extensionContainer(NAME_MY_CONTAINER).assertSize(1).value(0).assertItemsExactly(NAME_VALUE, NAME_EMBEDDED);
    assertTraceCanBeParsed(result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractEmptyModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractEmptyModelIntegrationTest)

Example 67 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestMapping method test262ModifyUserLocalityRecon.

/**
 * MID-3661, MID-3674
 */
@Test
public void test262ModifyUserLocalityRecon() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = getTestOperationResult();
    getDummyResource(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME).resetBreakMode();
    DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
    displayDumpable("Dummy account before", dummyAccountBefore);
    when();
    ObjectDelta<UserType> objectDelta = createModifyUserReplaceDelta(USER_GUYBRUSH_OID, UserType.F_LOCALITY, PrismTestUtil.createPolyString(LOCALITY_SCABB_ISLAND));
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta);
    ModelExecuteOptions options = executeOptions().reconcile();
    modelService.executeChanges(deltas, options, task, result);
    then();
    assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(USER_GUYBRUSH_OID);
    display("User after", userAfter);
    assertUser(userAfter, USER_GUYBRUSH_OID, USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, USER_GUYBRUSH_GIVEN_NAME, USER_GUYBRUSH_FAMILY_NAME);
    String accountOid = getSingleLinkOid(userAfter);
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
    display("Repo shadow after", repoShadow);
    assertNoPostponedOperation(repoShadow);
    // Check account in dummy resource
    DummyAccount dummyAccountAfter = assertDummyAccount(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME, true);
    displayDumpable("Dummy account after", dummyAccountAfter);
    assertDummyAccountAttribute(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, LOCALITY_SCABB_ISLAND);
    assertDummyAccountAttribute(RESOURCE_DUMMY_LIGHT_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, DRINK_GIN, DRINK_MEZCAL, rumFrom(LOCALITY_SCABB_ISLAND));
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test)

Example 68 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestMapping method test212ModifyUserLocalityRecon.

/**
 * MID-3661
 */
@Test
public void test212ModifyUserLocalityRecon() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = getTestOperationResult();
    getDummyResource(RESOURCE_DUMMY_CRIMSON_NAME).resetBreakMode();
    DummyAccount dummyAccountBefore = getDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
    displayDumpable("Dummy account before", dummyAccountBefore);
    when();
    ObjectDelta<UserType> objectDelta = createModifyUserReplaceDelta(USER_GUYBRUSH_OID, UserType.F_LOCALITY, PrismTestUtil.createPolyString(LOCALITY_SCABB_ISLAND));
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta);
    ModelExecuteOptions options = executeOptions().reconcile();
    modelService.executeChanges(deltas, options, task, result);
    then();
    assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(USER_GUYBRUSH_OID);
    display("User after", userAfter);
    assertUser(userAfter, USER_GUYBRUSH_OID, USER_GUYBRUSH_USERNAME, USER_GUYBRUSH_FULL_NAME, USER_GUYBRUSH_GIVEN_NAME, USER_GUYBRUSH_FAMILY_NAME);
    String accountOid = getSingleLinkOid(userAfter);
    PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result);
    display("Repo shadow after", repoShadow);
    assertNoPostponedOperation(repoShadow);
    // Check account in dummy resource
    DummyAccount dummyAccountAfter = assertDummyAccount(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME, true);
    displayDumpable("Dummy account after", dummyAccountAfter);
    assertDummyAccountAttribute(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, LOCALITY_SCABB_ISLAND);
    assertDummyAccountAttribute(RESOURCE_DUMMY_CRIMSON_NAME, ACCOUNT_GUYBRUSH_DUMMY_USERNAME, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_DRINK_NAME, DRINK_VODKA, DRINK_WHISKY, "rum from Scabb Island");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test)

Example 69 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestMiscellaneous method test110RequestPrunedRole.

@Test
public void test110RequestPrunedRole() throws Exception {
    login(userAdministrator);
    Task task = getTestTask();
    OperationResult result = getTestOperationResult();
    given();
    ModelExecuteOptions options = executeOptions().partialProcessing(new PartialProcessingOptionsType().approvals(PartialProcessingTypeType.SKIP));
    assignRole(userJackOid, ROLE_GOLD.oid, options, task, result);
    assertAssignedRole(getUser(userJackOid), ROLE_GOLD.oid);
    when();
    assignRole(userJackOid, ROLE_SILVER.oid, task, result);
    then();
    result.computeStatus();
    TestUtil.assertInProgress("Operation NOT in progress", result);
    assertNotAssignedRole(userJackOid, ROLE_SILVER.oid, result);
    // complete the work item related to assigning role silver
    CaseWorkItemType workItem = getWorkItem(task, result);
    display("Work item", workItem);
    caseManager.completeWorkItem(WorkItemId.of(workItem), ApprovalUtils.createApproveOutput(prismContext), null, task, result);
    CaseType aCase = CaseWorkItemUtil.getCaseRequired(workItem);
    CaseType rootCase = getCase(aCase.getParentRef().getOid());
    waitForCaseClose(rootCase);
    // should be pruned without approval
    assertNotAssignedRole(userJackOid, ROLE_GOLD.oid, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 70 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestPreview method test100PurePreview.

/**
 * Use pure "previewChanges" and check the approval schema execution information.
 */
@Test
public void test100PurePreview() throws Exception {
    given();
    login(userAdministrator);
    Task task = getTestTask();
    OperationResult result = getTestOperationResult();
    ModelExecuteOptions options = executeOptions();
    options.getOrCreatePartialProcessing().setApprovals(PartialProcessingTypeType.PROCESS);
    when();
    ModelContext<UserType> modelContext = modelInteractionService.previewChanges(getAssignmentDeltas(), options, task, result);
    then();
    ApprovalSchemaExecutionInformationType execInfo = getSingleExecutionInformation(modelContext);
    displayExecutionInformation(execInfo);
    // Everything is "in the future", so we have to obtain approvers information from the execInfo.stage list
    assertThat(getFutureStageApprovers(execInfo, 1)).as("stage 1 approvers").containsExactlyInAnyOrder(USER_JANE.oid);
    assertThat(getFutureStageApprovers(execInfo, 2)).as("stage 2 approvers").containsExactlyInAnyOrder(USER_MARTIN.oid);
    assertThat(getFutureStageApprovers(execInfo, 3)).as("stage 3 approvers").containsExactlyInAnyOrder(USER_PETER.oid, USER_KATE.oid);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Aggregations

ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)80 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)47 Task (com.evolveum.midpoint.task.api.Task)45 Test (org.testng.annotations.Test)30 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)21 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)13 RestartResponseException (org.apache.wicket.RestartResponseException)6 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)5 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)3 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)3 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)3 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)3 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)3 ExecuteChangeOptionsDto (com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)3 NotNull (org.jetbrains.annotations.NotNull)3