use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.
the class AbstractBasicDummyTest method test030ResourceAndConnectorCaching.
@Test
public void test030ResourceAndConnectorCaching() throws Exception {
TestUtil.displayTestTile("test030ResourceAndConnectorCaching");
// GIVEN
OperationResult result = new OperationResult(TestOpenDj.class.getName() + ".test010ResourceAndConnectorCaching");
ConnectorInstance configuredConnectorInstance = resourceManager.getConfiguredConnectorInstance(resource, ReadCapabilityType.class, false, result);
assertNotNull("No configuredConnectorInstance", configuredConnectorInstance);
ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
assertNotNull("No resource schema", resourceSchema);
// WHEN
PrismObject<ResourceType> resourceAgain = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result);
// THEN
result.computeStatus();
display("getObject result", result);
TestUtil.assertSuccess(result);
ResourceType resourceTypeAgain = resourceAgain.asObjectable();
assertNotNull("No connector ref", resourceTypeAgain.getConnectorRef());
assertNotNull("No connector ref OID", resourceTypeAgain.getConnectorRef().getOid());
PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
PrismContainer<Containerable> configurationContainerAgain = resourceAgain.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
assertTrue("Configurations not equivalent", configurationContainer.equivalent(configurationContainerAgain));
// Check resource schema caching
ResourceSchema resourceSchemaAgain = RefinedResourceSchemaImpl.getResourceSchema(resourceAgain, prismContext);
assertNotNull("No resource schema (again)", resourceSchemaAgain);
assertTrue("Resource schema was not cached", resourceSchema == resourceSchemaAgain);
// Check capabilities caching
CapabilitiesType capabilitiesType = resourceType.getCapabilities();
assertNotNull("No capabilities fetched from provisioning", capabilitiesType);
CachingMetadataType capCachingMetadataType = capabilitiesType.getCachingMetadata();
assertNotNull("No capabilities caching metadata fetched from provisioning", capCachingMetadataType);
CachingMetadataType capCachingMetadataTypeAgain = resourceTypeAgain.getCapabilities().getCachingMetadata();
assertEquals("Capabilities caching metadata serial number has changed", capCachingMetadataType.getSerialNumber(), capCachingMetadataTypeAgain.getSerialNumber());
assertEquals("Capabilities caching metadata timestamp has changed", capCachingMetadataType.getRetrievalTimestamp(), capCachingMetadataTypeAgain.getRetrievalTimestamp());
// Rough test if everything is fine
resource.asObjectable().setFetchResult(null);
resourceAgain.asObjectable().setFetchResult(null);
ObjectDelta<ResourceType> dummyResourceDiff = DiffUtil.diff(resource, resourceAgain);
display("Dummy resource diff", dummyResourceDiff);
assertTrue("The resource read again is not the same as the original. diff:" + dummyResourceDiff, dummyResourceDiff.isEmpty());
// Now we stick our nose deep inside the provisioning impl. But we need
// to make sure that the
// configured connector is properly cached
ConnectorInstance configuredConnectorInstanceAgain = resourceManager.getConfiguredConnectorInstance(resourceAgain, ReadCapabilityType.class, false, result);
assertNotNull("No configuredConnectorInstance (again)", configuredConnectorInstanceAgain);
assertTrue("Connector instance was not cached", configuredConnectorInstance == configuredConnectorInstanceAgain);
// Check if the connector still works.
OperationResult testResult = new OperationResult(TestOpenDj.class.getName() + ".test010ResourceAndConnectorCaching.test");
configuredConnectorInstanceAgain.test(testResult);
testResult.computeStatus();
TestUtil.assertSuccess("Connector test failed", testResult);
// Test connection should also refresh the connector by itself. So check if it has been refreshed
ConnectorInstance configuredConnectorInstanceAfterTest = resourceManager.getConfiguredConnectorInstance(resourceAgain, ReadCapabilityType.class, false, result);
assertNotNull("No configuredConnectorInstance (again)", configuredConnectorInstanceAfterTest);
assertTrue("Connector instance was not cached", configuredConnectorInstanceAgain == configuredConnectorInstanceAfterTest);
assertSteadyResource();
}
use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.
the class AbstractBasicDummyTest method test031ResourceAndConnectorCachingForceFresh.
@Test
public void test031ResourceAndConnectorCachingForceFresh() throws Exception {
TestUtil.displayTestTile("test031ResourceAndConnectorCachingForceFresh");
// GIVEN
OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + ".test011ResourceAndConnectorCachingForceFresh");
ConnectorInstance configuredConnectorInstance = resourceManager.getConfiguredConnectorInstance(resource, ReadCapabilityType.class, false, result);
assertNotNull("No configuredConnectorInstance", configuredConnectorInstance);
ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext);
assertNotNull("No resource schema", resourceSchema);
// WHEN
PrismObject<ResourceType> resourceAgain = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result);
// THEN
result.computeStatus();
display("getObject result", result);
TestUtil.assertSuccess(result);
ResourceType resourceTypeAgain = resourceAgain.asObjectable();
assertNotNull("No connector ref", resourceTypeAgain.getConnectorRef());
assertNotNull("No connector ref OID", resourceTypeAgain.getConnectorRef().getOid());
PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
PrismContainer<Containerable> configurationContainerAgain = resourceAgain.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
assertTrue("Configurations not equivalent", configurationContainer.equivalent(configurationContainerAgain));
ResourceSchema resourceSchemaAgain = RefinedResourceSchemaImpl.getResourceSchema(resourceAgain, prismContext);
assertNotNull("No resource schema (again)", resourceSchemaAgain);
assertTrue("Resource schema was not cached", resourceSchema == resourceSchemaAgain);
// Now we stick our nose deep inside the provisioning impl. But we need
// to make sure that the configured connector is properly refreshed
// forceFresh = true
ConnectorInstance configuredConnectorInstanceAgain = resourceManager.getConfiguredConnectorInstance(resourceAgain, ReadCapabilityType.class, true, result);
assertNotNull("No configuredConnectorInstance (again)", configuredConnectorInstanceAgain);
assertFalse("Connector instance was not refreshed", configuredConnectorInstance == configuredConnectorInstanceAgain);
// Check if the connector still works
OperationResult testResult = new OperationResult(TestOpenDj.class.getName() + ".test011ResourceAndConnectorCachingForceFresh.test");
configuredConnectorInstanceAgain.test(testResult);
testResult.computeStatus();
TestUtil.assertSuccess("Connector test failed", testResult);
assertConnectorInitializationCountIncrement(1);
rememberConnectorInstance(configuredConnectorInstanceAgain);
assertSteadyResource();
}
use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.
the class AbstractBasicDummyTest method test021Configuration.
@Test
public void test021Configuration() throws Exception {
final String TEST_NAME = "test021Configuration";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME);
// WHEN
resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result);
resourceType = resource.asObjectable();
// THEN
result.computeStatus();
display("getObject result", result);
TestUtil.assertSuccess(result);
// There may be one parse. Previous test have changed the resource version
// Schema for this version will not be re-parsed until getObject is tried
assertResourceSchemaParseCountIncrement(1);
assertResourceCacheMissesIncrement(1);
PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
assertNotNull("No configuration container", configurationContainer);
PrismContainerDefinition confContDef = configurationContainer.getDefinition();
assertNotNull("No configuration container definition", confContDef);
PrismContainer confingurationPropertiesContainer = configurationContainer.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME);
assertNotNull("No configuration properties container", confingurationPropertiesContainer);
PrismContainerDefinition confPropsDef = confingurationPropertiesContainer.getDefinition();
assertNotNull("No configuration properties container definition", confPropsDef);
List<PrismProperty<?>> configurationProperties = confingurationPropertiesContainer.getValue().getItems();
assertFalse("No configuration properties", configurationProperties.isEmpty());
for (PrismProperty<?> confProp : configurationProperties) {
PrismPropertyDefinition confPropDef = confProp.getDefinition();
assertNotNull("No definition for configuration property " + confProp, confPropDef);
assertFalse("Configuration property " + confProp + " is raw", confProp.isRaw());
assertConfigurationProperty(confProp);
}
// 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());
resource.checkConsistence();
rememberSchemaMetadata(resource);
rememberConnectorInstance(resource);
assertSteadyResource();
}
use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.
the class AbstractIntegrationTest method assertShadowSecondaryIdentifier.
protected void assertShadowSecondaryIdentifier(PrismObject<ShadowType> shadow, String expectedIdentifier, ResourceType resourceType, MatchingRule<String> nameMatchingRule) throws SchemaException {
RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType);
ObjectClassComplexTypeDefinition ocDef = rSchema.findObjectClassDefinition(shadow.asObjectable().getObjectClass());
ResourceAttributeDefinition idSecDef = ocDef.getSecondaryIdentifiers().iterator().next();
PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES);
PrismProperty<String> idProp = attributesContainer.findProperty(idSecDef.getName());
assertNotNull("No secondary identifier (" + idSecDef.getName() + ") attribute in shadow for " + expectedIdentifier, idProp);
if (nameMatchingRule == null) {
assertEquals("Unexpected secondary identifier in shadow for " + expectedIdentifier, expectedIdentifier, idProp.getRealValue());
} else {
PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for " + expectedIdentifier, nameMatchingRule, expectedIdentifier, idProp.getRealValue());
}
}
use of com.evolveum.midpoint.prism.Containerable in project midpoint by Evolveum.
the class AbstractManualResourceTest method test004Configuration.
@Test
public void test004Configuration() throws Exception {
final String TEST_NAME = "test004Configuration";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(AbstractManualResourceTest.class.getName() + "." + TEST_NAME);
// WHEN
resource = modelService.getObject(ResourceType.class, getResourceOid(), null, null, result);
resourceType = resource.asObjectable();
PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION);
assertNotNull("No configuration container", configurationContainer);
PrismContainerDefinition confContDef = configurationContainer.getDefinition();
assertNotNull("No configuration container definition", confContDef);
PrismProperty<String> propDefaultAssignee = configurationContainer.findProperty(CONF_PROPERTY_DEFAULT_ASSIGNEE_QNAME);
assertNotNull("No defaultAssignee conf prop", propDefaultAssignee);
// assertNotNull("No configuration properties container", confingurationPropertiesContainer);
// PrismContainerDefinition confPropDef = confingurationPropertiesContainer.getDefinition();
// assertNotNull("No configuration properties container definition", confPropDef);
}
Aggregations