Search in sources :

Example 11 with RawType

use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.

the class TestUserChangeApprovalLegacy method checkAssignmentConstruction.

private void checkAssignmentConstruction(UserType jack, String attributeName, String value) throws SchemaException {
    assertEquals("jack's assignments", 1, jack.getAssignment().size());
    AssignmentType assignmentType = jack.getAssignment().get(0);
    ConstructionType constructionType = assignmentType.getConstruction();
    assertNotNull("construction is null", constructionType);
    boolean found = false;
    for (ResourceAttributeDefinitionType attributeDefinitionType : constructionType.getAttribute()) {
        if (attributeDefinitionType.getRef().equivalent(new ItemPathType(new ItemPath(new QName(attributeName))))) {
            ExpressionType expressionType = attributeDefinitionType.getOutbound().getExpression();
            assertNotNull("no expression", expressionType);
            assertEquals("wrong # of expression evaluators", 1, expressionType.getExpressionEvaluator().size());
            JAXBElement<?> element = expressionType.getExpressionEvaluator().get(0);
            PrimitiveXNode valueXNode = (PrimitiveXNode) (((RawType) element.getValue()).serializeToXNode());
            assertEquals("wrong outbound value", value, valueXNode.getStringValue());
            found = true;
        }
    }
    assertTrue("attribute " + attributeName + " mapping not found", found);
}
Also used : PrimitiveXNode(com.evolveum.midpoint.prism.xnode.PrimitiveXNode) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) QName(javax.xml.namespace.QName) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 12 with RawType

use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.

the class ShadowAttributeIdSyncStoreReadTest method verifyHasId.

private void verifyHasId(PrismContainerValue<ShadowType> anyValue) {
    PrismProperty<?> id = (PrismProperty<?>) anyValue.asContainerable().getAttributes().asPrismContainerValue().findItem(RI_ID, PrismProperty.class);
    Object loadedId = id.getValue().getValue();
    assertEquals(SHADOW_ID, loadedId instanceof RawType ? ((RawType) loadedId).extractString() : loadedId);
}
Also used : PrismProperty(com.evolveum.midpoint.prism.PrismProperty) PrismObject(com.evolveum.midpoint.prism.PrismObject) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType)

Example 13 with RawType

use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.

the class AbstractDirectManualResourceTest 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 {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    accountWillReqestTimestampStart = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    when();
    modifyUserReplace(userWillOid, ACTIVATION_ADMINISTRATIVE_STATUS_PATH, task, result, ActivationStatusType.DISABLED);
    // THEN
    then();
    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, new RawType(itemFactory().createPropertyValue(USER_WILL_NAME), ATTR_USERNAME_QNAME, prismContext));
    assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, new RawType(itemFactory().createPropertyValue(USER_WILL_FULL_NAME_PIRATE), ATTR_FULLNAME_QNAME, prismContext));
    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);
    assertCaseState(willLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) Test(org.testng.annotations.Test)

Example 14 with RawType

use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.

the class AbstractDirectManualResourceTest method test230ModifyAccountWillChangePasswordAndEnable.

/**
 * Change password, enable. There is still pending disable delta. Make sure all the deltas are
 * stored correctly.
 */
@Test
public void test230ModifyAccountWillChangePasswordAndEnable() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ObjectDelta<UserType> delta = prismContext.deltaFactory().object().createModificationReplaceProperty(UserType.class, userWillOid, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS, ActivationStatusType.ENABLED);
    ProtectedStringType ps = new ProtectedStringType();
    ps.setClearValue(USER_WILL_PASSWORD_NEW);
    delta.addModificationReplaceProperty(SchemaConstants.PATH_PASSWORD_VALUE, ps);
    displayDumpable("ObjectDelta", delta);
    accountWillSecondReqestTimestampStart = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    when();
    executeChanges(delta, null, task, result);
    // THEN
    then();
    display("result", result);
    willSecondLastCaseOid = assertInProgress(result);
    accountWillSecondReqestTimestampEnd = clock.currentTimeXMLGregorianCalendar();
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result);
    display("Repo shadow", shadowRepo);
    assertPendingOperationDeltas(shadowRepo, 3);
    PendingOperationType pendingOperation = findPendingOperation(shadowRepo, OperationResultStatusType.IN_PROGRESS, SchemaConstants.PATH_PASSWORD_VALUE);
    assertPendingOperation(shadowRepo, pendingOperation, accountWillSecondReqestTimestampStart, accountWillSecondReqestTimestampEnd);
    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, new RawType(itemFactory().createPropertyValue(USER_WILL_NAME), ATTR_USERNAME_QNAME, prismContext));
    assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, new RawType(itemFactory().createPropertyValue(USER_WILL_FULL_NAME_PIRATE), ATTR_FULLNAME_QNAME, prismContext));
    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);
    assertAttribute(shadowProvisioning, ATTR_FULLNAME_QNAME, USER_WILL_FULL_NAME_PIRATE);
    assertAttributeFromBackingStore(shadowProvisioning, ATTR_DESCRIPTION_QNAME, ACCOUNT_WILL_DESCRIPTION_MANUAL);
    assertShadowPassword(shadowProvisioning);
    assertPendingOperationDeltas(shadowProvisioning, 3);
    pendingOperation = findPendingOperation(shadowProvisioning, OperationResultStatusType.IN_PROGRESS, SchemaConstants.PATH_PASSWORD_VALUE);
    assertPendingOperation(shadowProvisioning, pendingOperation, accountWillSecondReqestTimestampStart, accountWillSecondReqestTimestampEnd);
    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);
    new PrismObjectAsserter<>(shadowProvisioningFuture).assertSanity();
    assertNotNull("No async reference in result", willSecondLastCaseOid);
    assertCaseState(willLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
    assertCaseState(willSecondLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) Test(org.testng.annotations.Test)

Example 15 with RawType

use of com.evolveum.prism.xml.ns._public.types_3.RawType in project midpoint by Evolveum.

the class AbstractDirectManualResourceTest method test240CloseDisableCaseAndReadAccountWill.

/**
 * Disable case is closed. The account should be disabled. But there is still the other
 * delta pending.
 * Do NOT explicitly refresh the shadow in this case. Just reading it should cause the refresh.
 */
@Test
public void test240CloseDisableCaseAndReadAccountWill() throws Exception {
    // GIVEN
    Task task = getTestTask();
    OperationResult result = task.getResult();
    closeCase(willLastCaseOid);
    accountWillCompletionTimestampStart = clock.currentTimeXMLGregorianCalendar();
    // WHEN
    when();
    PrismObject<ShadowType> shadowModel = modelService.getObject(ShadowType.class, accountWillOid, null, task, result);
    // THEN
    then();
    assertSuccess(result);
    accountWillCompletionTimestampEnd = clock.currentTimeXMLGregorianCalendar();
    PrismObject<ShadowType> shadowRepo = repositoryService.getObject(ShadowType.class, accountWillOid, null, result);
    display("Repo shadow", shadowRepo);
    assertPendingOperationDeltas(shadowRepo, 3);
    PendingOperationType pendingOperation = findPendingOperation(shadowRepo, OperationResultStatusType.SUCCESS, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
    assertPendingOperation(shadowRepo, pendingOperation, accountWillReqestTimestampStart, accountWillReqestTimestampEnd, PendingOperationExecutionStatusType.COMPLETED, OperationResultStatusType.SUCCESS, accountWillCompletionTimestampStart, accountWillCompletionTimestampEnd);
    pendingOperation = findPendingOperation(shadowRepo, OperationResultStatusType.IN_PROGRESS, SchemaConstants.PATH_PASSWORD_VALUE);
    assertPendingOperation(shadowRepo, pendingOperation, accountWillSecondReqestTimestampStart, accountWillSecondReqestTimestampEnd);
    assertShadowActivationAdministrativeStatusFromCache(shadowRepo, ActivationStatusType.DISABLED);
    assertAttribute(shadowRepo, ATTR_USERNAME_QNAME, new RawType(itemFactory().createPropertyValue(USER_WILL_NAME), ATTR_USERNAME_QNAME, prismContext));
    assertAttributeFromCache(shadowRepo, ATTR_FULLNAME_QNAME, new RawType(itemFactory().createPropertyValue(USER_WILL_FULL_NAME_PIRATE), ATTR_FULLNAME_QNAME, prismContext));
    display("Model shadow", shadowModel);
    ShadowType shadowTypeModel = shadowModel.asObjectable();
    assertShadowName(shadowModel, USER_WILL_NAME);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowTypeModel.getKind());
    if (supportsBackingStore()) {
        assertShadowActivationAdministrativeStatus(shadowModel, ActivationStatusType.ENABLED);
    } else {
        assertShadowActivationAdministrativeStatus(shadowModel, ActivationStatusType.DISABLED);
    }
    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, 3);
    pendingOperation = findPendingOperation(shadowModel, OperationResultStatusType.SUCCESS, SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
    assertPendingOperation(shadowModel, pendingOperation, accountWillReqestTimestampStart, accountWillReqestTimestampEnd, PendingOperationExecutionStatusType.COMPLETED, 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);
    assertEquals("Wrong kind (provisioning)", ShadowKindType.ACCOUNT, shadowModelFuture.asObjectable().getKind());
    assertShadowActivationAdministrativeStatus(shadowModelFuture, ActivationStatusType.ENABLED);
    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);
    // TODO
    // assertShadowPassword(shadowProvisioningFuture);
    assertCaseState(willLastCaseOid, SchemaConstants.CASE_STATE_CLOSED);
    assertCaseState(willSecondLastCaseOid, SchemaConstants.CASE_STATE_OPEN);
    assertSteadyResources();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) RawType(com.evolveum.prism.xml.ns._public.types_3.RawType) Test(org.testng.annotations.Test)

Aggregations

RawType (com.evolveum.prism.xml.ns._public.types_3.RawType)62 QName (javax.xml.namespace.QName)22 Test (org.testng.annotations.Test)19 JAXBElement (javax.xml.bind.JAXBElement)18 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)16 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)13 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)10 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)10 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)9 ItemDeltaType (com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType)9 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)9 ArrayList (java.util.ArrayList)9 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)8 Task (com.evolveum.midpoint.task.api.Task)8 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)7 ProtectedStringType (com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType)7 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)6 PrimitiveXNode (com.evolveum.midpoint.prism.xnode.PrimitiveXNode)6 TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)6 PrismObject (com.evolveum.midpoint.prism.PrismObject)5