use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.
the class TestModelExpressions method testGetLinkedShadowKindIntentFullname.
@Test
public void testGetLinkedShadowKindIntentFullname() throws Exception {
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
PrismObject<UserType> user = getUser(USER_GUYBRUSH_OID);
VariablesMap variables = createVariables(ExpressionConstants.VAR_USER, user, user.getDefinition());
assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_FULLNAME);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1);
}
use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.
the class TestModelExpressions method testGetManagersOids.
@Test
public void testGetManagersOids() throws Exception {
// GIVEN
OperationResult result = createOperationResult();
String shortTestName = getTestNameShort();
PrismObject<UserType> chef = repositoryService.getObject(UserType.class, CHEF_OID, null, result);
ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + shortTestName + ".xml");
PrismPropertyDefinition<String> outputDefinition = getPrismContext().definitionFactory().createPropertyDefinition(PROPERTY_NAME, DOMUtil.XSD_STRING);
ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression(scriptType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), expressionFactory, shortTestName, result);
VariablesMap variables = createVariables(ExpressionConstants.VAR_USER, chef, chef.getDefinition());
// WHEN
List<PrismPropertyValue<String>> scriptOutputs = evaluate(scriptExpression, variables, false, shortTestName, null, result);
// THEN
display("Script output", scriptOutputs);
assertEquals("Unexpected number of script outputs", 3, scriptOutputs.size());
Set<String> oids = new HashSet<>();
oids.add(scriptOutputs.get(0).getValue());
oids.add(scriptOutputs.get(1).getValue());
oids.add(scriptOutputs.get(2).getValue());
Set<String> expectedOids = new HashSet<>(Arrays.asList(CHEESE_OID, CHEESE_JR_OID, LECHUCK_OID));
assertEquals("Unexpected script output", expectedOids, oids);
}
use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.
the class TestModelExpressions method testGetLinkedShadowNameRepo.
@Test
public void testGetLinkedShadowNameRepo() throws Exception {
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
PrismObject<UserType> user = getUser(USER_GUYBRUSH_OID);
VariablesMap variables = createVariables(ExpressionConstants.VAR_USER, user, user.getDefinition());
assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0);
}
use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.
the class TestModelExpressions method testGetLinkedShadowName.
@Test
public void testGetLinkedShadowName() throws Exception {
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);
PrismObject<UserType> user = getUser(USER_GUYBRUSH_OID);
VariablesMap variables = createVariables(ExpressionConstants.VAR_USER, user, user.getDefinition());
assertExecuteScriptExpressionString(variables, ACCOUNT_GUYBRUSH_DUMMY_USERNAME);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1);
}
use of com.evolveum.midpoint.schema.expression.VariablesMap in project midpoint by Evolveum.
the class TestModelExpressions method executeScriptExpressionString.
private String executeScriptExpressionString(VariablesMap variables) throws SecurityViolationException, ExpressionEvaluationException, SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, IOException {
// GIVEN
Task task = getTestTask();
OperationResult result = task.getResult();
String shortTestName = getTestNameShort();
ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + shortTestName + ".xml");
ItemDefinition<?> outputDefinition = getPrismContext().definitionFactory().createPropertyDefinition(PROPERTY_NAME, DOMUtil.XSD_STRING);
ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression(scriptType, outputDefinition, MiscSchemaUtil.getExpressionProfile(), expressionFactory, shortTestName, result);
if (variables == null) {
variables = new VariablesMap();
}
// WHEN
when();
List<PrismPropertyValue<String>> scriptOutputs = evaluate(scriptExpression, variables, false, shortTestName, null, result);
// THEN
then();
display("Script output", scriptOutputs);
result.computeStatus();
TestUtil.assertSuccess(result);
if (scriptOutputs.size() == 0) {
return null;
}
assertEquals("Unexpected number of script outputs", 1, scriptOutputs.size());
PrismPropertyValue<String> scriptOutput = scriptOutputs.get(0);
if (scriptOutput == null) {
return null;
}
return scriptOutput.getValue();
}
Aggregations