use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.
the class TestDummyNoActivation method test158DeleteValidToValidFrom.
@Override
public void test158DeleteValidToValidFrom() throws Exception {
final String TEST_NAME = "test158DeleteValidToValidFrom";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(TestDummy.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
syncServiceMock.reset();
ObjectDelta<ShadowType> delta = ObjectDelta.createModificationDeleteProperty(ShadowType.class, ACCOUNT_WILL_OID, SchemaConstants.PATH_ACTIVATION_VALID_TO, prismContext, XmlTypeConverter.createXMLGregorianCalendar(VALID_TO_MILLIS));
PrismObjectDefinition def = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class);
PropertyDelta validFromDelta = PropertyDelta.createModificationDeleteProperty(SchemaConstants.PATH_ACTIVATION_VALID_FROM, def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_VALID_FROM), XmlTypeConverter.createXMLGregorianCalendar(VALID_FROM_MILLIS));
delta.addModification(validFromDelta);
delta.checkConsistence();
try {
// WHEN
provisioningService.modifyObject(ShadowType.class, delta.getOid(), delta.getModifications(), new OperationProvisioningScriptsType(), null, task, result);
AssertJUnit.fail("Unexpected success");
} catch (SchemaException e) {
// This is expected
}
// THEN
result.computeStatus();
display("modifyObject result", result);
TestUtil.assertFailure(result);
delta.checkConsistence();
// check if activation was changed
DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_WILL_USERNAME);
assertTrue("Dummy account " + ACCOUNT_WILL_USERNAME + " is disabled, expected enabled", dummyAccount.isEnabled());
assertNull("Unexpected account validFrom in account " + ACCOUNT_WILL_USERNAME + ": " + dummyAccount.getValidFrom(), dummyAccount.getValidFrom());
assertNull("Unexpected account validTo in account " + ACCOUNT_WILL_USERNAME + ": " + dummyAccount.getValidTo(), dummyAccount.getValidTo());
syncServiceMock.assertNotifyFailureOnly();
assertSteadyResource();
}
use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.
the class AbstractOrgClosureTest method removeObjectParent.
protected void removeObjectParent(ObjectType object, ObjectReferenceType parentOrgRef, boolean useReplace, OperationResult opResult) throws Exception {
List<ItemDelta> modifications = new ArrayList<>();
if (!useReplace) {
// standard case
PrismReferenceValue existingValue = parentOrgRef.asReferenceValue();
ItemDelta removeParent = ReferenceDelta.createModificationDelete(object.getClass(), OrgType.F_PARENT_ORG_REF, prismContext, existingValue.clone());
modifications.add(removeParent);
} else {
// using REPLACE modification
List<PrismReferenceValue> newValues = new ArrayList<>();
for (ObjectReferenceType ort : object.getParentOrgRef()) {
if (!ort.getOid().equals(parentOrgRef.getOid())) {
newValues.add(ort.asReferenceValue().clone());
}
}
PrismObjectDefinition objectDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(object.getClass());
ItemDelta replaceParent = ReferenceDelta.createModificationReplace(new ItemPath(OrgType.F_PARENT_ORG_REF), objectDefinition, newValues);
modifications.add(replaceParent);
}
repositoryService.modifyObject(object.getClass(), object.getOid(), modifications, opResult);
if (object instanceof OrgType) {
orgGraph.removeEdge(object.getOid(), parentOrgRef.getOid());
}
}
use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.
the class ModifyUser method test100ModifyUserApproverMetadata.
@Test
public void test100ModifyUserApproverMetadata() throws Exception {
PrismObjectDefinition userDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
ReferenceDelta delta1 = ReferenceDelta.createModificationAdd(new ItemPath(UserType.F_METADATA, MetadataType.F_CREATE_APPROVER_REF), userDefinition, new PrismReferenceValue("target-oid-1", UserType.COMPLEX_TYPE));
ReferenceDelta delta2 = ReferenceDelta.createModificationAdd(new ItemPath(UserType.F_METADATA, MetadataType.F_MODIFY_APPROVER_REF), userDefinition, // the same as in delta1
new PrismReferenceValue("target-oid-1", UserType.COMPLEX_TYPE));
repositoryService.modifyObject(UserType.class, userOid, Arrays.asList(delta1, delta2), new OperationResult("asdf"));
}
use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.
the class ModifyUser method test050ModifyBigUser.
@Test
public void test050ModifyBigUser() throws Exception {
PrismObjectDefinition def = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
PropertyDelta delta = PropertyDelta.createModificationReplaceProperty(ObjectType.F_DESCRIPTION, def, "new description");
repositoryService.modifyObject(UserType.class, userBigOid, Arrays.asList(delta), new OperationResult("asdf"));
}
use of com.evolveum.midpoint.prism.PrismObjectDefinition in project midpoint by Evolveum.
the class SchemaDocMojo method renderSchema.
private void renderSchema(PrismSchema schema, PrismContext prismContext, VelocityEngine velocityEngine, PathGenerator pathGenerator) throws IOException {
getLog().info("Processing schema: " + schema);
VelocityContext velocityContext = new VelocityContext();
populateVelocityContextBase(velocityContext, prismContext, pathGenerator, schema, "..");
Template template = velocityEngine.getTemplate(TEMPLATE_SCHEMA_NAME);
Writer writer = new FileWriter(pathGenerator.prepareSchemaOutputFile(schema));
template.merge(velocityContext, writer);
writer.close();
// Object Definitions
for (PrismObjectDefinition objectDefinition : schema.getObjectDefinitions()) {
renderObjectDefinition(objectDefinition, schema, prismContext, velocityEngine, pathGenerator);
}
// Types
for (ComplexTypeDefinition typeDefinition : schema.getComplexTypeDefinitions()) {
renderComplexTypeDefinition(typeDefinition, schema, prismContext, velocityEngine, pathGenerator);
}
}
Aggregations