Search in sources :

Example 76 with ModelExecuteOptions

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

the class TestResources method singleModify.

private void singleModify(CarefulAnt<ResourceType> ant, int iteration, Task task, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
    given();
    ItemDelta<?, ?> itemDelta = ant.createDelta(iteration);
    ObjectDelta<ResourceType> objectDelta = prismContext.deltaFactory().object().createModifyDelta(RESOURCE_DUMMY_OID, itemDelta, ResourceType.class);
    Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta);
    IntegrationTestTools.assertNoRepoThreadLocalCache();
    ModelExecuteOptions options = executeOptions().raw();
    when();
    modelService.executeChanges(deltas, options, task, result);
    then();
    IntegrationTestTools.assertNoRepoThreadLocalCache();
    Collection<SelectorOptions<GetOperationOptions>> getOptions = SelectorOptions.createCollection(GetOperationOptions.createRaw());
    PrismObject<ResourceType> resourceAfter = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, getOptions, task, result);
    SqlRepoTestUtil.assertVersionProgressOptional(lastVersion, resourceAfter.getVersion());
    lastVersion = resourceAfter.getVersion();
    displayValue("Version", lastVersion);
    Element xsdSchema = ResourceTypeUtil.getResourceXsdSchema(resourceAfter);
    if (xsdSchema != null) {
        String targetNamespace = xsdSchema.getAttribute("targetNamespace");
        assertNotNull("No targetNamespace in schema after application of " + objectDelta, targetNamespace);
    }
    IntegrationTestTools.assertNoRepoThreadLocalCache();
    ant.assertModification(resourceAfter, iteration);
}
Also used : SelectorOptions(com.evolveum.midpoint.schema.SelectorOptions) Element(org.w3c.dom.Element) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta)

Example 77 with ModelExecuteOptions

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

the class TestMemberRecompute method test100ChangeCostCenter.

/**
 * Changing DCS cost center. Member recomputation (directly in iterative task) is triggered by default.
 */
@Test
public void test100ChangeCostCenter() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = getTestOperationResult();
    when();
    ObjectDelta<OrgType> delta = deltaFor(OrgType.class).item(OrgType.F_COST_CENTER).replace("07999").asObjectDelta(ORG_DCS.oid);
    ModelExecuteOptions options = new ModelExecuteOptions(prismContext).setExtensionPropertyRealValues(prismContext, MEMBER_RECOMPUTATION_WORKER_THREADS_NAME, 3);
    executeChanges(delta, options, task, result);
    then();
    assertSuccess(result);
    String taskOid = result.findAsynchronousOperationReference();
    assertThat(taskOid).as("background task OID").isNotNull();
    Task recomputeTask = waitForTaskFinish(taskOid, false);
    assertTask(recomputeTask, "recompute task after").display().assertSuccess().assertArchetypeRef(SystemObjectsType.ARCHETYPE_ITERATIVE_BULK_ACTION_TASK.value());
    assertThat(recomputeTask.getRootActivityDefinitionOrClone().getDistribution().getWorkerThreads()).as("worker threads").isEqualTo(3);
    assertUserAfterByUsername("user-dcs-0000").assertCostCenter("07999");
    assertUserAfterByUsername("user-cc-0000").assertCostCenter("07330");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 78 with ModelExecuteOptions

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

the class TestPreviewChanges method test234PreviewGuybrushAddRolePirateRecon.

/**
 * MID-3079
 */
@Test
public void test234PreviewGuybrushAddRolePirateRecon() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
    ObjectDelta<UserType> delta = createAssignmentAssignmentHolderDelta(UserType.class, USER_GUYBRUSH_OID, ROLE_PIRATE_OID, RoleType.COMPLEX_TYPE, null, null, null, true);
    ModelExecuteOptions options = executeOptions().reconcile();
    // WHEN
    when();
    ModelContext<UserType> modelContext = modelInteractionService.previewChanges(MiscSchemaUtil.createCollection(delta), options, task, result);
    // THEN
    then();
    displayDumpable("Preview context", modelContext);
    assertNotNull("Null model context", modelContext);
    assertSuccess(result);
    ModelElementContext<UserType> focusContext = modelContext.getFocusContext();
    assertNotNull("Model focus context missing", focusContext);
    Collection<? extends ModelProjectionContext> projectionContexts = modelContext.getProjectionContexts();
    assertNotNull("Null model projection context list", projectionContexts);
    assertEquals("Unexpected number of projection contexts", 1, projectionContexts.size());
    ModelProjectionContext accContext = projectionContexts.iterator().next();
    assertNotNull("Null model projection context", accContext);
    ObjectDelta<ShadowType> accountPrimaryDelta = accContext.getPrimaryDelta();
    assertNull("Unexpected account primary delta", accountPrimaryDelta);
    ObjectDelta<ShadowType> accountSecondaryDelta = accContext.getSecondaryDelta();
    assertEquals(ChangeType.MODIFY, accountSecondaryDelta.getChangeType());
    assertAccountDefaultDummyAttributeModify(accountSecondaryDelta, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_TITLE_NAME, // old
    new String[] { "Great Pirate" }, // add
    new String[] { ROLE_PIRATE_TITLE }, // delete
    null, // replace
    null);
    assertAccountDefaultDummyAttributeModify(accountSecondaryDelta, DUMMY_ACCOUNT_ATTRIBUTE_SEA_NAME, // old
    null, // add
    null, // delete
    null, // replace
    new String[] { "guybrush sailed The Seven Seas, immediately , role , with this The Seven Seas while focused on  (in Pirate)" });
    assertAccountDefaultDummyAttributeModify(accountSecondaryDelta, DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_GOSSIP_NAME, // old
    null, // add
    new String[] { "Guybrush Threepwood is the best pirate Melee Island has ever seen" }, // delete
    null, // replace
    null);
    PrismAsserts.assertModifications(accountSecondaryDelta, 3);
    assertSerializable(modelContext);
}
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 79 with ModelExecuteOptions

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

the class TestLoggingConfiguration method test004OverwriteInitialConfiguration.

/**
 * Overwrite initial system configuration by itself. Check that everything
 * still works.
 */
@Test
public void test004OverwriteInitialConfiguration() throws Exception {
    // GIVEN
    LogfileTestTailer tailer = new LogfileTestTailer(LoggingConfigurationManager.AUDIT_LOGGER_NAME);
    Task task = createPlainTask();
    OperationResult result = task.getResult();
    PrismObject<SystemConfigurationType> systemConfiguration = getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value());
    String previousVersion = systemConfiguration.getVersion();
    systemConfiguration.setVersion(null);
    // precondition
    tailer.logAndTail();
    assertBasicLogging(tailer);
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.PROVISIONING.name());
    ObjectDelta<SystemConfigurationType> delta = DeltaFactory.Object.createAddDelta(systemConfiguration);
    ModelExecuteOptions options = executeOptions().overwrite();
    // WHEN
    modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result);
    // THEN
    result.computeStatus();
    TestUtil.assertSuccess(result);
    tailer.logAndTail();
    assertBasicLogging(tailer);
    tailer.assertMarkerLogged(LogfileTestTailer.LEVEL_TRACE, ProfilingDataManager.Subsystem.PROVISIONING.name());
    tailer.close();
    PrismObject<SystemConfigurationType> systemConfigurationNew = getObject(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value());
    String newVersion = systemConfigurationNew.getVersion();
    assertTrue("Versions do not follow: " + previousVersion + " -> " + newVersion, Integer.parseInt(previousVersion) < Integer.parseInt(newVersion));
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) 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 80 with ModelExecuteOptions

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

the class TestAssignmentValidity method test140JackAssignRoleSailorValidToRaw.

/**
 * This time do not recompute. Just set everything up, let the assignment expire
 * and assign the role again.
 * MID-4110
 */
@Test
public void test140JackAssignRoleSailorValidToRaw() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    PrismObject<UserType> userBefore = getUser(USER_JACK_OID);
    display("User jack before", userBefore);
    ActivationType activationType = new ActivationType();
    jackPirateValidTo = getTimestamp("PT10M");
    activationType.setValidTo(jackPirateValidTo);
    ModelExecuteOptions options = executeOptions().raw();
    // WHEN
    when();
    modifyUserAssignment(USER_JACK_OID, ROLE_STRONG_SAILOR_OID, RoleType.COMPLEX_TYPE, null, task, null, activationType, true, options, result);
    // THEN
    then();
    assertSuccess(result);
    PrismObject<UserType> userAfter = getUser(USER_JACK_OID);
    display("User jack after", userAfter);
    assertAssignments(userAfter, 1);
    AssignmentType assignmentTypeAfter = assertAssignedRole(userAfter, ROLE_STRONG_SAILOR_OID);
    assertEffectiveActivation(assignmentTypeAfter, null);
    assertRoleMembershipRef(userAfter);
    assertDelegatedRef(userAfter);
    assertNoDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
}
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