Search in sources :

Example 21 with SchemaRegistry

use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.

the class TestUcfDummy method test000PrismContextSanity.

@Test
public void test000PrismContextSanity() throws Exception {
    final String TEST_NAME = "test000PrismContextSanity";
    TestUtil.displayTestTile(TEST_NAME);
    SchemaRegistry schemaRegistry = PrismTestUtil.getPrismContext().getSchemaRegistry();
    PrismSchema schemaIcfc = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_CONFIGURATION);
    assertNotNull("ICFC schema not found in the context (" + SchemaConstants.NS_ICF_CONFIGURATION + ")", schemaIcfc);
    PrismContainerDefinition<ConnectorConfigurationType> configurationPropertiesDef = schemaIcfc.findContainerDefinitionByElementName(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME);
    assertNotNull("icfc:configurationProperties not found in icfc schema (" + SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME + ")", configurationPropertiesDef);
    PrismSchema schemaIcfs = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_SCHEMA);
    assertNotNull("ICFS schema not found in the context (" + SchemaConstants.NS_ICF_SCHEMA + ")", schemaIcfs);
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) ConnectorConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test)

Example 22 with SchemaRegistry

use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.

the class TestSanityLegacy method test000Integrity.

/**
     * Test integrity of the test setup.
     *
     * @throws SchemaException
     * @throws ObjectNotFoundException
     * @throws CommunicationException
     */
@Test
public void test000Integrity() throws Exception {
    final String TEST_NAME = "test000Integrity";
    TestUtil.displayTestTile(this, TEST_NAME);
    assertNotNull(modelWeb);
    assertNotNull(modelService);
    assertNotNull(repositoryService);
    assertTrue(isSystemInitialized());
    assertNotNull(taskManager);
    assertNotNull(prismContext);
    SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
    assertNotNull(schemaRegistry);
    // This is defined in extra schema. So this effectively checks whether the extra schema was loaded
    PrismPropertyDefinition shipStateDefinition = schemaRegistry.findPropertyDefinitionByElementName(MY_SHIP_STATE);
    assertNotNull("No my:shipState definition", shipStateDefinition);
    assertEquals("Wrong maxOccurs in my:shipState definition", 1, shipStateDefinition.getMaxOccurs());
    assertNoRepoCache();
    Task task = taskManager.createTaskInstance(TestSanityLegacy.class.getName() + ".test000Integrity");
    OperationResult result = task.getResult();
    // Check if OpenDJ resource was imported correctly
    PrismObject<ResourceType> openDjResource = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, result);
    display("Imported OpenDJ resource (repository)", openDjResource);
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, openDjResource.getOid());
    assertNoRepoCache();
    String ldapConnectorOid = openDjResource.asObjectable().getConnectorRef().getOid();
    PrismObject<ConnectorType> ldapConnector = repositoryService.getObject(ConnectorType.class, ldapConnectorOid, null, result);
    display("LDAP Connector: ", ldapConnector);
    // TODO: test if OpenDJ and Derby are running
    repositoryService.getObject(GenericObjectType.class, SAMPLE_CONFIGURATION_OBJECT_OID, null, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PrismAsserts.assertEqualsPolyString(com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 23 with SchemaRegistry

use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.

the class TestUcfDummyMulti method test000PrismContextSanity.

@Test
public void test000PrismContextSanity() throws Exception {
    final String TEST_NAME = "test000PrismContextSanity";
    TestUtil.displayTestTile(TEST_NAME);
    SchemaRegistry schemaRegistry = PrismTestUtil.getPrismContext().getSchemaRegistry();
    PrismSchema schemaIcfc = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_CONFIGURATION);
    assertNotNull("ICFC schema not found in the context (" + SchemaConstants.NS_ICF_CONFIGURATION + ")", schemaIcfc);
    PrismContainerDefinition<ConnectorConfigurationType> configurationPropertiesDef = schemaIcfc.findContainerDefinitionByElementName(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME);
    assertNotNull("icfc:configurationProperties not found in icfc schema (" + SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME + ")", configurationPropertiesDef);
    PrismSchema schemaIcfs = schemaRegistry.findSchemaByNamespace(SchemaConstants.NS_ICF_SCHEMA);
    assertNotNull("ICFS schema not found in the context (" + SchemaConstants.NS_ICF_SCHEMA + ")", schemaIcfs);
}
Also used : PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) ConnectorConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test)

Example 24 with SchemaRegistry

use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.

the class ConsistencyTest method test000Integrity.

/**
	 * Test integrity of the test setup.
	 */
@Test
public void test000Integrity() throws Exception {
    final String TEST_NAME = "test000Integrity";
    TestUtil.displayTestTile(this, TEST_NAME);
    assertNotNull(modelWeb);
    assertNotNull(modelService);
    assertNotNull(repositoryService);
    assertTrue(isSystemInitialized());
    assertNotNull(taskManager);
    assertNotNull(prismContext);
    SchemaRegistry schemaRegistry = prismContext.getSchemaRegistry();
    assertNotNull(schemaRegistry);
    // This is defined in extra schema. So this effectively checks whether
    // the extra schema was loaded
    PrismPropertyDefinition shipStateDefinition = schemaRegistry.findPropertyDefinitionByElementName(MY_SHIP_STATE);
    assertNotNull("No my:shipState definition", shipStateDefinition);
    assertEquals("Wrong maxOccurs in my:shipState definition", 1, shipStateDefinition.getMaxOccurs());
    assertNoRepoCache();
    OperationResult result = new OperationResult(ConsistencyTest.class.getName() + "." + TEST_NAME);
    // Check if OpenDJ resource was imported correctly
    PrismObject<ResourceType> openDjResource = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, result);
    display("Imported OpenDJ resource (repository)", openDjResource);
    AssertJUnit.assertEquals(RESOURCE_OPENDJ_OID, openDjResource.getOid());
    assertNoRepoCache();
    String ldapConnectorOid = openDjResource.asObjectable().getConnectorRef().getOid();
    PrismObject<ConnectorType> ldapConnector = repositoryService.getObject(ConnectorType.class, ldapConnectorOid, null, result);
    display("LDAP Connector: ", ldapConnector);
}
Also used : ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test) AbstractModelIntegrationTest(com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)

Example 25 with SchemaRegistry

use of com.evolveum.midpoint.prism.schema.SchemaRegistry in project midpoint by Evolveum.

the class AddOverwriteTest method addWithOverwriteResource.

@Test
public void addWithOverwriteResource() throws Exception {
    // GIVEN
    SchemaRegistry reg = prismContext.getSchemaRegistry();
    PrismPropertyDefinition def = reg.findPropertyDefinitionByElementName(CapabilitiesType.F_NATIVE);
    PrismObject<ResourceType> resource = prismContext.parseObject(RESOURCE_OPENDJ_FILE);
    OperationResult opResult = new OperationResult("Import resource");
    repositoryService.addObject(resource, null, opResult);
    opResult.computeStatus();
    AssertJUnit.assertTrue(opResult.isSuccess());
    PrismObject<ResourceType> resourceAfterAdd = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, opResult);
    MidPointAsserts.assertOid(resourceAfterAdd, RESOURCE_OPENDJ_OID);
    MidPointAsserts.assertVersion(resourceAfterAdd, 0);
    // Precondition
    assertNotNull("no schema", resourceAfterAdd.asObjectable().getSchema());
    assertNotNull("no capabilities", resourceAfterAdd.asObjectable().getCapabilities());
    resource.asObjectable().setSchema(null);
    resource.asObjectable().setCapabilities(null);
    // WHEN
    repositoryService.addObject(resource, RepoAddOptions.createOverwrite(), opResult);
    // THEN
    opResult.computeStatus();
    AssertJUnit.assertTrue(opResult.isSuccess());
    PrismObject<ResourceType> resourceAfterOverwrite = repositoryService.getObject(ResourceType.class, RESOURCE_OPENDJ_OID, null, opResult);
    MidPointAsserts.assertOid(resourceAfterOverwrite, RESOURCE_OPENDJ_OID);
    MidPointAsserts.assertVersion(resourceAfterOverwrite, 1);
    assertNull("schema not gone", resourceAfterOverwrite.asObjectable().getSchema());
    assertNull("capabilities not gone", resourceAfterOverwrite.asObjectable().getCapabilities());
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) Test(org.testng.annotations.Test)

Aggregations

SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)39 Test (org.testng.annotations.Test)26 PrismContext (com.evolveum.midpoint.prism.PrismContext)10 PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)6 Task (com.evolveum.midpoint.task.api.Task)6 QName (javax.xml.namespace.QName)6 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)5 ConnectorType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)4 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)3 PrismObjectDefinition (com.evolveum.midpoint.prism.PrismObjectDefinition)3 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)3 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 ConnectorConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorConfigurationType)3 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)2 EncryptionException (com.evolveum.midpoint.prism.crypto.EncryptionException)2