Search in sources :

Example 6 with ExpressionVariables

use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.

the class TestModelExpressions method testGetLinkedShadowName.

@Test
public void testGetLinkedShadowName() throws Exception {
    final String TEST_NAME = "testGetLinkedShadowName";
    TestUtil.displayTestTile(this, TEST_NAME);
    rememberShadowFetchOperationCount();
    ExpressionVariables variables = ExpressionVariables.create(ExpressionConstants.VAR_USER, getUser(USER_GUYBRUSH_OID));
    assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
    assertShadowFetchOperationCountIncrement(1);
}
Also used : ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 7 with ExpressionVariables

use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.

the class TestModelExpressions method testGetLinkedShadowNameRepo.

@Test
public void testGetLinkedShadowNameRepo() throws Exception {
    final String TEST_NAME = "testGetLinkedShadowNameRepo";
    TestUtil.displayTestTile(this, TEST_NAME);
    rememberShadowFetchOperationCount();
    ExpressionVariables variables = ExpressionVariables.create(ExpressionConstants.VAR_USER, getUser(USER_GUYBRUSH_OID));
    assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
    assertShadowFetchOperationCountIncrement(0);
}
Also used : ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 8 with ExpressionVariables

use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.

the class TestModelExpressions method testGetLinkedShadowKindIntentFullname.

@Test
public void testGetLinkedShadowKindIntentFullname() throws Exception {
    final String TEST_NAME = "testGetLinkedShadowKindIntentFullname";
    TestUtil.displayTestTile(this, TEST_NAME);
    rememberShadowFetchOperationCount();
    ExpressionVariables variables = ExpressionVariables.create(ExpressionConstants.VAR_USER, getUser(USER_GUYBRUSH_OID));
    assertExecuteScriptExpressionString(TEST_NAME, variables, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME);
    assertShadowFetchOperationCountIncrement(1);
}
Also used : ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 9 with ExpressionVariables

use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.

the class TestModelExpressions method testGetManagersOids.

@Test
public void testGetManagersOids() throws Exception {
    final String TEST_NAME = "testGetManagersOids";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestModelExpressions.class.getName() + "." + TEST_NAME);
    PrismObject<UserType> chef = repositoryService.getObject(UserType.class, CHEF_OID, null, result);
    ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + TEST_NAME + ".xml");
    PrismPropertyDefinition<String> outputDefinition = new PrismPropertyDefinitionImpl<>(PROPERTY_NAME, DOMUtil.XSD_STRING, PrismTestUtil.getPrismContext());
    ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression(scriptType, outputDefinition, TEST_NAME);
    ExpressionVariables variables = new ExpressionVariables();
    variables.addVariableDefinition(new QName(SchemaConstants.NS_C, "user"), chef);
    // WHEN
    List<PrismPropertyValue<String>> scriptOutputs = evaluate(scriptExpression, variables, false, TEST_NAME, null, result);
    // THEN
    display("Script output", scriptOutputs);
    assertEquals("Unexpected number of script outputs", 3, scriptOutputs.size());
    Set<String> oids = new HashSet<String>();
    oids.add(scriptOutputs.get(0).getValue());
    oids.add(scriptOutputs.get(1).getValue());
    oids.add(scriptOutputs.get(2).getValue());
    Set<String> expectedOids = new HashSet<String>(Arrays.asList(new String[] { CHEESE_OID, CHEESE_JR_OID, LECHUCK_OID }));
    assertEquals("Unexpected script output", expectedOids, oids);
}
Also used : ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ScriptExpressionEvaluatorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ScriptExpressionEvaluatorType) ScriptExpression(com.evolveum.midpoint.model.common.expression.script.ScriptExpression) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Example 10 with ExpressionVariables

use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.

the class TestModelExpressions method testGetUserByOid.

@Test
public void testGetUserByOid() throws Exception {
    final String TEST_NAME = "testGetUserByOid";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    OperationResult result = new OperationResult(TestModelExpressions.class.getName() + "." + TEST_NAME);
    PrismObject<UserType> chef = repositoryService.getObject(UserType.class, CHEF_OID, null, result);
    ExpressionVariables variables = ExpressionVariables.create(ExpressionConstants.VAR_USER, chef);
    // WHEN, THEN
    assertExecuteScriptExpressionString(TEST_NAME, variables, chef.asObjectable().getName().getOrig());
}
Also used : ExpressionVariables(com.evolveum.midpoint.repo.common.expression.ExpressionVariables) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) AbstractInternalModelIntegrationTest(com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)

Aggregations

ExpressionVariables (com.evolveum.midpoint.repo.common.expression.ExpressionVariables)65 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)17 QName (javax.xml.namespace.QName)15 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)10 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)10 Test (org.testng.annotations.Test)10 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)9 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)9 ExpressionEvaluationContext (com.evolveum.midpoint.repo.common.expression.ExpressionEvaluationContext)9 Task (com.evolveum.midpoint.task.api.Task)8 ArrayList (java.util.ArrayList)8 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)7 PrismObject (com.evolveum.midpoint.prism.PrismObject)6 PrismPropertyDefinitionImpl (com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl)6 ExpressionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType)6 PrismContext (com.evolveum.midpoint.prism.PrismContext)5 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)5 SystemException (com.evolveum.midpoint.util.exception.SystemException)5 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)5 ScriptExpression (com.evolveum.midpoint.model.common.expression.script.ScriptExpression)4