use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test220SearchForUsersAccounts.
@Test
public void test220SearchForUsersAccounts() throws Exception {
final String TEST_NAME = "test220SearchForUsersAccounts";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<SearchExpressionType> expression = parseAnyData(SEARCH_FOR_USERS_ACCOUNTS_FILE);
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
TestUtil.assertSuccess(result);
assertEquals(4, output.getFinalOutput().getData().size());
assertAttributesFetched(output.getFinalOutput().getData());
}
use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test500ScriptingUsers.
@Test
public void test500ScriptingUsers() throws Exception {
final String TEST_NAME = "test500ScriptingUsers";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<ScriptingExpressionType> expression = parseAnyData(SCRIPTING_USERS_FILE);
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
TestUtil.assertSuccess(result);
PipelineData data = output.getFinalOutput();
assertEquals("Unexpected # of items in output", 5, data.getData().size());
Set<String> realOids = new HashSet<>();
for (PipelineItem item : data.getData()) {
PrismValue value = item.getValue();
PrismObject<UserType> user = ((PrismObjectValue<UserType>) value).asPrismObject();
assertEquals("Description not set", "Test", user.asObjectable().getDescription());
realOids.add(user.getOid());
assertSuccess(item.getResult());
}
assertEquals("Unexpected OIDs in output", Sets.newHashSet(Arrays.asList(USER_ADMINISTRATOR_OID, USER_JACK_OID, USER_BARBOSSA_OID, USER_GUYBRUSH_OID, USER_ELAINE_OID)), realOids);
}
use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test520GeneratePasswordsFullInput.
@Test
public void test520GeneratePasswordsFullInput() throws Exception {
final String TEST_NAME = "test520GeneratePasswordsFullInput";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
ExecuteScriptType executeScript = parseRealValue(GENERATE_PASSWORDS_2_FILE);
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(executeScript, task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
//TestUtil.assertSuccess(result);
PipelineData data = output.getFinalOutput();
List<PipelineItem> items = data.getData();
assertEquals("Unexpected # of items in output", 4, items.size());
assertSuccess(items.get(0).getResult());
assertFailure(items.get(1).getResult());
assertSuccess(items.get(2).getResult());
assertSuccess(items.get(3).getResult());
}
use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test530GeneratePasswordsReally.
@Test
public void test530GeneratePasswordsReally() throws Exception {
final String TEST_NAME = "test530GeneratePasswordsReally";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
ExecuteScriptType executeScript = parseRealValue(GENERATE_PASSWORDS_3_FILE);
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(executeScript, task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
PipelineData data = output.getFinalOutput();
List<PipelineItem> items = data.getData();
assertEquals("Unexpected # of items in output", 3, items.size());
assertFailure(items.get(0).getResult());
assertSuccess(items.get(1).getResult());
assertSuccess(items.get(2).getResult());
checkPassword(items.get(1), USER_GUYBRUSH_OID);
checkPassword(items.get(2), USER_ELAINE_OID);
}
use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test225SearchForUsersAccountsNoFetch.
@Test
public void test225SearchForUsersAccountsNoFetch() throws Exception {
final String TEST_NAME = "test225SearchForUsersAccountsNoFetch";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<SearchExpressionType> expression = parseAnyData(SEARCH_FOR_USERS_ACCOUNTS_NOFETCH_FILE);
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
TestUtil.assertSuccess(result);
assertEquals(4, output.getFinalOutput().getData().size());
assertAttributesNotFetched(output.getFinalOutput().getData());
}
Aggregations