Search in sources :

Example 11 with ExecutionContext

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());
}
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 12 with ExecutionContext

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"));
}
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 13 with ExecutionContext

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());
}
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 14 with ExecutionContext

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());
}
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 15 with ExecutionContext

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());
}
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)

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