Search in sources :

Example 21 with UserType

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

the class TestMappingTime method testAfterTimeTo.

@Test
public void testAfterTimeTo() throws Exception {
    final String TEST_NAME = "testAfterTimeTo";
    System.out.println("===[ " + TEST_NAME + "]===");
    // GIVEN
    ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), "CAPTAIN");
    Mapping.Builder<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> builder = evaluator.createMappingBuilder(MAPPING_TIME_FROM_TO_FILENAME, TEST_NAME, "title", delta);
    builder.setNow(TIME_FUTURE);
    Mapping<PrismPropertyValue<PolyString>, PrismPropertyDefinition<PolyString>> mapping = builder.build();
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    PrismValueDeltaSetTriple<PrismPropertyValue<PolyString>> outputTriple = mapping.getOutputTriple();
    assertNullTriple(outputTriple);
    assertNextRecompute(mapping, null);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 22 with UserType

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

the class TestMappingTime method testSetReferenceTimeBefore.

@Test
public void testSetReferenceTimeBefore() throws Exception {
    final String TEST_NAME = "testSetReferenceTimeBefore";
    System.out.println("===[ " + TEST_NAME + "]===");
    // GIVEN
    PrismObject<UserType> userOld = evaluator.getUserOld();
    XMLGregorianCalendar disableTimestamp = userOld.asObjectable().getActivation().getDisableTimestamp();
    userOld.asObjectable().getActivation().setDisableTimestamp(null);
    ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, new ItemPath(UserType.F_ACTIVATION, ActivationType.F_DISABLE_TIMESTAMP), evaluator.getPrismContext(), disableTimestamp);
    Mapping.Builder<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> builder = evaluator.createMappingBuilder(MAPPING_TIME_ACTIVATION, TEST_NAME, "title", delta, userOld);
    builder.setNow(TIME_PAST);
    PrismPropertyDefinition<Boolean> existenceDef = new PrismPropertyDefinitionImpl<>(ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_BOOLEAN, evaluator.getPrismContext());
    builder.setDefaultTargetDefinition(existenceDef);
    Mapping<PrismPropertyValue<Boolean>, PrismPropertyDefinition<Boolean>> mapping = builder.build();
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    PrismValueDeltaSetTriple<PrismPropertyValue<Boolean>> outputTriple = mapping.getOutputTriple();
    assertNullTriple(outputTriple);
    assertNextRecompute(mapping, TIME_MAPPING_DISABLED_PLUS_1M);
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Example 23 with UserType

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

the class ModelWebServiceRaw method invokeAllowingFaults.

public DOMSource invokeAllowingFaults(DOMSource request) throws FaultMessage {
    Node rootNode = request.getNode();
    Element rootElement;
    if (rootNode instanceof Document) {
        rootElement = ((Document) rootNode).getDocumentElement();
    } else if (rootNode instanceof Element) {
        rootElement = (Element) rootNode;
    } else {
        throw ws.createIllegalArgumentFault("Unexpected DOM node type: " + rootNode);
    }
    Object requestObject;
    try {
        requestObject = prismContext.parserFor(rootElement).parseRealValue();
    } catch (SchemaException e) {
        throw ws.createIllegalArgumentFault("Couldn't parse SOAP request body because of schema exception: " + e.getMessage());
    }
    Node response;
    Holder<OperationResultType> operationResultTypeHolder = new Holder<>();
    try {
        PrismSerializer<Element> serializer = prismContext.domSerializer().options(SerializationOptions.createSerializeReferenceNames());
        if (requestObject instanceof GetObjectType) {
            GetObjectType g = (GetObjectType) requestObject;
            Holder<ObjectType> objectTypeHolder = new Holder<>();
            ws.getObject(g.getObjectType(), g.getOid(), g.getOptions(), objectTypeHolder, operationResultTypeHolder);
            GetObjectResponseType gr = new GetObjectResponseType();
            gr.setObject(objectTypeHolder.value);
            gr.setResult(operationResultTypeHolder.value);
            response = serializer.serializeAnyData(gr, ModelPort.GET_OBJECT_RESPONSE);
        } else if (requestObject instanceof SearchObjectsType) {
            SearchObjectsType s = (SearchObjectsType) requestObject;
            Holder<ObjectListType> objectListTypeHolder = new Holder<>();
            ws.searchObjects(s.getObjectType(), s.getQuery(), s.getOptions(), objectListTypeHolder, operationResultTypeHolder);
            SearchObjectsResponseType sr = new SearchObjectsResponseType();
            sr.setObjectList(objectListTypeHolder.value);
            sr.setResult(operationResultTypeHolder.value);
            response = serializer.serializeAnyData(sr, ModelPort.SEARCH_OBJECTS_RESPONSE);
        } else if (requestObject instanceof ExecuteChangesType) {
            ExecuteChangesType e = (ExecuteChangesType) requestObject;
            ObjectDeltaOperationListType objectDeltaOperationListType = ws.executeChanges(e.getDeltaList(), e.getOptions());
            ExecuteChangesResponseType er = new ExecuteChangesResponseType();
            er.setDeltaOperationList(objectDeltaOperationListType);
            response = serializer.serializeAnyData(er, ModelPort.EXECUTE_CHANGES_RESPONSE);
        } else if (requestObject instanceof FindShadowOwnerType) {
            FindShadowOwnerType f = (FindShadowOwnerType) requestObject;
            Holder<UserType> userTypeHolder = new Holder<>();
            ws.findShadowOwner(f.getShadowOid(), userTypeHolder, operationResultTypeHolder);
            FindShadowOwnerResponseType fsr = new FindShadowOwnerResponseType();
            fsr.setUser(userTypeHolder.value);
            fsr.setResult(operationResultTypeHolder.value);
            response = serializer.serializeAnyData(fsr, ModelPort.FIND_SHADOW_OWNER_RESPONSE);
        } else if (requestObject instanceof TestResourceType) {
            TestResourceType tr = (TestResourceType) requestObject;
            OperationResultType operationResultType = ws.testResource(tr.getResourceOid());
            TestResourceResponseType trr = new TestResourceResponseType();
            trr.setResult(operationResultType);
            response = serializer.serializeAnyData(trr, ModelPort.TEST_RESOURCE_RESPONSE);
        } else if (requestObject instanceof ExecuteScriptsType) {
            ExecuteScriptsType es = (ExecuteScriptsType) requestObject;
            ExecuteScriptsResponseType esr = ws.executeScripts(es);
            response = serializer.serializeAnyData(esr, ModelPort.EXECUTE_SCRIPTS_RESPONSE);
        } else if (requestObject instanceof ImportFromResourceType) {
            ImportFromResourceType ifr = (ImportFromResourceType) requestObject;
            TaskType taskType = ws.importFromResource(ifr.getResourceOid(), ifr.getObjectClass());
            ImportFromResourceResponseType ifrr = new ImportFromResourceResponseType();
            ifrr.setTask(taskType);
            response = serializer.serializeAnyData(ifrr, ModelPort.IMPORT_FROM_RESOURCE_RESPONSE);
        } else if (requestObject instanceof NotifyChangeType) {
            NotifyChangeType nc = (NotifyChangeType) requestObject;
            TaskType taskType = ws.notifyChange(nc.getChangeDescription());
            NotifyChangeResponseType ncr = new NotifyChangeResponseType();
            ncr.setTask(taskType);
            response = serializer.serializeAnyData(ncr, ModelPort.NOTIFY_CHANGE_RESPONSE);
        } else {
            throw ws.createIllegalArgumentFault("Unsupported request type: " + requestObject);
        }
    } catch (SchemaException e) {
        throwFault(e, operationResultTypeHolder.value);
        // not reached
        return null;
    }
    return new DOMSource(response);
}
Also used : ExecuteChangesResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.ExecuteChangesResponseType) DOMSource(javax.xml.transform.dom.DOMSource) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) ExecuteChangesType(com.evolveum.midpoint.xml.ns._public.model.model_3.ExecuteChangesType) FindShadowOwnerResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.FindShadowOwnerResponseType) Document(org.w3c.dom.Document) FindShadowOwnerType(com.evolveum.midpoint.xml.ns._public.model.model_3.FindShadowOwnerType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) GetObjectType(com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) GetObjectType(com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectType) ImportFromResourceType(com.evolveum.midpoint.xml.ns._public.model.model_3.ImportFromResourceType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) NotifyChangeType(com.evolveum.midpoint.xml.ns._public.model.model_3.NotifyChangeType) GetObjectResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.GetObjectResponseType) Holder(javax.xml.ws.Holder) NotifyChangeResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.NotifyChangeResponseType) TestResourceType(com.evolveum.midpoint.xml.ns._public.model.model_3.TestResourceType) SearchObjectsType(com.evolveum.midpoint.xml.ns._public.model.model_3.SearchObjectsType) ImportFromResourceResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.ImportFromResourceResponseType) ExecuteScriptsResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.ExecuteScriptsResponseType) ExecuteScriptsType(com.evolveum.midpoint.xml.ns._public.model.model_3.ExecuteScriptsType) SearchObjectsResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.SearchObjectsResponseType) TestResourceResponseType(com.evolveum.midpoint.xml.ns._public.model.model_3.TestResourceResponseType) ObjectDeltaOperationListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaOperationListType)

Example 24 with UserType

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

the class UserComputer method recompute.

public void recompute(PrismObject<UserType> user) {
    UserType userType = user.asObjectable();
    ActivationType activationType = userType.getActivation();
    if (activationType != null) {
        activationComputer.computeEffective(userType.getLifecycleState(), activationType);
    }
}
Also used : ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 25 with UserType

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

the class TestMappingDynamicSysVar method employeeTypeDeltaDelete.

public PrismValueDeltaSetTriple<PrismPropertyValue<String>> employeeTypeDeltaDelete(final String TEST_NAME, String delVal, String... oldVals) throws Exception {
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    ObjectDelta<UserType> delta = ObjectDelta.createModificationDeleteProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), delVal);
    Mapping<PrismPropertyValue<String>, PrismPropertyDefinition<String>> mapping = evaluator.createMapping("mapping-script-system-variables-employee-type.xml", TEST_NAME, "employeeType", delta);
    PrismObject<UserType> user = (PrismObject<UserType>) mapping.getSourceContext().getOldObject();
    setEmployeeType(user.asObjectable(), oldVals);
    mapping.getSourceContext().recompute();
    OperationResult opResult = new OperationResult(TEST_NAME);
    // WHEN
    mapping.evaluate(null, opResult);
    // THEN
    evaluator.assertResult(opResult);
    return mapping.getOutputTriple();
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Aggregations

UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1275 Test (org.testng.annotations.Test)1093 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1079 Task (com.evolveum.midpoint.task.api.Task)962 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)403 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)379 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)235 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)227 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)224 ArrayList (java.util.ArrayList)138 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)115 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)114 PrismObject (com.evolveum.midpoint.prism.PrismObject)88 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)88 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)85 TestValidityRecomputeTask (com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask)77 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)77 QName (javax.xml.namespace.QName)66 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)64 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)63