use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType in project midpoint by Evolveum.
the class ConsistencyTest method test124AddAccountDirectAlreadyExists.
//MID-1595, MID-1577
@Test
public void test124AddAccountDirectAlreadyExists() throws Exception {
final String TEST_NAME = "test124AddAccountDirectAlreadyExists";
TestUtil.displayTestTile(TEST_NAME);
OperationResult parentResult = new OperationResult(TEST_NAME);
Task task = taskManager.createTaskInstance();
SchemaHandlingType oldSchemaHandling = resourceTypeOpenDjrepo.getSchemaHandling();
SynchronizationType oldSynchronization = resourceTypeOpenDjrepo.getSynchronization();
try {
// we will reapply this schema handling after this test finish
ItemDefinition syncDef = resourceTypeOpenDjrepo.asPrismObject().getDefinition().findItemDefinition(ResourceType.F_SYNCHRONIZATION);
assertNotNull("null definition for sync delta", syncDef);
ObjectDeltaType omt = unmarshallValueFromFile(REQUEST_RESOURCE_MODIFY_SYNCHRONIZATION, ObjectDeltaType.class);
ObjectDelta objectDelta = DeltaConvertor.createObjectDelta(omt, prismContext);
repositoryService.modifyObject(ResourceType.class, RESOURCE_OPENDJ_OID, objectDelta.getModifications(), parentResult);
requestToExecuteChanges(REQUEST_RESOURCE_MODIFY_RESOURCE_SCHEMA, RESOURCE_OPENDJ_OID, ResourceType.class, task, null, parentResult);
PrismObject<ResourceType> res = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, parentResult);
// LOGGER.trace("resource schema handling after modify: {}",
// prismContext.silentMarshalObject(res.asObjectable(), LOGGER));
repoAddObjectFromFile(USER_ABOMBA_FILENAME, parentResult);
requestToExecuteChanges(REQUEST_USER_MODIFY_ADD_ACCOUNT_DIRECTLY, USER_ABOMBA_OID, UserType.class, task, null, parentResult);
String abombaOid = assertUserOneAccountRef(USER_ABOMBA_OID);
ShadowType abombaShadow = repositoryService.getObject(ShadowType.class, abombaOid, null, parentResult).asObjectable();
assertShadowName(abombaShadow, "uid=abomba,OU=people,DC=example,DC=com");
repoAddObjectFromFile(USER_ABOM_FILENAME, parentResult);
requestToExecuteChanges(REQUEST_USER_MODIFY_ADD_ACCOUNT_DIRECTLY, USER_ABOM_OID, UserType.class, task, null, parentResult);
String abomOid = assertUserOneAccountRef(USER_ABOM_OID);
ShadowType abomShadow = repositoryService.getObject(ShadowType.class, abomOid, null, parentResult).asObjectable();
assertShadowName(abomShadow, "uid=abomba1,OU=people,DC=example,DC=com");
ReferenceDelta abombaDeleteAccDelta = ReferenceDelta.createModificationDelete(ShadowType.class, UserType.F_LINK_REF, prismContext, new PrismReferenceValue(abombaOid));
ObjectDelta d = ObjectDelta.createModifyDelta(USER_ABOMBA_OID, abombaDeleteAccDelta, UserType.class, prismContext);
modelService.executeChanges(MiscSchemaUtil.createCollection(d), null, task, parentResult);
assertUserNoAccountRef(USER_ABOMBA_OID, parentResult);
repositoryService.getObject(ShadowType.class, abombaOid, null, parentResult);
ReferenceDelta abomDeleteAccDelta = ReferenceDelta.createModificationDelete(ShadowType.class, UserType.F_LINK_REF, prismContext, abomShadow.asPrismObject());
ObjectDelta d2 = ObjectDelta.createModifyDelta(USER_ABOM_OID, abomDeleteAccDelta, UserType.class, prismContext);
modelService.executeChanges(MiscSchemaUtil.createCollection(d2), null, task, parentResult);
assertUserNoAccountRef(USER_ABOM_OID, parentResult);
try {
repositoryService.getObject(ShadowType.class, abomOid, null, parentResult);
fail("Expected that shadow abom does not exist, but it is");
} catch (ObjectNotFoundException ex) {
// this is expected
} catch (Exception ex) {
fail("Expected object not found exception but got " + ex);
}
LOGGER.info("starting second execution request for user abomba");
OperationResult result = new OperationResult("Add account already exist result.");
requestToExecuteChanges(REQUEST_USER_MODIFY_ADD_ACCOUNT_DIRECTLY, USER_ABOMBA_OID, UserType.class, task, null, result);
String abombaOid2 = assertUserOneAccountRef(USER_ABOMBA_OID);
ShadowType abombaShadow2 = repositoryService.getObject(ShadowType.class, abombaOid2, null, result).asObjectable();
assertShadowName(abombaShadow2, "uid=abomba,OU=people,DC=example,DC=com");
result.computeStatus();
LOGGER.info("Displaying execute changes result");
display(result);
// return the previous changes of resource back
Collection<? extends ItemDelta> schemaHandlingDelta = ContainerDelta.createModificationReplaceContainerCollection(ResourceType.F_SCHEMA_HANDLING, resourceTypeOpenDjrepo.asPrismObject().getDefinition(), oldSchemaHandling.asPrismContainerValue().clone());
PropertyDelta syncDelta = PropertyDelta.createModificationReplaceProperty(ResourceType.F_SYNCHRONIZATION, resourceTypeOpenDjrepo.asPrismObject().getDefinition(), oldSynchronization);
((Collection) schemaHandlingDelta).add(syncDelta);
repositoryService.modifyObject(ResourceType.class, RESOURCE_OPENDJ_OID, schemaHandlingDelta, parentResult);
} catch (Exception ex) {
LOGGER.info("error: " + ex.getMessage(), ex);
throw ex;
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SchemaHandlingType in project midpoint by Evolveum.
the class TestSanityLegacy method checkOpenDjSchemaHandling.
private void checkOpenDjSchemaHandling(ResourceType resource, String source) {
SchemaHandlingType schemaHandling = resource.getSchemaHandling();
for (ResourceObjectTypeDefinitionType resObjectTypeDef : schemaHandling.getObjectType()) {
if (resObjectTypeDef.getKind() == ShadowKindType.ACCOUNT) {
String name = resObjectTypeDef.getIntent();
assertNotNull("Resource " + resource + " from " + source + " has an schemaHandlig account definition without intent", name);
assertNotNull("Account type " + name + " in " + resource + " from " + source + " does not have object class", resObjectTypeDef.getObjectClass());
}
if (resObjectTypeDef.getKind() == ShadowKindType.ENTITLEMENT) {
String name = resObjectTypeDef.getIntent();
assertNotNull("Resource " + resource + " from " + source + " has an schemaHandlig entitlement definition without intent", name);
assertNotNull("Entitlement type " + name + " in " + resource + " from " + source + " does not have object class", resObjectTypeDef.getObjectClass());
}
}
}
Aggregations