use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType 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.xml.ns._public.common.common_3.CapabilitiesType in project ddf by codice.
the class TestRegistryStore method testInit.
@Test
public void testInit() throws Exception {
RegistryStoreImpl registryStore = spy(new RegistryStoreImpl(context, cswSourceConfiguration, provider, factory, encryptionService) {
@Override
protected void validateOperation() {
}
@Override
public boolean isAvailable() {
return availability;
}
@Override
protected SourceResponse query(QueryRequest queryRequest, ElementSetType elementSetName, List<QName> elementNames, Csw csw) throws UnsupportedQueryException {
if (queryResults == null) {
throw new UnsupportedQueryException("Test - Bad Query");
}
return new SourceResponseImpl(queryRequest, queryResults);
}
@Override
public SourceResponse query(QueryRequest request) throws UnsupportedQueryException {
return new SourceResponseImpl(request, Collections.singletonList(new Result() {
@Override
public Metacard getMetacard() {
MetacardImpl metacard = new MetacardImpl();
metacard.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, "registryId");
metacard.setAttribute(Metacard.TITLE, "title");
return metacard;
}
@Override
public Double getRelevanceScore() {
return null;
}
@Override
public Double getDistanceInMeters() {
return null;
}
}));
}
@Override
protected CapabilitiesType getCapabilities() {
return mock(CapabilitiesType.class);
}
@Override
public void configureCswSource() {
}
;
@Override
protected Subject getSystemSubject() {
return subject;
}
@Override
BundleContext getBundleContext() {
return context;
}
});
registryStore.setFilterBuilder(filterBuilder);
registryStore.setFilterAdapter(filterAdapter);
registryStore.setConfigAdmin(configAdmin);
registryStore.setMetacardMarshaller(new MetacardMarshaller(parser));
registryStore.setSchemaTransformerManager(transformer);
registryStore.setAutoPush(true);
registryStore.setRegistryUrl("http://test.url:0101/example");
properties = new Hashtable<>();
properties.put(RegistryStoreImpl.ID, "registryId");
registryStore.setMetacardMarshaller(marshaller);
Csw csw = mock(Csw.class);
when(factory.getClientForSubject(any())).thenReturn(csw);
cswSourceConfiguration.setCswUrl("https://localhost");
cswSourceConfiguration.setPollIntervalMinutes(1);
queryResults.add(new ResultImpl(getDefaultMetacard()));
registryStore.init();
assertThat(registryStore.getRegistryId(), is("registryId"));
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType in project midpoint by Evolveum.
the class AbstractLdapTest method test030Capabilities.
@Test
public void test030Capabilities() throws Exception {
final String TEST_NAME = "test030Capabilities";
TestUtil.displayTestTile(this, TEST_NAME);
CapabilitiesType capabilities = resourceType.getCapabilities();
display("Resource capabilities", capabilities);
assertNotNull("Null capabilities", capabilities);
CapabilityCollectionType nativeCapabilitiesCollectionType = capabilities.getNative();
assertNotNull("Null native capabilities type", nativeCapabilitiesCollectionType);
List<Object> nativeCapabilities = nativeCapabilitiesCollectionType.getAny();
assertNotNull("Null native capabilities", nativeCapabilities);
assertFalse("Empty native capabilities", nativeCapabilities.isEmpty());
assertCapability(nativeCapabilities, ReadCapabilityType.class);
assertCapability(nativeCapabilities, CreateCapabilityType.class);
assertCapability(nativeCapabilities, UpdateCapabilityType.class);
assertCapability(nativeCapabilities, DeleteCapabilityType.class);
// TODO: assert password capability. Check password readability.
ActivationCapabilityType activationCapabilityType = CapabilityUtil.getCapability(nativeCapabilities, ActivationCapabilityType.class);
assertActivationCapability(activationCapabilityType);
assertAdditionalCapabilities(nativeCapabilities);
assertStableSystem();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType in project midpoint by Evolveum.
the class ResourceManager method supportsCapability.
private <T extends CapabilityType> boolean supportsCapability(ConnectorInstanceSpecificationType additionalConnectorType, Collection<Object> nativeCapabilities, Class<T> capabilityClass) {
CapabilitiesType specifiedCapabilitiesType = additionalConnectorType.getCapabilities();
if (specifiedCapabilitiesType != null) {
CapabilityCollectionType configuredCapCollectionType = specifiedCapabilitiesType.getConfigured();
if (configuredCapCollectionType != null) {
T configuredCap = CapabilityUtil.getCapability(configuredCapCollectionType.getAny(), capabilityClass);
if (configuredCap != null && !CapabilityUtil.isCapabilityEnabled(configuredCap)) {
return false;
}
}
}
T cap = CapabilityUtil.getCapability(nativeCapabilities, capabilityClass);
if (cap == null) {
return false;
}
return CapabilityUtil.isCapabilityEnabled(cap);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType in project midpoint by Evolveum.
the class ResourceObjectConverter method completeActivation.
/**
* Completes activation state by determining simulated activation if necessary.
*/
private void completeActivation(ProvisioningContext ctx, PrismObject<ShadowType> resourceObject, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
ResourceType resourceType = ctx.getResource();
ShadowType resourceObjectType = resourceObject.asObjectable();
CapabilitiesType connectorCapabilities = ctx.getConnectorCapabilities(ReadCapabilityType.class);
ActivationCapabilityType activationCapability = CapabilityUtil.getEffectiveCapability(connectorCapabilities, ActivationCapabilityType.class);
if (resourceObjectType.getActivation() != null || CapabilityUtil.isCapabilityEnabled(activationCapability)) {
ActivationType activationType = null;
if (CapabilityUtil.hasNativeCapability(connectorCapabilities, ActivationCapabilityType.class)) {
activationType = resourceObjectType.getActivation();
} else if (CapabilityUtil.isCapabilityEnabled(activationCapability)) {
activationType = convertFromSimulatedActivationAttributes(resourceType, resourceObject, activationCapability, parentResult);
} else {
// No activation capability, nothing to do
}
LOGGER.trace("Determined activation, administrativeStatus: {}, lockoutStatus: {}", activationType == null ? "null activationType" : activationType.getAdministrativeStatus(), activationType == null ? "null activationType" : activationType.getLockoutStatus());
resourceObjectType.setActivation(activationType);
} else {
resourceObjectType.setActivation(null);
}
}
Aggregations