use of com.evolveum.midpoint.prism.delta.ReferenceDelta in project midpoint by Evolveum.
the class TestPreviewChanges method modifyUserAddAccountImplicitExplicitSameReverse.
private void modifyUserAddAccountImplicitExplicitSameReverse(String bundleName, ObjectSource<PrismObject<ShadowType>> accountSource, ObjectChecker<ModelContext<UserType>> checker) throws Exception {
final String TEST_NAME = bundleName + "ImplicitExplicitSameReverse";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestPreviewChanges.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<ShadowType> account = accountSource.get();
ObjectDelta<UserType> userDelta = ObjectDelta.createEmptyModifyDelta(UserType.class, USER_JACK_OID, prismContext);
PrismReferenceValue accountRefVal = new PrismReferenceValue();
accountRefVal.setObject(account);
ReferenceDelta accountRefDelta = ReferenceDelta.createModificationAdd(UserType.F_LINK_REF, getUserDefinition(), accountRefVal);
userDelta.addModification(accountRefDelta);
ObjectDelta<ShadowType> accountDelta = account.createAddDelta();
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(accountDelta, userDelta);
doPreview(deltas, checker, task, result);
}
use of com.evolveum.midpoint.prism.delta.ReferenceDelta in project midpoint by Evolveum.
the class TestConnectorDummyFake method test450DowngradeRawReplace.
@Test
public void test450DowngradeRawReplace() throws Exception {
final String TEST_NAME = "test450DowngradeRawReplace";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
PrismObject<ResourceType> dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
ObjectDelta<ResourceType> resourceDelta = ObjectDelta.createEmptyModifyDelta(ResourceType.class, RESOURCE_DUMMY_FAKE_OID, prismContext);
ReferenceDelta connectorRefDeltaReplace = ReferenceDelta.createModificationReplace(ResourceType.F_CONNECTOR_REF, getResourceDefinition(), connectorDummyFakeOid);
resourceDelta.addModification(connectorRefDeltaReplace);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(resourceDelta);
ModelExecuteOptions options = ModelExecuteOptions.createRaw();
// WHEN
modelService.executeChanges(deltas, options, task, result);
// THEN
result.computeStatus();
display("executeChanges result", result);
TestUtil.assertSuccess("executeChanges result", result);
assertDowngrade(dummyResourceModelBefore);
}
use of com.evolveum.midpoint.prism.delta.ReferenceDelta in project midpoint by Evolveum.
the class TestConnectorDummyFake method test250DowngradeModelReplace.
@Test
public void test250DowngradeModelReplace() throws Exception {
final String TEST_NAME = "test250DowngradeModelReplace";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
PrismObject<ResourceType> dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
ObjectDelta<ResourceType> resourceDelta = ObjectDelta.createEmptyModifyDelta(ResourceType.class, RESOURCE_DUMMY_FAKE_OID, prismContext);
ReferenceDelta connectorRefDeltaReplace = ReferenceDelta.createModificationReplace(ResourceType.F_CONNECTOR_REF, getResourceDefinition(), connectorDummyFakeOid);
resourceDelta.addModification(connectorRefDeltaReplace);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(resourceDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
result.computeStatus();
display("executeChanges result", result);
TestUtil.assertSuccess("executeChanges result", result);
assertDowngrade(dummyResourceModelBefore);
}
use of com.evolveum.midpoint.prism.delta.ReferenceDelta in project midpoint by Evolveum.
the class TestConnectorDummyFake method test400UpgradeRawReplace.
@Test
public void test400UpgradeRawReplace() throws Exception {
final String TEST_NAME = "test400UpgradeRawReplace";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
PrismObject<ResourceType> dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
ObjectDelta<ResourceType> resourceDelta = ObjectDelta.createEmptyModifyDelta(ResourceType.class, RESOURCE_DUMMY_FAKE_OID, prismContext);
ReferenceDelta connectorRefDeltaReplace = ReferenceDelta.createModificationReplace(ResourceType.F_CONNECTOR_REF, getResourceDefinition(), connectorDummyOid);
resourceDelta.addModification(connectorRefDeltaReplace);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(resourceDelta);
ModelExecuteOptions options = ModelExecuteOptions.createRaw();
// 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.prism.delta.ReferenceDelta in project midpoint by Evolveum.
the class TestConnectorDummyFake method test100UpgradeModelAddDelete.
/**
* Upgrading connector in RESOURCE_DUMMY_FAKE by changing the connectorRef in resource (add/delete case)
* The connectorRef is changed from fake to real dummy.
*/
@Test
public void test100UpgradeModelAddDelete() throws Exception {
final String TEST_NAME = "test100UpgradeModelAddDelete";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
PrismObject<ResourceType> dummyResourceModelBefore = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
ObjectDelta<ResourceType> resourceDelta = ObjectDelta.createEmptyModifyDelta(ResourceType.class, RESOURCE_DUMMY_FAKE_OID, prismContext);
PrismReference connectorRef = resourceDummyFake.findReference(ResourceType.F_CONNECTOR_REF);
ReferenceDelta connectorRefDeltaDel = ReferenceDelta.createModificationDelete(ResourceType.F_CONNECTOR_REF, getResourceDefinition(), connectorRef.getValue().clone());
resourceDelta.addModification(connectorRefDeltaDel);
ReferenceDelta connectorRefDeltaAdd = ReferenceDelta.createModificationAdd(ResourceType.F_CONNECTOR_REF, getResourceDefinition(), connectorDummyOid);
resourceDelta.addModification(connectorRefDeltaAdd);
// Purge the schema. New connector schema is not compatible.
resourceDelta.addModificationReplaceContainer(ResourceType.F_SCHEMA);
display("Delta", resourceDelta);
Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(resourceDelta);
// WHEN
modelService.executeChanges(deltas, null, task, result);
// THEN
result.computeStatus();
display("executeChanges result", result);
TestUtil.assertSuccess("executeChanges result", result);
assertUpgrade(dummyResourceModelBefore);
}
Aggregations