Search in sources :

Example 21 with ExecutionContext

use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.

the class TestScriptingBasic method test350RecomputeJack.

@Test
public void test350RecomputeJack() throws Exception {
    final String TEST_NAME = "test350RecomputeJack";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(DOT_CLASS + TEST_NAME);
    OperationResult result = task.getResult();
    PrismProperty<ScriptingExpressionType> expression = parseAnyData(RECOMPUTE_JACK_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("Recomputed user:c0c010c0-d34d-b33f-f00d-111111111111(jack)\n", output.getConsoleOutput());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExecutionContext(com.evolveum.midpoint.model.impl.scripting.ExecutionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 22 with ExecutionContext

use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.

the class TestScriptingBasic method test420NotificationAboutJack.

@Test
public void test420NotificationAboutJack() throws Exception {
    final String TEST_NAME = "test420NotificationAboutJack";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(DOT_CLASS + TEST_NAME);
    OperationResult result = task.getResult();
    PrismProperty<ScriptingExpressionType> expression = parseAnyData(NOTIFICATION_ABOUT_JACK_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", "jack/" + USER_JACK_OID, m.getBody());
    assertEquals("Wrong message subject", "Ad hoc notification", m.getSubject());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExecutionContext(com.evolveum.midpoint.model.impl.scripting.ExecutionContext) Message(com.evolveum.midpoint.notifications.api.transports.Message) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 23 with ExecutionContext

use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.

the class TestScriptingBasic method test210SearchForShadows.

@Test
public void test210SearchForShadows() throws Exception {
    final String TEST_NAME = "test210SearchForShadows";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(DOT_CLASS + TEST_NAME);
    OperationResult result = task.getResult();
    PrismProperty<SearchExpressionType> expression = parseAnyData(SEARCH_FOR_SHADOWS_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());
    assertAttributesFetched(output.getFinalOutput().getData());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExecutionContext(com.evolveum.midpoint.model.impl.scripting.ExecutionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 24 with ExecutionContext

use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.

the class TestScriptingBasic method test330ModifyJack.

@Test
public void test330ModifyJack() throws Exception {
    final String TEST_NAME = "test330ModifyJack";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(DOT_CLASS + TEST_NAME);
    OperationResult result = task.getResult();
    PrismProperty<ScriptingExpressionType> expression = parseAnyData(MODIFY_JACK_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("Nowhere", searchObjectByName(UserType.class, "jack").asObjectable().getLocality().getOrig());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExecutionContext(com.evolveum.midpoint.model.impl.scripting.ExecutionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 25 with ExecutionContext

use of com.evolveum.midpoint.model.impl.scripting.ExecutionContext in project midpoint by Evolveum.

the class TestScriptingBasic method test360AssignToJack.

@Test
public void test360AssignToJack() throws Exception {
    final String TEST_NAME = "test360AssignToJack";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = createTask(DOT_CLASS + TEST_NAME);
    OperationResult result = task.getResult();
    PrismProperty<ScriptingExpressionType> expression = parseAnyData(ASSIGN_TO_JACK_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("Recomputed user:c0c010c0-d34d-b33f-f00d-111111111111(jack)\n", output.getConsoleOutput());
    PrismObject<UserType> jack = getUser(USER_JACK_OID);
    display("jack after assignments creation", jack);
    assertAssignedAccount(jack, "10000000-0000-0000-0000-000000000104");
    assertAssignedRole(jack, "12345678-d34d-b33f-f00d-55555555cccc");
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExecutionContext(com.evolveum.midpoint.model.impl.scripting.ExecutionContext) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Aggregations

ExecutionContext (com.evolveum.midpoint.model.impl.scripting.ExecutionContext)31 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)29 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)28 Task (com.evolveum.midpoint.task.api.Task)28 Test (org.testng.annotations.Test)28 PipelineItem (com.evolveum.midpoint.model.api.PipelineItem)6 PipelineData (com.evolveum.midpoint.model.impl.scripting.PipelineData)6 Message (com.evolveum.midpoint.notifications.api.transports.Message)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 HashSet (java.util.HashSet)2 ScriptExecutionException (com.evolveum.midpoint.model.api.ScriptExecutionException)1 ExpressionHelper (com.evolveum.midpoint.model.impl.scripting.helpers.ExpressionHelper)1 OperationsHelper (com.evolveum.midpoint.model.impl.scripting.helpers.OperationsHelper)1 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)1 QueryConvertor (com.evolveum.midpoint.prism.marshaller.QueryConvertor)1 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 QueryJaxbConvertor (com.evolveum.midpoint.prism.query.QueryJaxbConvertor)1 GetOperationOptions (com.evolveum.midpoint.schema.GetOperationOptions)1 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)1