use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test410TestResource.
@Test
public void test410TestResource() throws Exception {
final String TEST_NAME = "test410TestResource";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<ScriptingExpressionType> expression = parseAnyData(TEST_DUMMY_RESOURCE_FILE);
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
ResourceType dummy = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, taskManager.createTaskInstance(), result).asObjectable();
display("dummy resource after test connection", dummy.asPrismObject());
result.computeStatus();
TestUtil.assertSuccess(result);
assertEquals(1, output.getFinalOutput().getData().size());
assertEquals("Tested resource:10000000-0000-0000-0000-000000000004(Dummy Resource): SUCCESS\n", output.getConsoleOutput());
}
use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test300DisableJack.
@Test
public void test300DisableJack() throws Exception {
final String TEST_NAME = "test300DisableJack";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<ScriptingExpressionType> expression = parseAnyData(DISABLE_JACK_FILE);
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
assertOutputData(output, 1, OperationResultStatus.SUCCESS);
assertEquals("Disabled user:c0c010c0-d34d-b33f-f00d-111111111111(jack)\n", output.getConsoleOutput());
result.computeStatus();
TestUtil.assertSuccess(result);
assertAdministrativeStatusDisabled(searchObjectByName(UserType.class, "jack"));
}
use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test205SearchForResources.
@Test
public void test205SearchForResources() throws Exception {
final String TEST_NAME = "test205SearchForResources";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<SearchExpressionType> expression = parseAnyData(SEARCH_FOR_RESOURCES_FILE);
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
TestUtil.assertSuccess(result);
assertEquals(13, output.getFinalOutput().getData().size());
}
use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test200SearchUser.
@Test
public void test200SearchUser() throws Exception {
final String TEST_NAME = "test200SearchUser";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<SearchExpressionType> expression = parseAnyData(SEARCH_FOR_USERS_FILE);
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
TestUtil.assertSuccess(result);
assertEquals(2, output.getFinalOutput().getData().size());
//assertEquals("administrator", ((PrismObject<UserType>) output.getData().get(0)).asObjectable().getName().getOrig());
}
use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test430NotificationAboutJackType2.
@Test
public void test430NotificationAboutJackType2() throws Exception {
final String TEST_NAME = "test430NotificationAboutJackType2";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<ScriptingExpressionType> expression = parseAnyData(NOTIFICATION_ABOUT_JACK_TYPE2_FILE);
prepareNotifications();
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
TestUtil.assertSuccess(result);
assertOutputData(output, 1, OperationResultStatus.SUCCESS);
assertEquals("Produced 1 event(s)\n", output.getConsoleOutput());
display("Dummy transport", dummyTransport);
checkDummyTransportMessages("Custom", 1);
Message m = dummyTransport.getMessages("dummy:Custom").get(0);
assertEquals("Wrong message body", "1", m.getBody());
assertEquals("Wrong message subject", "Ad hoc notification 2", m.getSubject());
checkDummyTransportMessages("CustomType2", 1);
m = dummyTransport.getMessages("dummy:CustomType2").get(0);
assertEquals("Wrong message body", "POV:user:c0c010c0-d34d-b33f-f00d-111111111111(jack)", m.getBody());
assertEquals("Wrong message subject", "Failure notification of type 2", m.getSubject());
}
Aggregations