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);
}
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);
}
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);
}
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);
}
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());
}
Aggregations