Search in sources :

Example 16 with ExecutionContext

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

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PipelineData(com.evolveum.midpoint.model.impl.scripting.PipelineData) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ExecutionContext(com.evolveum.midpoint.model.impl.scripting.ExecutionContext) PipelineItem(com.evolveum.midpoint.model.api.PipelineItem) HashSet(java.util.HashSet) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 18 with ExecutionContext

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());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExecutionContext(com.evolveum.midpoint.model.impl.scripting.ExecutionContext) PipelineItem(com.evolveum.midpoint.model.api.PipelineItem) PipelineData(com.evolveum.midpoint.model.impl.scripting.PipelineData) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 19 with ExecutionContext

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExecutionContext(com.evolveum.midpoint.model.impl.scripting.ExecutionContext) PipelineItem(com.evolveum.midpoint.model.api.PipelineItem) PipelineData(com.evolveum.midpoint.model.impl.scripting.PipelineData) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractInitializedModelIntegrationTest(com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)

Example 20 with ExecutionContext

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