Search in sources :

Example 11 with CapabilityCollectionType

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();
}
Also used : CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) TestConnectionCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.TestConnectionCapabilityType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ScriptCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType) CapabilitiesType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType) CredentialsCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType) PrismObject(com.evolveum.midpoint.prism.PrismObject) CachingMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType) Test(org.testng.annotations.Test)

Example 12 with CapabilityCollectionType

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());
}
Also used : ConnectorInstance(com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) GenericConnectorException(com.evolveum.midpoint.provisioning.api.GenericConnectorException) CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) CachingMetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType)

Example 13 with CapabilityCollectionType

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);
    }
}
Also used : ReadCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType) CapabilityCollectionType(com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType) ActivationCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType) TestOpenDj(com.evolveum.midpoint.provisioning.impl.opendj.TestOpenDj) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) PrismObject(com.evolveum.midpoint.prism.PrismObject) CreateCapabilityType(com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType) Test(org.testng.annotations.Test) AbstractProvisioningIntegrationTest(com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)

Aggregations

CapabilityCollectionType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType)13 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)11 ActivationCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType)10 Test (org.testng.annotations.Test)10 PrismObject (com.evolveum.midpoint.prism.PrismObject)9 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)8 CredentialsCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CredentialsCapabilityType)6 ScriptCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ScriptCapabilityType)5 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)3 CapabilitiesType (com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType)3 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)3 CreateCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType)3 ReadCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType)3 TestConnectionCapabilityType (com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.TestConnectionCapabilityType)3 AbstractProvisioningIntegrationTest (com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)2 TestOpenDj (com.evolveum.midpoint.provisioning.impl.opendj.TestOpenDj)2 Task (com.evolveum.midpoint.task.api.Task)2 CachingMetadataType (com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType)2 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)2 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)2