use of com.evolveum.midpoint.schema.processor.ResourceSchema in project midpoint by Evolveum.
the class AbstractManualResourceTest method test005ParsedSchema.
@Test
public void test005ParsedSchema() throws Exception {
final String TEST_NAME = "test005ParsedSchema";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME);
// THEN
// The returned type should have the schema pre-parsed
assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType));
// Also test if the utility method returns the same thing
ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext);
display("Parsed resource schema", resourceSchema);
// Check whether it is reusing the existing schema and not parsing it all over again
// Not equals() but == ... we want to really know if exactly the same
// object instance is returned
assertTrue("Broken caching", resourceSchema == RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext));
ObjectClassComplexTypeDefinition accountDef = resourceSchema.findObjectClassDefinition(RESOURCE_ACCOUNT_OBJECTCLASS);
assertNotNull("Account definition is missing", accountDef);
assertNotNull("Null identifiers in account", accountDef.getPrimaryIdentifiers());
assertFalse("Empty identifiers in account", accountDef.getPrimaryIdentifiers().isEmpty());
assertNotNull("No naming attribute in account", accountDef.getNamingAttribute());
assertEquals("Unexpected number of definitions", getNumberOfAccountAttributeDefinitions(), accountDef.getDefinitions().size());
ResourceAttributeDefinition<String> usernameDef = accountDef.findAttributeDefinition(ATTR_USERNAME);
assertNotNull("No definition for username", usernameDef);
assertEquals(1, usernameDef.getMaxOccurs());
assertEquals(1, usernameDef.getMinOccurs());
assertTrue("No username create", usernameDef.canAdd());
assertTrue("No username update", usernameDef.canModify());
assertTrue("No username read", usernameDef.canRead());
ResourceAttributeDefinition<String> fullnameDef = accountDef.findAttributeDefinition(ATTR_FULLNAME);
assertNotNull("No definition for fullname", fullnameDef);
assertEquals(1, fullnameDef.getMaxOccurs());
assertEquals(0, fullnameDef.getMinOccurs());
assertTrue("No fullname create", fullnameDef.canAdd());
assertTrue("No fullname update", fullnameDef.canModify());
assertTrue("No fullname read", fullnameDef.canRead());
}
use of com.evolveum.midpoint.schema.processor.ResourceSchema in project midpoint by Evolveum.
the class TestDummySchemaless method test005ParsedSchemaSchemaless.
/**
* This basically checks if the methods do not die on NPE
*/
@Test
public void test005ParsedSchemaSchemaless() throws Exception {
final String TEST_NAME = "test005ParsedSchemaSchemaless";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME);
// THEN
// The returned type should have the schema pre-parsed
assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceTypeSchemaless));
// Also test if the utility method returns the same thing
ResourceSchema returnedSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceTypeSchemaless, prismContext);
display("Parsed resource schema", returnedSchema);
assertNull("Unexpected schema after parsing", returnedSchema);
}
use of com.evolveum.midpoint.schema.processor.ResourceSchema in project midpoint by Evolveum.
the class TestDummySchemaless method test106GetObjectStaticSchema.
@Test
public void test106GetObjectStaticSchema() throws Exception {
final String TEST_NAME = "test106GetObjectStaticSchema";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME);
PrismObject<ResourceType> resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_STATIC_SCHEMA_OID, null, null, result);
assertNotNull("Resource is null", resource);
ResourceType resourceType = resource.asObjectable();
assertNotNull("No connector ref", resourceType.getConnectorRef());
assertNotNull("No connector ref OID", resourceType.getConnectorRef().getOid());
ResourceSchema returnedSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
display("Parsed resource schema", returnedSchema);
assertNotNull("Null resource schema", returnedSchema);
dummyResourceSchemalessCtl.assertDummyResourceSchemaSanity(returnedSchema, resource.asObjectable(), true);
}
Aggregations