use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class TestActivation method test114ModifyUserJackEnable.
/**
* Re-enabling the user should enable the account as well. Even if the user is already enabled.
*
* TODO Sure? Enabling already enabled user is a phantom change. As such, it is now filtered out.
*/
@Test
public void test114ModifyUserJackEnable() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL);
XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();
// MID-6420
ModelExecuteOptions options = ModelExecuteOptions.create(prismContext).pushChanges();
// WHEN
modifyUserReplace(USER_JACK_OID, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, options, task, result, ActivationStatusType.ENABLED);
// THEN
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar();
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
assertUserJack(userJack, USER_JACK_FULL_NAME);
assertAdministrativeStatusEnabled(userJack);
assertDummyEnabled(ACCOUNT_JACK_DUMMY_USERNAME);
// No real change in effective status, therefore the enableTimestamp should be unchanged
assertEnableTimestampFocus(userJack, null, startTime);
assertAccounts(USER_JACK_OID, 1);
PrismObject<ShadowType> account = getShadowModel(accountOid);
assertAccountShadowModel(account, accountOid, ACCOUNT_JACK_DUMMY_USERNAME, getDummyResourceType());
assertAdministrativeStatusEnabled(account);
assertEnableTimestampShadow(account, startTime, endTime);
}
use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class TestConnectorDummyFake method test400UpgradeRawReplace.
@Test
public void test400UpgradeRawReplace() throws Exception {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
PrismObject<ResourceType> dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
ObjectDelta<ResourceType> resourceDelta = prismContext.deltaFactory().object().createEmptyModifyDelta(ResourceType.class, RESOURCE_DUMMY_FAKE_OID);
ReferenceDelta connectorRefDeltaReplace = prismContext.deltaFactory().reference().createModificationReplace(ResourceType.F_CONNECTOR_REF, getResourceDefinition(), connectorDummyOid);
resourceDelta.addModification(connectorRefDeltaReplace);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(resourceDelta);
ModelExecuteOptions options = executeOptions().raw();
// WHEN
modelService.executeChanges(deltas, options, task, result);
// THEN
result.computeStatus();
display("executeChanges result", result);
TestUtil.assertSuccess("executeChanges result", result);
assertUpgrade(dummyResourceModelBefore);
}
use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class TestModelServiceContract method test302ModifyAccountJackDummyBlue.
/**
* modify account blue directly + request reconcile. check old value in delta.
*/
@Test
public void test302ModifyAccountJackDummyBlue() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.FULL);
Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<>();
ObjectDelta<ShadowType> accountDelta = prismContext.deltaFactory().object().createModificationReplaceProperty(ShadowType.class, accountJackBlueOid, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributeFullnamePath(), "Cpt. Jack Sparrow");
accountDelta.addModificationReplaceProperty(getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME), "Queen Anne's Revenge");
deltas.add(accountDelta);
ModelExecuteOptions options = executeOptions().reconcile();
OperationsPerformanceMonitor.INSTANCE.clearGlobalPerformanceInformation();
when();
modelService.executeChanges(deltas, options, task, result);
then();
OperationsPerformanceInformationType performanceInformation = OperationsPerformanceInformationUtil.toOperationsPerformanceInformationType(OperationsPerformanceMonitor.INSTANCE.getGlobalPerformanceInformation());
displayValue("Operation performance (by name)", OperationsPerformanceInformationUtil.format(performanceInformation));
displayValue("Operation performance (by time)", OperationsPerformanceInformationUtil.format(performanceInformation, new AbstractStatisticsPrinter.Options(TEXT, TIME), null, null));
assertSuccess(result);
// Not sure why 2 ... but this is not a big problem now
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2);
PrismObject<UserType> userJack = getUser(USER_JACK_OID);
display("User after change execution", userJack);
// Fullname inbound mapping is not used because it is weak
assertUserJack(userJack, "Jack Sparrow", "Jack", "Sparrow");
String accountJackOid = getSingleLinkOid(userJack);
// Check shadow
PrismObject<ShadowType> accountShadow = repositoryService.getObject(ShadowType.class, accountJackOid, SelectorOptions.createCollection(GetOperationOptions.createRaw()), result);
assertAccountShadowRepo(accountShadow, accountJackBlueOid, USER_JACK_USERNAME, getDummyResourceType(RESOURCE_DUMMY_BLUE_NAME));
// Check account
// All the changes should be reflected to the account
modelService.getObject(ShadowType.class, accountJackOid, null, task, result);
assertAccountShadowRepo(accountShadow, accountJackBlueOid, USER_JACK_USERNAME, getDummyResourceType(RESOURCE_DUMMY_BLUE_NAME));
// Check account in dummy resource
assertDummyAccount(RESOURCE_DUMMY_BLUE_NAME, USER_JACK_USERNAME, "Cpt. Jack Sparrow", true);
// Check audit
displayDumpable("Audit", dummyAuditService);
dummyAuditService.assertSimpleRecordSanity();
dummyAuditService.assertRecords(2);
dummyAuditService.assertAnyRequestDeltas();
// lastProvisioningTimestamp, modify account
dummyAuditService.assertExecutionDeltas(0, 2);
dummyAuditService.assertHasDelta(0, ChangeType.MODIFY, UserType.class);
dummyAuditService.assertHasDelta(0, ChangeType.MODIFY, ShadowType.class);
dummyAuditService.assertOldValue(0, ChangeType.MODIFY, ShadowType.class, getDummyResourceController(RESOURCE_DUMMY_BLUE_NAME).getAttributeFullnamePath(), "Jack Sparrow");
// dummyAuditService.assertOldValue(0, ChangeType.MODIFY, ShadowType.class,
// dummyResourceCtl.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_SHIP_NAME));
dummyAuditService.assertTarget(USER_JACK_OID);
dummyAuditService.assertExecutionSuccess();
assertSteadyResources();
}
use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class TestEditSchema method test180LookupLanguagesReplaceObject.
@Test
public void test180LookupLanguagesReplaceObject() throws Exception {
given();
Task task = getTestTask();
OperationResult result = task.getResult();
PrismObject<LookupTableType> replacement = PrismTestUtil.parseObject(LOOKUP_LANGUAGES_REPLACEMENT_FILE);
ObjectDelta<LookupTableType> delta = DeltaFactory.Object.createAddDelta(replacement);
when();
ModelExecuteOptions options = executeOptions().overwrite();
options.raw(true);
modelService.executeChanges(MiscSchemaUtil.createCollection(delta), options, task, result);
then();
result.computeStatus();
TestUtil.assertSuccess(result);
PrismObject<LookupTableType> lookup = getLookupTableAll(LOOKUP_LANGUAGES_OID, task, result);
result.computeStatus();
TestUtil.assertSuccess(result);
IntegrationTestTools.display("Languages", lookup);
assertEquals("Wrong lang lookup name", "Languages Replaced", lookup.asObjectable().getName().getOrig());
PrismContainer<LookupTableRowType> tableContainer = lookup.findContainer(LookupTableType.F_ROW);
assertNotNull("Table container missing", tableContainer);
assertEquals("Unexpected table container size", 1, tableContainer.size());
assertLookupRow(tableContainer, "fr_FR", "fr", "Français");
assertSteadyResources();
}
use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class TestAssignmentValidity method test161JackAssignRoleSailorValidToRaw.
/**
* MID-4110
*/
@Test
public void test161JackAssignRoleSailorValidToRaw() 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, 2);
AssignmentType assignmentSailorTypeAfter = assertAssignedRole(userAfter, ROLE_STRONG_SAILOR_OID);
assertEffectiveActivation(assignmentSailorTypeAfter, null);
AssignmentType assignmentPirateTypeAfter = assertAssignedRole(userAfter, ROLE_PIRATE_OID);
assertEffectiveActivation(assignmentPirateTypeAfter, ActivationStatusType.ENABLED);
// SAILOR is not here, we are raw
assertRoleMembershipRef(userAfter, ROLE_PIRATE_OID);
assertDelegatedRef(userAfter);
assertJackDummyPirateAccount();
}
Aggregations