use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class TestSchemaSanity method assertPropertyValue.
public static void assertPropertyValue(PrismContainer<?> container, String propName, Object propValue) {
ItemName propQName = new ItemName(SchemaConstantsGenerated.NS_COMMON, propName);
PrismAsserts.assertPropertyValue(container, propQName, propValue);
}
use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class TestParseDiffPatch method testResource.
@Test
public void testResource() throws Exception {
PrismObject<ResourceType> resourceBefore = PrismTestUtil.parseObject(RESOURCE_BEFORE_FILE);
PrismObject<ResourceType> resourceAfter = PrismTestUtil.parseObject(RESOURCE_AFTER_FILE);
resourceBefore.checkConsistence();
resourceAfter.checkConsistence();
// sanity
assertFalse("Equals does not work", resourceBefore.equals(resourceAfter));
// WHEN
ObjectDelta<ResourceType> resourceDelta = resourceBefore.diff(resourceAfter);
// THEN
System.out.println("DELTA:");
System.out.println(resourceDelta.debugDump());
resourceDelta.checkConsistence();
resourceDelta.assertDefinitions(true);
resourceBefore.checkConsistence();
resourceAfter.checkConsistence();
assertEquals("Wrong delta OID", RESOURCE_OID, resourceDelta.getOid());
assertEquals("Wrong change type", ChangeType.MODIFY, resourceDelta.getChangeType());
Collection<? extends ItemDelta> modifications = resourceDelta.getModifications();
assertEquals("Unexpected number of modifications", 7, modifications.size());
PrismAsserts.assertContainerDeleteGetContainerDelta(resourceDelta, ResourceType.F_SCHEMA);
PrismAsserts.assertPropertyReplace(resourceDelta, pathTimeouts("update"), 3);
PrismAsserts.assertPropertyReplace(resourceDelta, pathTimeouts("scriptOnResource"), 4);
PrismAsserts.assertPropertyDelete(resourceDelta, ItemPath.create(ResourceType.F_CONNECTOR_CONFIGURATION, new ItemName(SchemaTestConstants.NS_ICFC, "producerBufferSize")), 100);
ItemPath correlationPath = ItemPath.create(ResourceType.F_SYNCHRONIZATION, SynchronizationType.F_OBJECT_SYNCHRONIZATION, 1L, ObjectSynchronizationType.F_CORRELATION);
ItemDelta<?, ?> correlationDelta = resourceDelta.findItemDelta(correlationPath);
assertThat(correlationDelta).as("correlation delta").isNotNull();
assertThat(correlationDelta.getValuesToAdd()).as("values to add in correlation delta").hasSize(1);
assertThat(correlationDelta.getValuesToDelete()).as("values to delete in correlation delta").hasSize(1);
// The following does not work:
// PrismAsserts.assertPropertyDelete(resourceDelta, correlationPath, resourceBefore.findProperty(correlationPath).getValue());
// PrismAsserts.assertPropertyAdd(resourceDelta, correlationPath, resourceAfter.findProperty(correlationPath).getValue());
// Configuration properties changes
assertConfigurationPropertyChange(resourceDelta, "principal");
assertConfigurationPropertyChange(resourceDelta, "credentials");
resourceDelta.checkConsistence();
resourceBefore.checkConsistence();
resourceAfter.checkConsistence();
}
use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class TestParseUserPolyString method testSkipItems.
@Test
public void testSkipItems() throws SchemaException, IOException {
PrismContext prismContext = getPrismContext();
PrismObject<UserType> jack = prismContext.parserFor(getFile()).language(language).parse();
String serialized = prismContext.serializerFor(language).itemsToSkip(Arrays.asList(UserType.F_ORGANIZATIONAL_UNIT, UserType.F_LINK_REF, UserType.F_ASSIGNMENT)).options(SerializationOptions.createSkipIndexOnly()).serialize(jack);
System.out.println("Serialization with org unit, linkRef and assignment skipped:\n" + serialized);
PrismObject<UserType> jackReparsed = prismContext.parserFor(serialized).language(language).parse();
assertEquals("Wrong # of org units", 0, jackReparsed.asObjectable().getOrganizationalUnit().size());
assertEquals("Wrong # of assignments", 0, jackReparsed.asObjectable().getAssignment().size());
assertEquals("Wrong # of links", 0, jackReparsed.asObjectable().getLinkRef().size());
assertNotNull("ext:stringType is not present", jackReparsed.getExtensionContainerValue().find(new ItemName("stringType")));
PrismProperty<String> hiddenProperty = jackReparsed.getExtensionContainerValue().findProperty(new ItemName("hidden"));
assertNotNull("ext:hidden is missing", hiddenProperty);
assertEquals("ext:hidden has wrong # of values", 0, hiddenProperty.size());
assertTrue("ext:hidden is not incomplete", hiddenProperty.isIncomplete());
}
use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class SchemaProcessorTest method testAccessList.
@Test
public void testAccessList() throws Exception {
final String icfNS = "http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3";
String filename = "src/test/resources/processor/resource-schema-complex.xsd";
Document schemaDom = DOMUtil.parseFile(filename);
ResourceSchema schema = ResourceSchemaParser.parse(DOMUtil.getFirstChildElement(schemaDom), filename);
ResourceObjectDefinition objectDef = schema.findDefinitionForObjectClass(new ItemName(MidPointConstants.NS_RI, "AccountObjectClass"));
assertNotNull("AccountObjectClass definition not found", objectDef);
ResourceAttributeDefinition attrDef = objectDef.findAttributeDefinition(new ItemName(icfNS, "uid"));
AssertJUnit.assertTrue("uid readability", attrDef.canRead());
AssertJUnit.assertFalse("uid updateability", attrDef.canModify());
AssertJUnit.assertFalse("uid createability", attrDef.canAdd());
attrDef = objectDef.findAttributeDefinition(new ItemName(MidPointConstants.NS_RI, "title"));
AssertJUnit.assertTrue(attrDef.canRead());
AssertJUnit.assertTrue(attrDef.canModify());
AssertJUnit.assertTrue(attrDef.canAdd());
attrDef = objectDef.findAttributeDefinition(new ItemName(MidPointConstants.NS_RI, "photo"));
AssertJUnit.assertFalse(attrDef.canRead());
AssertJUnit.assertTrue(attrDef.canModify());
AssertJUnit.assertTrue(attrDef.canAdd());
}
use of com.evolveum.midpoint.prism.path.ItemName in project midpoint by Evolveum.
the class RelationModel method setObject.
@Override
public void setObject(String object) {
QName newRelation = null;
if (QNameUtil.isUri(object)) {
newRelation = QNameUtil.uriToQName(object);
} else {
new ItemName(SchemaConstants.NS_ORG, object);
}
baseModel.setObject(newRelation);
}
Aggregations