use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class TestModelExpressions method testGetLinkedShadowKindIntentUsernameRepo.
@Test
public void testGetLinkedShadowKindIntentUsernameRepo() throws Exception {
final String TEST_NAME = "testGetLinkedShadowKindIntentUsernameRepo";
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);
}
use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class TestModelExpressions method testGetLinkedShadowKindIntentUsername.
@Test
public void testGetLinkedShadowKindIntentUsername() throws Exception {
final String TEST_NAME = "testGetLinkedShadowKindIntentUsername";
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);
}
use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class TestModelExpressions method testIsUniquePropertyValue.
/**
* MID-2887
*/
@Test
public void testIsUniquePropertyValue() throws Exception {
final String TEST_NAME = "testIsUniquePropertyValue";
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<Boolean> outputDefinition = new PrismPropertyDefinitionImpl<>(PROPERTY_NAME, DOMUtil.XSD_BOOLEAN, PrismTestUtil.getPrismContext());
ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression(scriptType, outputDefinition, TEST_NAME);
ExpressionVariables variables = new ExpressionVariables();
variables.addVariableDefinition(new QName(SchemaConstants.NS_C, "user"), chef);
variables.addVariableDefinition(new QName(SchemaConstants.NS_C, "value"), "Scumm Bar Chef");
// WHEN
List<PrismPropertyValue<Boolean>> scriptOutputs = evaluate(scriptExpression, variables, false, TEST_NAME, null, result);
// THEN
display("Script output", scriptOutputs);
assertEquals("Unexpected number of script outputs", 1, scriptOutputs.size());
Boolean scriptOutput = scriptOutputs.get(0).getValue();
assertEquals("Unexpected script output", Boolean.TRUE, scriptOutput);
}
use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class TestModelExpressions method executeScriptExpressionString.
private String executeScriptExpressionString(final String TEST_NAME, ExpressionVariables variables) throws SchemaException, IOException, JAXBException, ExpressionEvaluationException, ObjectNotFoundException {
// GIVEN
OperationResult result = new OperationResult(TestModelExpressions.class.getName() + "." + TEST_NAME);
ScriptExpressionEvaluatorType scriptType = parseScriptType("expression-" + TEST_NAME + ".xml");
ItemDefinition outputDefinition = new PrismPropertyDefinitionImpl(PROPERTY_NAME, DOMUtil.XSD_STRING, PrismTestUtil.getPrismContext());
ScriptExpression scriptExpression = scriptExpressionFactory.createScriptExpression(scriptType, outputDefinition, TEST_NAME);
if (variables == null) {
variables = new ExpressionVariables();
}
// WHEN
TestUtil.displayWhen(TEST_NAME);
List<PrismPropertyValue<String>> scriptOutputs = evaluate(scriptExpression, variables, false, TEST_NAME, null, result);
// THEN
TestUtil.displayThen(TEST_NAME);
display("Script output", scriptOutputs);
result.computeStatus();
TestUtil.assertSuccess(result);
if (scriptOutputs.size() == 0) {
return null;
}
assertEquals("Unexpected number of script outputs", 1, scriptOutputs.size());
return scriptOutputs.get(0).getValue();
}
use of com.evolveum.midpoint.repo.common.expression.ExpressionVariables in project midpoint by Evolveum.
the class TestModelExpressions method testGetLinkedShadowKindIntentFullnameRepo.
@Test
public void testGetLinkedShadowKindIntentFullnameRepo() throws Exception {
final String TEST_NAME = "testGetLinkedShadowKindIntentFullnameRepo";
TestUtil.displayTestTile(this, TEST_NAME);
rememberShadowFetchOperationCount();
ExpressionVariables variables = ExpressionVariables.create(ExpressionConstants.VAR_USER, getUser(USER_GUYBRUSH_OID));
assertExecuteScriptExpressionString(TEST_NAME, variables, null);
assertShadowFetchOperationCountIncrement(0);
}
Aggregations