Exemplo n.º 1
0
  @Test
  public void test410TestResource() throws Exception {
    final String TEST_NAME = "test410TestResource";
    TestUtil.displayTestTile(this, TEST_NAME);

    // GIVEN
    OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME);
    PrismProperty<ScriptingExpressionType> expression = parseAnyData(TEST_DUMMY_RESOURCE_FILE);

    // WHEN
    ExecutionContext output =
        scriptingExpressionEvaluator.evaluateExpression(
            expression.getAnyValue().getValue(), result);

    // THEN
    IntegrationTestTools.display("output", output.getFinalOutput());
    IntegrationTestTools.display("stdout", output.getConsoleOutput());
    ResourceType dummy =
        modelService
            .getObject(
                ResourceType.class,
                RESOURCE_DUMMY_OID,
                null,
                taskManager.createTaskInstance(),
                result)
            .asObjectable();
    IntegrationTestTools.display("dummy resource after test connection", dummy.asPrismObject());
    IntegrationTestTools.display(result);
    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());
  }
Exemplo n.º 2
0
  @Test
  public void test420NotificationAboutJack() throws Exception {
    final String TEST_NAME = "test420NotificationAboutJack";
    TestUtil.displayTestTile(this, TEST_NAME);

    // GIVEN
    OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME);
    PrismProperty<ScriptingExpressionType> expression = parseAnyData(NOTIFICATION_ABOUT_JACK_FILE);
    prepareNotifications();

    // WHEN
    ExecutionContext output =
        scriptingExpressionEvaluator.evaluateExpression(
            expression.getAnyValue().getValue(), result);

    // THEN
    IntegrationTestTools.display("output", output.getFinalOutput());
    IntegrationTestTools.display("stdout", output.getConsoleOutput());
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertEquals(0, output.getFinalOutput().getData().size());
    assertEquals("Produced 1 event(s)\n", output.getConsoleOutput());

    IntegrationTestTools.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());
  }
Exemplo n.º 3
0
  @Test
  public void test340ModifyJackBack() throws Exception {
    final String TEST_NAME = "test340ModifyJackBack";
    TestUtil.displayTestTile(this, TEST_NAME);

    // GIVEN
    OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME);
    PrismProperty<ScriptingExpressionType> expression = parseAnyData(MODIFY_JACK_BACK_FILE);

    // WHEN
    ExecutionContext output =
        scriptingExpressionEvaluator.evaluateExpression(
            expression.getAnyValue().getValue(), result);

    // THEN
    assertNoOutputData(output);
    IntegrationTestTools.display("stdout", output.getConsoleOutput());
    IntegrationTestTools.display(result);
    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());
  }
Exemplo n.º 4
0
  @Test
  public void test360AssignToJack() throws Exception {
    final String TEST_NAME = "test360AssignToJack";
    TestUtil.displayTestTile(this, TEST_NAME);

    // GIVEN
    OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME);
    PrismProperty<ScriptingExpressionType> expression = parseAnyData(ASSIGN_TO_JACK_FILE);

    // WHEN
    ExecutionContext output =
        scriptingExpressionEvaluator.evaluateExpression(
            expression.getAnyValue().getValue(), result);

    // THEN
    assertNoOutputData(output);
    IntegrationTestTools.display("stdout", output.getConsoleOutput());
    IntegrationTestTools.display(result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    // assertEquals("Recomputed user:c0c010c0-d34d-b33f-f00d-111111111111(jack)\n",
    // output.getConsoleOutput());
    PrismObject<UserType> jack = getUser(USER_JACK_OID);
    IntegrationTestTools.display("jack after assignments creation", jack);
    assertAssignedAccount(jack, "10000000-0000-0000-0000-000000000104");
    assertAssignedRole(jack, "12345678-d34d-b33f-f00d-55555555cccc");
  }
Exemplo n.º 5
0
  @Test
  public void test400PurgeSchema() throws Exception {
    final String TEST_NAME = "test400PurgeSchema";
    TestUtil.displayTestTile(this, TEST_NAME);

    // GIVEN
    OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME);
    Task task = taskManager.createTaskInstance();
    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(), result);

    // THEN
    IntegrationTestTools.display("output", output.getFinalOutput());
    IntegrationTestTools.display("stdout", output.getConsoleOutput());
    IntegrationTestTools.display(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());
  }
Exemplo n.º 6
0
  @Test
  public void test350RecomputeJack() throws Exception {
    final String TEST_NAME = "test350RecomputeJack";
    TestUtil.displayTestTile(this, TEST_NAME);

    // GIVEN
    OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME);
    PrismProperty<ScriptingExpressionType> expression = parseAnyData(RECOMPUTE_JACK_FILE);

    // WHEN
    ExecutionContext output =
        scriptingExpressionEvaluator.evaluateExpression(
            expression.getAnyValue().getValue(), result);

    // THEN
    assertNoOutputData(output);
    IntegrationTestTools.display("stdout", output.getConsoleOutput());
    IntegrationTestTools.display(result);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertEquals(
        "Recomputed user:c0c010c0-d34d-b33f-f00d-111111111111(jack)\n", output.getConsoleOutput());
  }
Exemplo n.º 7
0
  @Test
  public void test320DeleteAndAddJack() throws Exception {
    final String TEST_NAME = "test320DeleteAndAddJack";
    TestUtil.displayTestTile(this, TEST_NAME);

    // GIVEN
    OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME);
    PrismProperty<ScriptingExpressionType> expression = parseAnyData(DELETE_AND_ADD_JACK_FILE);

    // WHEN
    ExecutionContext output =
        scriptingExpressionEvaluator.evaluateExpression(
            expression.getAnyValue().getValue(), result);

    // THEN
    assertNoOutputData(output);
    IntegrationTestTools.display("stdout", output.getConsoleOutput());
    result.computeStatus();
    TestUtil.assertSuccess(result);
    assertEquals(
        "Deleted user:c0c010c0-d34d-b33f-f00d-111111111111(jack)\nAdded user:c0c010c0-d34d-b33f-f00d-111111111111(jack)\n",
        output.getConsoleOutput());
    assertAdministrativeStatusEnabled(searchObjectByName(UserType.class, "jack"));
  }
Exemplo n.º 8
0
  @Test
  public void test500ScriptingUsers() throws Exception {
    final String TEST_NAME = "test500ScriptingUsers";
    TestUtil.displayTestTile(this, TEST_NAME);

    // GIVEN
    OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME);
    PrismProperty<ScriptingExpressionType> expression = parseAnyData(SCRIPTING_USERS_FILE);

    // WHEN
    ExecutionContext output =
        scriptingExpressionEvaluator.evaluateExpression(
            expression.getAnyValue().getValue(), result);

    // THEN
    TestUtil.assertSuccess(result);
    Data data = output.getFinalOutput();
    assertEquals("Unexpected # of items in output", 5, data.getData().size());
    Set<String> realOids = new HashSet<>();
    for (PrismValue value : data.getData()) {
      PrismObject<UserType> user = ((PrismObjectValue<UserType>) value).asPrismObject();
      assertEquals("Description not set", "Test", user.asObjectable().getDescription());
      realOids.add(user.getOid());
    }
    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);
    IntegrationTestTools.display("stdout", output.getConsoleOutput());
    IntegrationTestTools.display(result);
    result.computeStatus();
  }