Search in sources :

Example 76 with VariablesMap

use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.

the class TestExpression method test110Path.

@Test
public void test110Path() throws Exception {
    // GIVEN
    OperationResult result = createOperationResult();
    rememberScriptExecutionCount();
    ExpressionType expressionType = parseExpression(EXPRESSION_PATH_FILE);
    Collection<Source<?, ?>> sources = prepareStringSources();
    VariablesMap variables = prepareBasicVariables();
    ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null);
    // WHEN
    PrismValueDeltaSetTriple<PrismPropertyValue<String>> outputTriple = evaluatePropertyExpression(expressionType, PrimitiveType.STRING, expressionContext, result);
    // THEN
    assertOutputTriple(outputTriple).assertEmptyMinus().assertEmptyPlus().zeroSet().assertSinglePropertyValue(USER_JACK_NAME);
    assertScriptExecutionIncrement(0);
}
Also used : ExpressionEvaluationContext(com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) Source(com.evolveum.midpoint.repo.common.expression.Source) Test(org.testng.annotations.Test) AbstractModelCommonTest(com.evolveum.midpoint.model.common.AbstractModelCommonTest)

Example 77 with VariablesMap

use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.

the class TestExpression method test100AsIs.

@Test
public void test100AsIs() throws Exception {
    // GIVEN
    OperationResult result = createOperationResult();
    rememberScriptExecutionCount();
    ExpressionType expressionType = parseExpression(EXPRESSION_ASIS_FILE);
    Collection<Source<?, ?>> sources = prepareStringSources();
    VariablesMap variables = prepareBasicVariables();
    ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null);
    // WHEN
    PrismValueDeltaSetTriple<PrismPropertyValue<String>> outputTriple = evaluatePropertyExpression(expressionType, PrimitiveType.STRING, expressionContext, result);
    // THEN
    assertOutputTriple(outputTriple).assertEmptyMinus().assertEmptyPlus().zeroSet().assertSinglePropertyValue(INPUT_VALUE);
    assertScriptExecutionIncrement(0);
}
Also used : ExpressionEvaluationContext(com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) Source(com.evolveum.midpoint.repo.common.expression.Source) Test(org.testng.annotations.Test) AbstractModelCommonTest(com.evolveum.midpoint.model.common.AbstractModelCommonTest)

Example 78 with VariablesMap

use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.

the class TestExpression method test130Const.

@Test
public void test130Const() throws Exception {
    // GIVEN
    OperationResult result = createOperationResult();
    rememberScriptExecutionCount();
    ExpressionType expressionType = parseExpression(EXPRESSION_CONST_FILE);
    Collection<Source<?, ?>> sources = prepareStringSources();
    VariablesMap variables = prepareBasicVariables();
    ExpressionEvaluationContext expressionContext = new ExpressionEvaluationContext(sources, variables, getTestNameShort(), null);
    // WHEN
    PrismValueDeltaSetTriple<PrismPropertyValue<String>> outputTriple = evaluatePropertyExpression(expressionType, PrimitiveType.STRING, expressionContext, result);
    // THEN
    assertOutputTriple(outputTriple).assertEmptyMinus().assertEmptyPlus().zeroSet().assertSinglePropertyValue(ExpressionTestUtil.CONST_FOO_VALUE);
    assertScriptExecutionIncrement(0);
}
Also used : ExpressionEvaluationContext(com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) Source(com.evolveum.midpoint.repo.common.expression.Source) Test(org.testng.annotations.Test) AbstractModelCommonTest(com.evolveum.midpoint.model.common.AbstractModelCommonTest)

Example 79 with VariablesMap

use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.

the class TestExpressionUtil method createVariables.

private VariablesMap createVariables() throws SchemaException, IOException {
    VariablesMap variables = new VariablesMap();
    PrismObject<UserType> user = createUser();
    variables.addVariableDefinition(ExpressionConstants.VAR_USER, user, user.getDefinition());
    variables.addVariableDefinition(ExpressionConstants.VAR_FOCUS, user, user.getDefinition());
    return variables;
}
Also used : VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Example 80 with VariablesMap

use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.

the class TestExpressionUtil method createVariablesOdo.

private VariablesMap createVariablesOdo() throws SchemaException, IOException {
    VariablesMap variables = new VariablesMap();
    PrismObject<UserType> userOld = createUser();
    ObjectDelta<UserType> delta = PrismTestUtil.getPrismContext().deltaFactory().object().createModificationReplaceProperty(UserType.class, userOld.getOid(), UserType.F_FULL_NAME, PrismTestUtil.createPolyString("Captain Jack Sparrow"));
    ObjectDeltaObject<UserType> odo = new ObjectDeltaObject<>(userOld, delta, null, userOld.getDefinition());
    odo.recompute();
    variables.addVariableDefinition(ExpressionConstants.VAR_USER, odo, odo.getDefinition());
    variables.addVariableDefinition(ExpressionConstants.VAR_FOCUS, odo, odo.getDefinition());
    return variables;
}
Also used : ObjectDeltaObject(com.evolveum.midpoint.prism.util.ObjectDeltaObject) VariablesMap(com.evolveum.midpoint.schema.expression.VariablesMap) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)

Aggregations

VariablesMap (com.evolveum.midpoint.schema.expression.VariablesMap)166 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)48 ExpressionEvaluationContext (com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext)30 Test (org.testng.annotations.Test)28 Task (com.evolveum.midpoint.task.api.Task)23 NotNull (org.jetbrains.annotations.NotNull)23 QName (javax.xml.namespace.QName)15 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)12 Source (com.evolveum.midpoint.repo.common.expression.Source)12 AbstractModelCommonTest (com.evolveum.midpoint.model.common.AbstractModelCommonTest)11 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)11 ExpressionFactory (com.evolveum.midpoint.repo.common.expression.ExpressionFactory)10 Trace (com.evolveum.midpoint.util.logging.Trace)10 TraceManager (com.evolveum.midpoint.util.logging.TraceManager)10 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)9 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)9 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)9 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)8 ExpressionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType)8 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)7