use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.TestConnectionCapabilityType in project midpoint by Evolveum.
the class ConnectorInstanceConnIdImpl method processOperationCapabilities.
private boolean processOperationCapabilities(OperationResult parentResult) {
capabilities = new ArrayList<>();
// Create capabilities from supported connector operations
InternalMonitor.recordConnectorOperation("getSupportedOperations");
Set<Class<? extends APIOperation>> supportedOperations = connIdConnectorFacade.getSupportedOperations();
LOGGER.trace("Connector supported operations: {}", supportedOperations);
boolean supportsSchema = false;
if (supportedOperations.contains(SchemaApiOp.class)) {
SchemaCapabilityType capSchema = new SchemaCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createSchema(capSchema));
supportsSchema = true;
}
if (supportedOperations.contains(SyncApiOp.class)) {
LiveSyncCapabilityType capSync = new LiveSyncCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createLiveSync(capSync));
}
if (supportedOperations.contains(TestApiOp.class)) {
TestConnectionCapabilityType capTest = new TestConnectionCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createTestConnection(capTest));
}
if (supportedOperations.contains(CreateApiOp.class)) {
CreateCapabilityType capCreate = new CreateCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createCreate(capCreate));
}
if (supportedOperations.contains(GetApiOp.class) || supportedOperations.contains(SearchApiOp.class)) {
ReadCapabilityType capRead = new ReadCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createRead(capRead));
}
if (supportedOperations.contains(UpdateApiOp.class)) {
UpdateCapabilityType capUpdate = new UpdateCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createUpdate(capUpdate));
}
if (supportedOperations.contains(DeleteApiOp.class)) {
DeleteCapabilityType capDelete = new DeleteCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createDelete(capDelete));
}
if (supportedOperations.contains(ScriptOnResourceApiOp.class) || supportedOperations.contains(ScriptOnConnectorApiOp.class)) {
ScriptCapabilityType capScript = new ScriptCapabilityType();
if (supportedOperations.contains(ScriptOnResourceApiOp.class)) {
Host host = new Host();
host.setType(ProvisioningScriptHostType.RESOURCE);
capScript.getHost().add(host);
// language is unknown here
}
if (supportedOperations.contains(ScriptOnConnectorApiOp.class)) {
Host host = new Host();
host.setType(ProvisioningScriptHostType.CONNECTOR);
capScript.getHost().add(host);
// language is unknown here
}
capabilities.add(CAPABILITY_OBJECT_FACTORY.createScript(capScript));
}
return supportsSchema;
}
use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.TestConnectionCapabilityType in project midpoint by Evolveum.
the class AbstractBasicDummyTest method test024Capabilities.
@Test
public void test024Capabilities() throws Exception {
final String TEST_NAME = "test024Capabilities";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
OperationResult result = new OperationResult(AbstractBasicDummyTest.class.getName() + "." + TEST_NAME);
// WHEN
PrismObject<ResourceType> resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result);
ResourceType resourceType = resource.asObjectable();
// THEN
result.computeStatus();
display("getObject result", result);
TestUtil.assertSuccess(result);
// Check native capabilities
CapabilityCollectionType nativeCapabilities = resourceType.getCapabilities().getNative();
display("Native capabilities", PrismTestUtil.serializeAnyDataWrapped(nativeCapabilities));
display("Resource", resourceType);
List<Object> nativeCapabilitiesList = nativeCapabilities.getAny();
assertFalse("Empty capabilities returned", nativeCapabilitiesList.isEmpty());
CredentialsCapabilityType capCred = CapabilityUtil.getCapability(nativeCapabilitiesList, CredentialsCapabilityType.class);
assertNativeCredentialsCapability(capCred);
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
capabilitiesCachingMetadataType = resourceType.getCapabilities().getCachingMetadata();
assertNotNull("No capabilities caching metadata", capabilitiesCachingMetadataType);
assertNotNull("No capabilities caching metadata timestamp", capabilitiesCachingMetadataType.getRetrievalTimestamp());
assertNotNull("No capabilities caching metadata serial number", capabilitiesCachingMetadataType.getSerialNumber());
// Check effective capabilites
capCred = ResourceTypeUtil.getEffectiveCapability(resourceType, CredentialsCapabilityType.class);
assertNotNull("password capability not found", capCred.getPassword());
// Although connector does not support activation, the resource
// specifies a way how to simulate it.
// Therefore the following should succeed
capAct = ResourceTypeUtil.getEffectiveCapability(resourceType, ActivationCapabilityType.class);
assertNotNull("activation capability not found", capCred.getPassword());
List<Object> effectiveCapabilities = ResourceTypeUtil.getEffectiveCapabilities(resourceType);
for (Object capability : effectiveCapabilities) {
System.out.println("Capability: " + CapabilityUtil.getCapabilityDisplayName(capability) + " : " + capability);
}
assertSteadyResource();
}
use of com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.TestConnectionCapabilityType 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.resource.capabilities_3.TestConnectionCapabilityType in project midpoint by Evolveum.
the class ConnIdCapabilitiesAndSchemaParser method processOperationCapabilities.
/**
* Create capabilities from supported connector operations
*/
private void processOperationCapabilities() {
if (connIdSupportedOperations.contains(SchemaApiOp.class)) {
SchemaCapabilityType capSchema = new SchemaCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createSchema(capSchema));
supportsSchema = true;
} else {
supportsSchema = false;
}
if (connIdSupportedOperations.contains(SyncApiOp.class)) {
LiveSyncCapabilityType capSync = new LiveSyncCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createLiveSync(capSync));
}
if (connIdSupportedOperations.contains(TestApiOp.class)) {
TestConnectionCapabilityType capTest = new TestConnectionCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createTestConnection(capTest));
}
if (connIdSupportedOperations.contains(CreateApiOp.class)) {
CreateCapabilityType capCreate = new CreateCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createCreate(capCreate));
}
if (connIdSupportedOperations.contains(UpdateDeltaApiOp.class)) {
UpdateCapabilityType capUpdate = new UpdateCapabilityType();
capUpdate.setDelta(true);
// This is the default for all resources.
// (Currently there is no way how to obtain it from the connector.)
// It can be disabled manually.
capUpdate.setAddRemoveAttributeValues(true);
capabilities.add(CAPABILITY_OBJECT_FACTORY.createUpdate(capUpdate));
} else if (connIdSupportedOperations.contains(UpdateApiOp.class)) {
UpdateCapabilityType capUpdate = new UpdateCapabilityType();
// This is the default for all resources.
// (Currently there is no way how to obtain it from the connector.)
// It can be disabled manually.
capUpdate.setAddRemoveAttributeValues(true);
capabilities.add(CAPABILITY_OBJECT_FACTORY.createUpdate(capUpdate));
}
if (connIdSupportedOperations.contains(DeleteApiOp.class)) {
DeleteCapabilityType capDelete = new DeleteCapabilityType();
capabilities.add(CAPABILITY_OBJECT_FACTORY.createDelete(capDelete));
}
if (connIdSupportedOperations.contains(ScriptOnResourceApiOp.class) || connIdSupportedOperations.contains(ScriptOnConnectorApiOp.class)) {
ScriptCapabilityType capScript = new ScriptCapabilityType();
if (connIdSupportedOperations.contains(ScriptOnResourceApiOp.class)) {
Host host = new Host();
host.setType(ProvisioningScriptHostType.RESOURCE);
capScript.getHost().add(host);
// language is unknown here
}
if (connIdSupportedOperations.contains(ScriptOnConnectorApiOp.class)) {
Host host = new Host();
host.setType(ProvisioningScriptHostType.CONNECTOR);
capScript.getHost().add(host);
// language is unknown here
}
capabilities.add(CAPABILITY_OBJECT_FACTORY.createScript(capScript));
}
}
Aggregations