Search in sources :

Example 26 with COMPLETE

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.

the class AbstractManualResourceTest method test220ModifyUserWillDisable.

/**
	 * disable - do not complete yet (do not wait for delta to expire, we want several deltas at once).
	 */
@Test
public void test220ModifyUserWillDisable() throws Exception {
    final String TEST_NAME = "test220ModifyUserWillDisable";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    displayWhen(TEST_NAME);
    modifyUserReplace(userWillOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED);
    // THEN
    displayThen(TEST_NAME);
    display("result", result);
    willLastCaseOid = assertInProgress(result);
    accountWillReqestTimestampEnd = clock.currentTimeXMLGregorianCalendar();
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result);
    display("Repo shadow", shadowRepo);
    assertPendingOperationDeltas(shadowRepo, 2);
    PendingOperationType pendingOperation = findPendingOperation(shadowRepo, OperationResultStatusType.IN_PROGRESS, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
    assertPendingOperation(shadowRepo, pendingOperation, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
    assertNotNull("No ID in pending operation", pendingOperation.getId());
    // Still old data in the repo. The operation is not completed yet.
    assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
    assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    PrismObject<ShadowType> shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result);
    display("Model shadow", shadowModel);
    ShadowType shadowTypeProvisioning = shadowModel.asObjectable();
    assertShadowName(shadowModel, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
    assertShadowActivationAdministrativeStatus(shadowModel, ActivationStatusType.ENABLED);
    assertAttribute(shadowModel, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttribute(shadowModel, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    assertAttributeFromBackingStore(shadowModel, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
    assertShadowPassword(shadowModel);
    assertPendingOperationDeltas(shadowModel, 2);
    pendingOperation = findPendingOperation(shadowModel, OperationResultStatusType.IN_PROGRESS, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
    assertPendingOperation(shadowModel, pendingOperation, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
    PrismObject<ShadowType> shadowModelFuture = modelService.getObject(ShadowType.class, accountWillOid, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), task, result);
    display("Model shadow (future)", shadowModelFuture);
    assertShadowName(shadowModelFuture, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowModelFuture.asObjectable().getKind());
    assertShadowActivationAdministrativeStatus(shadowModelFuture, ActivationStatusType.DISABLED);
    assertAttribute(shadowModelFuture, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttribute(shadowModelFuture, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    assertAttributeFromBackingStore(shadowModelFuture, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
    assertShadowPassword(shadowModelFuture);
    assertNotNull("No async reference in result", willLastCaseOid);
    assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PendingOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 27 with COMPLETE

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.

the class AbstractManualResourceTest method test310CloseCaseAndRecomputeWill.

/**
	 * Case is closed. The operation is complete.
	 */
@Test
public void test310CloseCaseAndRecomputeWill() throws Exception {
    final String TEST_NAME = "test310CloseCaseAndRecomputeWill";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    closeCase(willLastCaseOid);
    accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    displayWhen(TEST_NAME);
    // We need reconcile and not recompute here. We need to fetch the updated case status.
    reconcileUser(userWillOid, task, result);
    // THEN
    displayThen(TEST_NAME);
    display("result", result);
    assertSuccess(result);
    accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar();
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result);
    display("Repo shadow", shadowRepo);
    assertSinglePendingOperation(shadowRepo, accountWillReqestTimestampStart, accountWillReqestTimestampEnd, OperationResultStatusType.SUCCESS, accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
    assertShadowDead(shadowRepo);
    PrismObject<ShadowType> shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result);
    display("Model shadow", shadowModel);
    ShadowType shadowTypeProvisioning = shadowModel.asObjectable();
    assertShadowName(shadowModel, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
    assertShadowDead(shadowModel);
    assertShadowPassword(shadowModel);
    PendingOperationType pendingOperation = assertSinglePendingOperation(shadowModel, accountWillReqestTimestampStart, accountWillReqestTimestampEnd, OperationResultStatusType.SUCCESS, accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
    PrismObject<ShadowType> shadowModelFuture = modelService.getObject(ShadowType.class, accountWillOid, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), task, result);
    display("Model shadow (future)", shadowModelFuture);
    assertShadowName(shadowModelFuture, USER_WILL_NAME);
    assertShadowDead(shadowModelFuture);
    assertShadowPassword(shadowModelFuture);
    assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_CLOSED);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PendingOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 28 with COMPLETE

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.

the class AbstractManualResourceTest method test204CloseCaseAndRecomputeWill.

/**
	 * Case is closed. The operation is complete.
	 */
@Test
public void test204CloseCaseAndRecomputeWill() throws Exception {
    final String TEST_NAME = "test204CloseCaseAndRecomputeWill";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    closeCase(willLastCaseOid);
    accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    displayWhen(TEST_NAME);
    recomputeUser(userWillOid, task, result);
    // THEN
    displayThen(TEST_NAME);
    assertSuccess(result);
    accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar();
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result);
    display("Repo shadow", shadowRepo);
    assertSinglePendingOperation(shadowRepo, accountWillReqestTimestampStart, accountWillReqestTimestampEnd, OperationResultStatusType.SUCCESS, accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
    assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.ENABLED);
    assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    PrismObject<ShadowType> shadowProvisioning = modelService.getObject(ShadowType.class, accountWillOid, null, task, result);
    display("Model shadow", shadowProvisioning);
    ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
    assertShadowName(shadowProvisioning, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
    assertShadowActivationAdministrativeStatus(shadowProvisioning, ActivationStatusType.ENABLED);
    assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    if (supportsBackingStore()) {
        assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME);
    } else {
        assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    }
    assertAttributeFromBackingStore(shadowProvisioning, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
    assertShadowPassword(shadowProvisioning);
    PendingOperationType pendingOperation = assertSinglePendingOperation(shadowProvisioning, accountWillReqestTimestampStart, accountWillReqestTimestampEnd, OperationResultStatusType.SUCCESS, accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
    PrismObject<ShadowType> shadowProvisioningFuture = modelService.getObject(ShadowType.class, accountWillOid, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), task, result);
    display("Model shadow (future)", shadowProvisioningFuture);
    assertShadowName(shadowProvisioningFuture, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowProvisioningFuture.asObjectable().getKind());
    assertShadowActivationAdministrativeStatus(shadowProvisioningFuture, ActivationStatusType.ENABLED);
    assertAttribute(shadowProvisioningFuture, ATTR_USERNAME_QNAME, USER_WILL_NAME);
    assertAttribute(shadowProvisioningFuture, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    assertAttributeFromBackingStore(shadowProvisioningFuture, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
    assertShadowPassword(shadowProvisioningFuture);
    assertCase(willLastCaseOid, SchemaConstants.CASE_STATE_CLOSED);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PendingOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractConfiguredModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)

Example 29 with COMPLETE

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.

the class AuditController method getObjectFromLastEvent.

private <O extends ObjectType> PrismObject<O> getObjectFromLastEvent(PrismObject<O> object, List<AuditEventRecord> changeTrail, String eventIdentifier) {
    if (changeTrail.isEmpty()) {
        return object;
    }
    AuditEventRecord lastEvent = changeTrail.remove(changeTrail.size() - 1);
    if (!eventIdentifier.equals(lastEvent.getEventIdentifier())) {
        throw new IllegalStateException("Wrong last event identifier, expected " + eventIdentifier + " but was " + lastEvent.getEventIdentifier());
    }
    Collection<ObjectDeltaOperation<? extends ObjectType>> lastEventDeltasOperations = lastEvent.getDeltas();
    for (ObjectDeltaOperation<? extends ObjectType> lastEventDeltasOperation : lastEventDeltasOperations) {
        ObjectDelta<O> objectDelta = (ObjectDelta<O>) lastEventDeltasOperation.getObjectDelta();
        if (!isApplicable(lastEventDeltasOperation, object, lastEvent)) {
            continue;
        }
        if (objectDelta.isAdd()) {
            // We are lucky. This is object add, so we have complete object there. No need to roll back
            // the operations.
            PrismObject<O> objectToAdd = objectDelta.getObjectToAdd();
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Taking object from add delta in last event {}:\n{}", lastEvent.getEventIdentifier(), objectToAdd.debugDump(1));
            }
            return objectToAdd;
        }
    }
    return null;
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectDeltaOperation(com.evolveum.midpoint.schema.ObjectDeltaOperation) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) AuditEventRecord(com.evolveum.midpoint.audit.api.AuditEventRecord)

Example 30 with COMPLETE

use of com.evolveum.midpoint.xml.ns._public.common.common_3.WorkBucketStateType.COMPLETE in project midpoint by Evolveum.

the class ResourceManager method loadAndCacheResource.

private PrismObject<ResourceType> loadAndCacheResource(PrismObject<ResourceType> repositoryObject, GetOperationOptions options, Task task, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    PrismObject<ResourceType> completedResource = completeResource(repositoryObject, null, false, null, options, task, parentResult);
    if (!isComplete(completedResource)) {
        // No not cache non-complete resources (e.g. those retrieved with noFetch)
        return completedResource;
    }
    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Putting resource in cache:\n{}", completedResource.debugDump());
        Element xsdSchemaElement = ResourceTypeUtil.getResourceXsdSchema(completedResource);
        if (xsdSchemaElement == null) {
            LOGGER.trace("Schema: null");
        } else {
            LOGGER.trace("Schema:\n{}", DOMUtil.serializeDOMToString(ResourceTypeUtil.getResourceXsdSchema(completedResource)));
        }
    }
    OperationResult completeResourceResult = parentResult.findSubresult(OPERATION_COMPLETE_RESOURCE);
    if (completeResourceResult.isSuccess()) {
        // Cache only resources that are completely OK
        resourceCache.put(completedResource);
    }
    InternalMonitor.getResourceCacheStats().recordMiss();
    return completedResource;
}
Also used : Element(org.w3c.dom.Element) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Aggregations

OperationResult (com.evolveum.midpoint.schema.result.OperationResult)25 Test (org.testng.annotations.Test)21 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)14 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)13 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)13 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)12 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)11 Task (com.evolveum.midpoint.task.api.Task)11 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)10 GenericObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType)9 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)9 SelectorQualifiedGetOptionsType (com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)9 Holder (javax.xml.ws.Holder)9 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)8 ChangeRecordEntry (org.opends.server.util.ChangeRecordEntry)8 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)7 Element (org.w3c.dom.Element)6 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)5 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)5 List (java.util.List)5