예제 #1
0
  @Test
  public void test380DisableJackInBackgroundSimple() throws Exception {
    final String TEST_NAME = "test380DisableJackInBackgroundSimple";
    TestUtil.displayTestTile(this, TEST_NAME);

    // GIVEN
    OperationResult result = new OperationResult(DOT_CLASS + TEST_NAME);

    // WHEN
    Task task = taskManager.createTaskInstance();
    task.setOwner(getUser(USER_ADMINISTRATOR_OID));
    scriptingExpressionEvaluator.evaluateExpressionInBackground(
        UserType.COMPLEX_TYPE,
        ObjectQueryUtil.createOrigNameQuery("jack", prismContext).getFilter(),
        "disable",
        task,
        result);

    waitForTaskFinish(task.getOid(), false);
    task.refresh(result);

    // THEN
    IntegrationTestTools.display(task.getResult());
    TestUtil.assertSuccess(task.getResult());
    PrismObject<UserType> jack = getUser(USER_JACK_OID);
    IntegrationTestTools.display("jack after disable script", jack);
    assertAdministrativeStatusDisabled(jack);
  }
예제 #2
0
 public PrismObject<NodeType> getNodeById(String nodeIdentifier, OperationResult result)
     throws ObjectNotFoundException {
   try {
     //            QueryType q = QueryUtil.createNameQuery(nodeIdentifier);        // TODO change
     // to query-by-node-id
     ObjectQuery q =
         ObjectQueryUtil.createNameQuery(
             NodeType.class, taskManager.getPrismContext(), nodeIdentifier);
     List<PrismObject<NodeType>> nodes =
         taskManager.getRepositoryService().searchObjects(NodeType.class, q, null, result);
     if (nodes.isEmpty()) {
       //                result.recordFatalError("A node with identifier " + nodeIdentifier + "
       // does not exist.");
       throw new ObjectNotFoundException(
           "A node with identifier " + nodeIdentifier + " does not exist.");
     } else if (nodes.size() > 1) {
       throw new SystemException(
           "Multiple nodes with the same identifier '" + nodeIdentifier + "' in the repository.");
     } else {
       return nodes.get(0);
     }
   } catch (SchemaException e) { // should not occur
     throw new SystemException("Cannot get the list of nodes from the repository", e);
   }
 }