Search in sources :

Example 31 with PendingOperationType

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

the class AbstractManualResourceTest method findPendingOperation.

private PendingOperationType findPendingOperation(PrismObject<ShadowType> shadow, OperationResultStatusType expectedResult, ItemPath itemPath) {
    List<PendingOperationType> pendingOperations = shadow.asObjectable().getPendingOperation();
    for (PendingOperationType pendingOperation : pendingOperations) {
        OperationResultStatusType result = pendingOperation.getResultStatus();
        if (result == null) {
            result = OperationResultStatusType.IN_PROGRESS;
        }
        if (pendingOperation.getResultStatus() != expectedResult) {
            continue;
        }
        if (itemPath == null) {
            return pendingOperation;
        }
        ObjectDeltaType delta = pendingOperation.getDelta();
        assertNotNull("No delta in pending operation in " + shadow, delta);
        for (ItemDeltaType itemDelta : delta.getItemDelta()) {
            ItemPath deltaPath = itemDelta.getPath().getItemPath();
            if (itemPath.equivalent(deltaPath)) {
                return pendingOperation;
            }
        }
    }
    return null;
}
Also used : ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) PendingOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType) OperationResultStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType) ItemDeltaType(com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 32 with PendingOperationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType 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 33 with PendingOperationType

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

the class AbstractManualResourceTest method test330UpdateBackingStoreAndRecomputeWill.

@Test
public void test330UpdateBackingStoreAndRecomputeWill() throws Exception {
    final String TEST_NAME = "test330UpdateBackingStoreAndRecomputeWill";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    backingStoreDeleteWill();
    // WHEN
    displayWhen(TEST_NAME);
    recomputeUser(userWillOid, task, result);
    // THEN
    displayThen(TEST_NAME);
    assertSuccess(result);
    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);
    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);
    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 34 with PendingOperationType

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

the class AbstractManualResourceTest method test300DeleteAccountWill.

@Test
public void test300DeleteAccountWill() throws Exception {
    final String TEST_NAME = "test300DeleteAccountWill";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    syncServiceMock.reset();
    accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    displayWhen(TEST_NAME);
    provisioningService.deleteObject(ShadowType.class, ACCOUNT_WILL_OID, null, null, task, result);
    // THEN
    displayThen(TEST_NAME);
    display("result", result);
    willLastCaseOid = assertInProgress(result);
    accountWillReqestTimestampEnd = clock.currentTimeXMLGregorianCalendar();
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
    display("Repo shadow", shadowRepo);
    assertPendingOperationDeltas(shadowRepo, 1);
    PendingOperationType pendingOperation = findPendingOperation(shadowRepo, OperationResultStatusType.IN_PROGRESS, null);
    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, ACCOUNT_WILL_USERNAME);
    assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME_PIRATE);
    syncServiceMock.assertNoNotifyChange();
    syncServiceMock.assertNotifyInProgressOnly();
    PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
    display("Provisioning shadow", shadowProvisioning);
    ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
    assertShadowName(shadowProvisioning, ACCOUNT_WILL_USERNAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
    assertShadowActivationAdministrativeStatus(shadowProvisioning, ActivationStatusType.ENABLED);
    assertAttribute(shadowProvisioning, ATTR_USERNAME_QNAME, ACCOUNT_WILL_USERNAME);
    assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, ACCOUNT_WILL_FULLNAME_PIRATE);
    assertAttributeFromBackingStore(shadowProvisioning, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
    assertShadowPassword(shadowProvisioning);
    assertPendingOperationDeltas(shadowProvisioning, 1);
    pendingOperation = findPendingOperation(shadowProvisioning, OperationResultStatusType.IN_PROGRESS, null);
    assertPendingOperation(shadowProvisioning, pendingOperation, accountWillReqestTimestampStart, accountWillReqestTimestampEnd);
    PrismObject<ShadowType> shadowProvisioningFuture = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), task, result);
    display("Provisioning shadow (future)", shadowProvisioningFuture);
    assertShadowName(shadowProvisioningFuture, ACCOUNT_WILL_USERNAME);
    assertShadowDead(shadowProvisioningFuture);
    assertShadowPassword(shadowProvisioningFuture);
    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) AbstractProvisioningIntegrationTest(com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)

Example 35 with PendingOperationType

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

the class AbstractManualResourceTest method test320RefreshAccountWillAfter5min.

/**
	 * ff 5min, everything should be the same (grace not expired yet)
	 */
@Test
public void test320RefreshAccountWillAfter5min() throws Exception {
    final String TEST_NAME = "test320RefreshAccountWillAfter5min";
    displayTestTile(TEST_NAME);
    // GIVEN
    Task task = createTask(TEST_NAME);
    OperationResult result = task.getResult();
    syncServiceMock.reset();
    clock.overrideDuration("PT5M");
    PrismObject<ShadowType> shadowBefore = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
    display("Shadow before", shadowBefore);
    // WHEN
    displayWhen(TEST_NAME);
    provisioningService.refreshShadow(shadowBefore, null, task, result);
    // THEN
    displayThen(TEST_NAME);
    assertSuccess(result);
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, result);
    display("Repo shadow", shadowRepo);
    assertSinglePendingOperation(shadowRepo, accountWillReqestTimestampStart, accountWillReqestTimestampEnd, OperationResultStatusType.SUCCESS, accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
    assertShadowDead(shadowRepo);
    syncServiceMock.assertNoNotifyChange();
    syncServiceMock.assertNoNotifcations();
    PrismObject<ShadowType> shadowProvisioning = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result);
    display("Provisioning shadow", shadowProvisioning);
    ShadowType shadowTypeProvisioning = shadowProvisioning.asObjectable();
    assertShadowName(shadowProvisioning, ACCOUNT_WILL_USERNAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeProvisioning.getKind());
    assertShadowDead(shadowProvisioning);
    assertShadowPassword(shadowProvisioning);
    PendingOperationType pendingOperation = assertSinglePendingOperation(shadowProvisioning, accountWillReqestTimestampStart, accountWillReqestTimestampEnd, OperationResultStatusType.SUCCESS, accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
    PrismObject<ShadowType> shadowProvisioningFuture = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)), task, result);
    display("Provisioning shadow (future)", shadowProvisioningFuture);
    assertShadowName(shadowProvisioningFuture, ACCOUNT_WILL_USERNAME);
    assertShadowDead(shadowProvisioningFuture);
    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) AbstractProvisioningIntegrationTest(com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)

Aggregations

PendingOperationType (com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType)43 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)41 Task (com.evolveum.midpoint.task.api.Task)41 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)41 Test (org.testng.annotations.Test)38 AbstractConfiguredModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest)19 AbstractProvisioningIntegrationTest (com.evolveum.midpoint.provisioning.impl.AbstractProvisioningIntegrationTest)19 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)4 OperationResultStatusType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType)4 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)2 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)2