use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test400PurgeSchema.
@Test
public void test400PurgeSchema() throws Exception {
final String TEST_NAME = "test400PurgeSchema";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<ScriptingExpressionType> expression = parseAnyData(PURGE_DUMMY_BLACK_SCHEMA_FILE);
// ResourceType dummy = modelService.getObject(ResourceType.class, RESOURCE_DUMMY_BLACK_OID, null, task, result).asObjectable();
// IntegrationTestTools.display("dummy resource before purge schema", dummy.asPrismObject());
// IntegrationTestTools.display("elements: " + dummy.getSchema().getDefinition().getAny().get(0).getElementsByTagName("*").getLength());
// IntegrationTestTools.display("schema as XML: " + DOMUtil.printDom(dummy.getSchema().getDefinition().getAny().get(0)));
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
TestUtil.assertSuccess(result);
assertEquals(1, output.getFinalOutput().getData().size());
// dummy = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_BLACK_OID, null, result).asObjectable();
// IntegrationTestTools.display("dummy resource from repo", dummy.asPrismObject());
// IntegrationTestTools.display("elements: " + dummy.getSchema().getDefinition().getAny().get(0).getElementsByTagName("*").getLength());
// IntegrationTestTools.display("schema as XML: " + DOMUtil.printDom(dummy.getSchema().getDefinition().getAny().get(0)));
//AssertJUnit.assertNull("Schema is still present", dummy.getSchema());
// actually, schema gets downloaded just after purging it
assertEquals("Purged schema information from resource:10000000-0000-0000-0000-000000000305(Dummy Resource Black)\n", output.getConsoleOutput());
}
use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test215SearchForShadowsNoFetch.
@Test
public void test215SearchForShadowsNoFetch() throws Exception {
final String TEST_NAME = "test215SearchForShadowsNoFetch";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<SearchExpressionType> expression = parseAnyData(SEARCH_FOR_SHADOWS_NOFETCH_FILE);
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
TestUtil.assertSuccess(result);
assertEquals(5, output.getFinalOutput().getData().size());
assertAttributesNotFetched(output.getFinalOutput().getData());
}
use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test340ModifyJackBack.
@Test
public void test340ModifyJackBack() throws Exception {
final String TEST_NAME = "test340ModifyJackBack";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = createTask(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
PrismProperty<ScriptingExpressionType> expression = parseAnyData(MODIFY_JACK_BACK_FILE);
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(expression.getAnyValue().getValue(), task, result);
// THEN
dumpOutput(output, result);
assertOutputData(output, 1, OperationResultStatus.SUCCESS);
result.computeStatus();
TestUtil.assertSuccess(result);
assertEquals("Modified user:c0c010c0-d34d-b33f-f00d-111111111111(jack)\n", output.getConsoleOutput());
assertEquals("Caribbean", searchObjectByName(UserType.class, "jack").asObjectable().getLocality().getOrig());
}
use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class TestScriptingBasic method test112Echo.
@Test
public void test112Echo() throws Exception {
final String TEST_NAME = "test112Echo";
TestUtil.displayTestTile(this, TEST_NAME);
// GIVEN
Task task = taskManager.createTaskInstance(DOT_CLASS + TEST_NAME);
OperationResult result = task.getResult();
ExecuteScriptType executeScript = parseRealValue(ECHO_FILE);
// WHEN
ExecutionContext output = scriptingExpressionEvaluator.evaluateExpression(executeScript, task, result);
// THEN
dumpOutput(output, result);
result.computeStatus();
PipelineData data = output.getFinalOutput();
assertEquals("Unexpected # of items in output", 4, data.getData().size());
// TODO check correct serialization (MID-
}
use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.
the class ModelController method evaluateExpression.
@Override
public ScriptExecutionResult evaluateExpression(ExecuteScriptType scriptExecutionCommand, Task task, OperationResult result) throws ScriptExecutionException, SchemaException, SecurityViolationException {
checkScriptingAuthorization(result);
ExecutionContext executionContext = scriptingExpressionEvaluator.evaluateExpression(scriptExecutionCommand, task, result);
return executionContext.toExecutionResult();
}
Aggregations