Search in sources :

Example 6 with ResourceObjectClassDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition in project midpoint by Evolveum.

the class TestDummyLegacy method assertNoObjectClass.

private void assertNoObjectClass(ResourceSchema schema, String objectClassLocalName) {
    ResourceObjectClassDefinition ocDef = schema.findObjectClassDefinition(new QName(MidPointConstants.NS_RI, objectClassLocalName));
    assertNull("Objectclass " + objectClassLocalName + " found in schema while not expecting it", ocDef);
}
Also used : ResourceObjectClassDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition) QName(javax.xml.namespace.QName)

Example 7 with ResourceObjectClassDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition in project midpoint by Evolveum.

the class TestDummyLegacy method assertObjectClass.

private void assertObjectClass(ResourceSchema schema, String objectClassLocalName) {
    ResourceObjectClassDefinition ocDef = schema.findObjectClassDefinition(new QName(MidPointConstants.NS_RI, objectClassLocalName));
    assertNotNull("No objectclass " + objectClassLocalName + " found in schema", ocDef);
}
Also used : ResourceObjectClassDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition) QName(javax.xml.namespace.QName)

Example 8 with ResourceObjectClassDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition in project midpoint by Evolveum.

the class UcfExecutionContext method recordIcfOperationSuspend.

public void recordIcfOperationSuspend(@NotNull ConnIdOperation operation) {
    ResourceObjectClassDefinition objectClassDef = operation.getObjectClassDef();
    if (operation != currentOperation) {
        LOGGER.warn("Suspending operation other than current: suspending {}, recorded current {}, task {}", operation, currentOperation, task);
    } else {
        if (task != null) {
            task.onConnIdOperationSuspend(operation);
        } else {
            reportNoTask(currentOperation);
        }
    }
    currentOperation = null;
    recordState("Returned from " + operation + " of " + getObjectClassName(objectClassDef) + " on " + getResourceName());
}
Also used : ResourceObjectClassDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition)

Example 9 with ResourceObjectClassDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition in project midpoint by Evolveum.

the class TestUcfDummyMulti method test100AddAccount.

@Test
public void test100AddAccount() throws Exception {
    OperationResult result = createOperationResult();
    ResourceObjectClassDefinition defaultAccountDefinition = resourceSchema.findObjectClassDefinitionRequired(ACCOUNT_OBJECT_CLASS_NAME);
    ShadowType shadowType = new ShadowType();
    PrismTestUtil.getPrismContext().adopt(shadowType);
    shadowType.setName(PrismTestUtil.createPolyStringType(ACCOUNT_JACK_USERNAME));
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resource.getOid());
    shadowType.setResourceRef(resourceRef);
    shadowType.setObjectClass(defaultAccountDefinition.getTypeName());
    PrismObject<ShadowType> shadow = shadowType.asPrismObject();
    ResourceAttributeContainer attributesContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, defaultAccountDefinition);
    ResourceAttribute<String> icfsNameProp = attributesContainer.findOrCreateAttribute(SchemaConstants.ICFS_NAME);
    icfsNameProp.setRealValue(ACCOUNT_JACK_USERNAME);
    // WHEN
    cc.addObject(shadow, null, result);
    // THEN
    DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_JACK_USERNAME);
    assertNotNull("Account " + ACCOUNT_JACK_USERNAME + " was not created", dummyAccount);
    assertNotNull("Account " + ACCOUNT_JACK_USERNAME + " has no username", dummyAccount.getName());
}
Also used : ResourceObjectClassDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResourceAttributeContainer(com.evolveum.midpoint.schema.processor.ResourceAttributeContainer) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test)

Example 10 with ResourceObjectClassDefinition

use of com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition in project midpoint by Evolveum.

the class TestUcfDummyMulti method test200BlockingSearch.

@Test
public void test200BlockingSearch() throws Exception {
    // GIVEN
    UcfExecutionContext ctx = createExecutionContext();
    OperationResult result = createOperationResult();
    final ResourceObjectClassDefinition accountDefinition = resourceSchema.findObjectClassDefinitionRequired(ACCOUNT_OBJECT_CLASS_NAME);
    // Determine object class from the schema
    final List<PrismObject<ShadowType>> searchResults = new ArrayList<>();
    final ObjectHandler handler = (ucfObject, lResult) -> {
        checkUcfShadow(ucfObject.getResourceObject(), accountDefinition);
        searchResults.add(ucfObject.getResourceObject());
        return true;
    };
    dummyResource.setBlockOperations(true);
    // WHEN
    Thread t = new Thread(() -> {
        try {
            cc.search(accountDefinition, null, handler, null, null, null, null, ctx, result);
        } catch (CommunicationException | GenericFrameworkException | SchemaException | SecurityViolationException | ObjectNotFoundException e) {
            logger.error("Error in the search: {}", e.getMessage(), e);
        }
    });
    t.setName("search1");
    t.start();
    // Give the new thread a chance to get blocked
    Thread.sleep(500);
    ConnectorOperationalStatus opStat = cc.getOperationalStatus();
    displayDumpable("stats (blocked)", opStat);
    assertEquals("Wrong pool active", (Integer) 1, opStat.getPoolStatusNumActive());
    assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumIdle());
    assertEquals("Unexpected number of search results", 0, searchResults.size());
    dummyResource.unblock();
    t.join();
    dummyResource.setBlockOperations(false);
    // THEN
    assertEquals("Unexpected number of search results", 1, searchResults.size());
    opStat = cc.getOperationalStatus();
    displayDumpable("stats (final)", opStat);
    assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumActive());
    assertEquals("Wrong pool active", (Integer) 1, opStat.getPoolStatusNumIdle());
    PrismObject<ShadowType> searchResult = searchResults.get(0);
    displayDumpable("Search result", searchResult);
}
Also used : ResourceObjectClassDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition) AssertJUnit(org.testng.AssertJUnit) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) ResourceAttributeContainer(com.evolveum.midpoint.schema.processor.ResourceAttributeContainer) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Test(org.testng.annotations.Test) SchemaRegistry(com.evolveum.midpoint.prism.schema.SchemaRegistry) ObjectHandler(com.evolveum.midpoint.provisioning.ucf.api.ObjectHandler) ACCOUNT_OBJECT_CLASS_NAME(com.evolveum.midpoint.schema.util.SchemaTestConstants.ACCOUNT_OBJECT_CLASS_NAME) ArrayList(java.util.ArrayList) ResourceAttribute(com.evolveum.midpoint.schema.processor.ResourceAttribute) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) PrismTestUtil(com.evolveum.midpoint.prism.util.PrismTestUtil) ResourceObjectClassDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition) Files(com.google.common.io.Files) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus) TestUtil(com.evolveum.midpoint.test.util.TestUtil) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) ResourceTypeUtil(com.evolveum.midpoint.schema.util.ResourceTypeUtil) PrismObject(com.evolveum.midpoint.prism.PrismObject) File(java.io.File) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ShadowUtil(com.evolveum.midpoint.schema.util.ShadowUtil) ContextConfiguration(org.springframework.test.context.ContextConfiguration) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) UcfExecutionContext(com.evolveum.midpoint.provisioning.ucf.api.UcfExecutionContext) PrismSchema(com.evolveum.midpoint.prism.schema.PrismSchema) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) GenericFrameworkException(com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectHandler(com.evolveum.midpoint.provisioning.ucf.api.ObjectHandler) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus) UcfExecutionContext(com.evolveum.midpoint.provisioning.ucf.api.UcfExecutionContext) Test(org.testng.annotations.Test)

Aggregations

ResourceObjectClassDefinition (com.evolveum.midpoint.schema.processor.ResourceObjectClassDefinition)11 Test (org.testng.annotations.Test)6 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)4 PrismObject (com.evolveum.midpoint.prism.PrismObject)4 ResourceAttributeContainer (com.evolveum.midpoint.schema.processor.ResourceAttributeContainer)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)3 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)3 PrismSchema (com.evolveum.midpoint.prism.schema.PrismSchema)3 SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)3 PrismTestUtil (com.evolveum.midpoint.prism.util.PrismTestUtil)3 GenericFrameworkException (com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException)3 ObjectHandler (com.evolveum.midpoint.provisioning.ucf.api.ObjectHandler)3 UcfExecutionContext (com.evolveum.midpoint.provisioning.ucf.api.UcfExecutionContext)3 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)3 ResourceAttribute (com.evolveum.midpoint.schema.processor.ResourceAttribute)3 ConnectorOperationalStatus (com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)3 ResourceTypeUtil (com.evolveum.midpoint.schema.util.ResourceTypeUtil)3 ACCOUNT_OBJECT_CLASS_NAME (com.evolveum.midpoint.schema.util.SchemaTestConstants.ACCOUNT_OBJECT_CLASS_NAME)3 ShadowUtil (com.evolveum.midpoint.schema.util.ShadowUtil)3