use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType in project midpoint by Evolveum.
the class AbstractBasicDummyTest method test025CapabilitiesRepo.
/**
* Check if the cached native capabilities were properly stored in the repo
*/
@Test
public void test025CapabilitiesRepo() throws Exception {
final String TEST_NAME = "test025CapabilitiesRepo";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME);
// WHEN
PrismObject<ResourceType> resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, result);
;
// THEN
result.computeStatus();
display("getObject result", result);
TestUtil.assertSuccess(result);
// Check native capabilities
ResourceType resourceType = resource.asObjectable();
CapabilitiesType capabilitiesType = resourceType.getCapabilities();
assertNotNull("No capabilities in repo, the capabilities were not cached", capabilitiesType);
CapabilityCollectionType nativeCapabilities = capabilitiesType.getNative();
System.out.println("Native capabilities: " + PrismTestUtil.serializeAnyDataWrapped(nativeCapabilities));
System.out.println("resource: " + resourceType.asPrismObject().debugDump());
List<Object> nativeCapabilitiesList = nativeCapabilities.getAny();
assertFalse("Empty capabilities returned", nativeCapabilitiesList.isEmpty());
CredentialsCapabilityType capCred = CapabilityUtil.getCapability(nativeCapabilitiesList, CredentialsCapabilityType.class);
assertNotNull("password native capability not present", capCred.getPassword());
ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class);
if (supportsActivation()) {
assertNotNull("native activation capability not present", capAct);
assertNotNull("native activation status capability not present", capAct.getStatus());
} else {
assertNull("native activation capability sneaked in", capAct);
}
TestConnectionCapabilityType capTest = CapabilityUtil.getCapability(nativeCapabilitiesList, TestConnectionCapabilityType.class);
assertNotNull("native test capability not present", capTest);
ScriptCapabilityType capScript = CapabilityUtil.getCapability(nativeCapabilitiesList, ScriptCapabilityType.class);
assertNotNull("native script capability not present", capScript);
assertNotNull("No host in native script capability", capScript.getHost());
assertFalse("No host in native script capability", capScript.getHost().isEmpty());
// TODO: better look inside
CachingMetadataType repoCapabilitiesCachingMetadataType = capabilitiesType.getCachingMetadata();
assertNotNull("No repo capabilities caching metadata", repoCapabilitiesCachingMetadataType);
assertNotNull("No repo capabilities caching metadata timestamp", repoCapabilitiesCachingMetadataType.getRetrievalTimestamp());
assertNotNull("No repo capabilities caching metadata serial number", repoCapabilitiesCachingMetadataType.getSerialNumber());
assertEquals("Repo capabilities caching metadata timestamp does not match previously returned value", capabilitiesCachingMetadataType.getRetrievalTimestamp(), repoCapabilitiesCachingMetadataType.getRetrievalTimestamp());
assertEquals("Repo capabilities caching metadata serial does not match previously returned value", capabilitiesCachingMetadataType.getSerialNumber(), repoCapabilitiesCachingMetadataType.getSerialNumber());
assertSteadyResource();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType in project midpoint by Evolveum.
the class ResourceManager method completeConnectorCapabilities.
private void completeConnectorCapabilities(ConnectorSpec connectorSpec, CapabilitiesType capType, ItemPath itemPath, boolean forceRefresh, Collection<Object> retrievedCapabilities, Collection<ItemDelta<?, ?>> modifications, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException {
if (!forceRefresh && capType.getNative() != null && !capType.getNative().getAny().isEmpty()) {
return;
}
if (retrievedCapabilities == null) {
try {
InternalMonitor.recordConnectorCapabilitiesFetchCount();
ConnectorInstance connector = connectorManager.getConfiguredConnectorInstance(connectorSpec, false, result);
retrievedCapabilities = connector.fetchCapabilities(result);
} catch (GenericFrameworkException e) {
throw new GenericConnectorException("Generic error in connector " + connectorSpec + ": " + e.getMessage(), e);
}
}
CapabilityCollectionType nativeCapType = new CapabilityCollectionType();
capType.setNative(nativeCapType);
nativeCapType.getAny().addAll(retrievedCapabilities);
CachingMetadataType cachingMetadata = MiscSchemaUtil.generateCachingMetadata();
capType.setCachingMetadata(cachingMetadata);
ObjectDelta<ResourceType> capabilitiesReplaceDelta = ObjectDelta.createModificationReplaceContainer(ResourceType.class, connectorSpec.getResource().getOid(), itemPath, prismContext, capType.asPrismContainerValue().clone());
modifications.addAll(capabilitiesReplaceDelta.getModifications());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType in project midpoint by Evolveum.
the class AbstractManualResourceTest method test006Capabilities.
@Test
public void test006Capabilities() throws Exception {
final String TEST_NAME = "test006Capabilities";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(TestOpenDj.class.getName() + "." + TEST_NAME);
// WHEN
ResourceType resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, null, result).asObjectable();
// THEN
display("Resource from provisioninig", resource);
display("Resource from provisioninig (XML)", PrismTestUtil.serializeObjectToString(resource.asPrismObject(), PrismContext.LANG_XML));
CapabilityCollectionType nativeCapabilities = resource.getCapabilities().getNative();
List<Object> nativeCapabilitiesList = nativeCapabilities.getAny();
assertFalse("Empty capabilities returned", nativeCapabilitiesList.isEmpty());
CreateCapabilityType capCreate = CapabilityUtil.getCapability(nativeCapabilitiesList, CreateCapabilityType.class);
assertNotNull("Missing create capability", capCreate);
assertManual(capCreate);
ActivationCapabilityType capAct = CapabilityUtil.getCapability(nativeCapabilitiesList, ActivationCapabilityType.class);
assertNotNull("Missing activation capability", capAct);
ReadCapabilityType capRead = CapabilityUtil.getCapability(nativeCapabilitiesList, ReadCapabilityType.class);
assertNotNull("Missing read capability", capRead);
assertEquals("Wrong caching-only setting in read capability", Boolean.TRUE, capRead.isCachingOnly());
List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resource);
for (Object capability : effectiveCapabilities) {
System.out.println("Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
}
}
Aggregations