Search in sources :

Example 31 with ItemName

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);
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName)

Example 32 with ItemName

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();
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 33 with ItemName

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());
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 34 with ItemName

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());
}
Also used : ItemName(com.evolveum.midpoint.prism.path.ItemName) Document(org.w3c.dom.Document) Test(org.testng.annotations.Test) AbstractSchemaTest(com.evolveum.midpoint.schema.AbstractSchemaTest)

Example 35 with ItemName

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);
}
Also used : QName(javax.xml.namespace.QName) ItemName(com.evolveum.midpoint.prism.path.ItemName)

Aggregations

ItemName (com.evolveum.midpoint.prism.path.ItemName)89 Test (org.testng.annotations.Test)24 QName (javax.xml.namespace.QName)19 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)13 NotNull (org.jetbrains.annotations.NotNull)10 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)8 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 Task (com.evolveum.midpoint.task.api.Task)6 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)5 MUser (com.evolveum.midpoint.repo.sqale.qmodel.focus.MUser)5 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)5 Element (org.w3c.dom.Element)5 JdbcSession (com.evolveum.midpoint.repo.sqlbase.JdbcSession)4 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)4 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)4 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)4 ArrayList (java.util.ArrayList)4 ItemDefinition (com.evolveum.midpoint.prism.ItemDefinition)3