use of com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType in project midpoint by Evolveum.
the class AbstractDummyTest method assertHasSchema.
protected void assertHasSchema(PrismObject<ResourceType> resource, String desc) throws SchemaException {
ResourceType resourceType = resource.asObjectable();
display("Resource " + desc, resourceType);
XmlSchemaType xmlSchemaTypeAfter = resourceType.getSchema();
assertNotNull("No schema in " + desc, xmlSchemaTypeAfter);
Element resourceXsdSchemaElementAfter = ResourceTypeUtil.getResourceXsdSchema(resourceType);
assertNotNull("No schema XSD element in " + desc, resourceXsdSchemaElementAfter);
String resourceXml = prismContext.serializeObjectToString(resource, PrismContext.LANG_XML);
// display("Resource XML", resourceXml);
CachingMetadataType cachingMetadata = xmlSchemaTypeAfter.getCachingMetadata();
assertNotNull("No caching metadata in " + desc, cachingMetadata);
assertNotNull("No retrievalTimestamp in " + desc, cachingMetadata.getRetrievalTimestamp());
assertNotNull("No serialNumber in " + desc, cachingMetadata.getSerialNumber());
Element xsdElement = ObjectTypeUtil.findXsdElement(xmlSchemaTypeAfter);
ResourceSchema parsedSchema = ResourceSchemaImpl.parse(xsdElement, resource.toString(), prismContext);
assertNotNull("No schema after parsing in " + desc, parsedSchema);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType in project midpoint by Evolveum.
the class AbstractDummyTest method assertSchemaMetadataUnchanged.
protected void assertSchemaMetadataUnchanged(PrismObject<ResourceType> resource) {
CachingMetadataType current = getSchemaCachingMetadata(resource);
assertEquals("Schema caching metadata changed", lastCachingMetadata, current);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType in project midpoint by Evolveum.
the class TestDummyHacks method test003Connection.
/**
* This should be the very first test that works with the resource.
*
* The original repository object does not have resource schema. The schema
* should be generated from the resource on the first use. This is the test
* that executes testResource and checks whether the schema was generated.
*/
@Test
public void test003Connection() throws Exception {
final String TEST_NAME = "test003Connection";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// Check that there is no schema before test (pre-condition)
ResourceType resourceBefore = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result).asObjectable();
assertNotNull("No connector ref", resourceBefore.getConnectorRef());
assertNotNull("No connector ref OID", resourceBefore.getConnectorRef().getOid());
ConnectorType connector = repositoryService.getObject(ConnectorType.class, resourceBefore.getConnectorRef().getOid(), null, result).asObjectable();
assertNotNull(connector);
XmlSchemaType xmlSchemaTypeBefore = resourceBefore.getSchema();
Element resourceXsdSchemaElementBefore = ResourceTypeUtil.getResourceXsdSchema(resourceBefore);
AssertJUnit.assertNull("Found schema before test connection. Bad test setup?", resourceXsdSchemaElementBefore);
// WHEN
OperationResult testResult = provisioningService.testResource(RESOURCE_DUMMY_OID, task);
// THEN
display("Test result", testResult);
TestUtil.assertSuccess("Test resource failed (result)", testResult);
PrismObject<ResourceType> resourceRepoAfter = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result);
ResourceType resourceTypeRepoAfter = resourceRepoAfter.asObjectable();
display("Resource after test", resourceTypeRepoAfter);
XmlSchemaType xmlSchemaTypeAfter = resourceTypeRepoAfter.getSchema();
assertNotNull("No schema after test connection", xmlSchemaTypeAfter);
Element resourceXsdSchemaElementAfter = ResourceTypeUtil.getResourceXsdSchema(resourceTypeRepoAfter);
assertNotNull("No schema after test connection", resourceXsdSchemaElementAfter);
String resourceXml = prismContext.serializeObjectToString(resourceRepoAfter, PrismContext.LANG_XML);
display("Resource XML", resourceXml);
CachingMetadataType cachingMetadata = xmlSchemaTypeAfter.getCachingMetadata();
assertNotNull("No caching metadata", cachingMetadata);
assertNotNull("No retrievalTimestamp", cachingMetadata.getRetrievalTimestamp());
assertNotNull("No serialNumber", cachingMetadata.getSerialNumber());
Element xsdElement = ObjectTypeUtil.findXsdElement(xmlSchemaTypeAfter);
ResourceSchema parsedSchema = ResourceSchemaImpl.parse(xsdElement, resourceBefore.toString(), prismContext);
assertNotNull("No schema after parsing", parsedSchema);
display("Parsed schema", parsedSchema);
ComplexTypeDefinition accountDef = parsedSchema.findComplexTypeDefinition(new QName(parsedSchema.getNamespace(), SchemaConstants.ACCOUNT_OBJECT_CLASS_LOCAL_NAME));
assertNotNull("No account definition in schema after parsing", accountDef);
PrismAsserts.assertPropertyDefinition(accountDef, SchemaConstants.ICFS_NAME, DOMUtil.XSD_STRING, 1, 1);
PrismAsserts.assertPropertyDefinition(accountDef, new QName(SchemaConstants.NS_ICF_SCHEMA, "description"), DOMUtil.XSD_STRING, 0, 1);
// The useless configuration variables should be reflected to the resource now
assertEquals("Wrong useless string", "Shiver me timbers!", dummyResource.getUselessString());
assertEquals("Wrong guarded useless string", "Dead men tell no tales", dummyResource.getUselessGuardedString());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType in project midpoint by Evolveum.
the class TestModelServiceContractCaching method assertShadowRepo.
@Override
protected void assertShadowRepo(PrismObject<ShadowType> shadow, String oid, String username, ResourceType resourceType, QName objectClass, MatchingRule<String> nameMatchingRule) throws SchemaException {
super.assertShadowRepo(shadow, oid, username, resourceType, objectClass, nameMatchingRule);
CachingMetadataType cachingMetadata = shadow.asObjectable().getCachingMetadata();
assertNotNull("Missing caching metadata in repo shadow" + shadow, cachingMetadata);
}
Aggregations