@Test
  public void testSearch() throws UcfException, SchemaException, CommunicationException {
    TestUtil.displayTestTile("testSearch");
    // GIVEN

    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
    // Determine object class from the schema

    ResultHandler<ShadowType> handler =
        new ResultHandler<ShadowType>() {

          @Override
          public boolean handle(PrismObject<ShadowType> object) {
            System.out.println("Search: found: " + object);
            return true;
          }
        };

    OperationResult result = new OperationResult(this.getClass().getName() + ".testSearch");

    // WHEN
    cc.search(accountDefinition, new ObjectQuery(), handler, null, result);

    // THEN

  }
  // This obviously does not work with LDAP connector
  @Test(enabled = false)
  public void testDisableAccount() throws Exception {
    TestUtil.displayTestTile(this, "testDisableAccount");

    // GIVEN
    OperationResult result = new OperationResult(this.getClass().getName() + ".testDisableAccount");

    Collection<ResourceAttribute<?>> identifiers =
        addSampleResourceObject("blackbeard", "Edward", "Teach");

    // Check precondition
    String entryUuid = getEntryUuid(identifiers);
    SearchResultEntry ldapEntryBefore = openDJController.searchAndAssertByEntryUuid(entryUuid);
    assertTrue("The account is not enabled", openDJController.isAccountEnabled(ldapEntryBefore));

    // WHEN

    Set<Operation> changes = new HashSet<Operation>();
    changes.add(createActivationChange(ActivationStatusType.DISABLED));

    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);

    cc.modifyObject(accountDefinition, identifiers, changes, result);

    // THEN

    SearchResultEntry ldapEntryAfter = openDJController.searchAndAssertByEntryUuid(entryUuid);
    assertFalse("The account was not disabled", openDJController.isAccountEnabled(ldapEntryAfter));
  }
  @Test
  public void testAddDeleteObject() throws Exception {
    TestUtil.displayTestTile(this, "testDeleteObject");

    OperationResult result = new OperationResult(this.getClass().getName() + ".testDelete");

    Collection<ResourceAttribute<?>> identifiers = addSampleResourceObject("john", "John", "Smith");

    String uid = null;
    for (ResourceAttribute<?> resourceAttribute : identifiers) {
      if (ConnectorFactoryIcfImpl.ICFS_UID.equals(resourceAttribute.getElementName())) {
        uid = resourceAttribute.getValue(String.class).getValue();
        System.out.println("uuuuid:" + uid);
        assertNotNull(uid);
      }
    }

    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);

    cc.deleteObject(accountDefinition, null, identifiers, result);

    PrismObject<ShadowType> resObj = null;
    try {
      resObj = cc.fetchObject(ShadowType.class, accountDefinition, identifiers, null, result);
      Assert.fail();
    } catch (ObjectNotFoundException ex) {
      AssertJUnit.assertNull(resObj);
    }
  }
  @Test
  public void testChangeModifyObject() throws Exception {
    TestUtil.displayTestTile(this, "testChangeModifyObject");

    OperationResult result = new OperationResult(this.getClass().getName() + ".testModify");

    Collection<ResourceAttribute<?>> identifiers = addSampleResourceObject("john", "John", "Smith");

    Set<Operation> changes = new HashSet<Operation>();

    changes.add(createAddAttributeChange("employeeNumber", "123123123"));
    changes.add(createReplaceAttributeChange("sn", "Smith007"));
    changes.add(createAddAttributeChange("street", "Wall Street"));
    changes.add(createDeleteAttributeChange("givenName", "John"));

    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);

    cc.modifyObject(accountDefinition, identifiers, changes, result);

    PrismObject<ShadowType> shadow =
        cc.fetchObject(ShadowType.class, accountDefinition, identifiers, null, result);
    ResourceAttributeContainer resObj = ShadowUtil.getAttributesContainer(shadow);

    AssertJUnit.assertNull(
        resObj.findAttribute(
            new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "givenName")));

    String addedEmployeeNumber =
        resObj
            .findAttribute(
                new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "employeeNumber"))
            .getValue(String.class)
            .getValue();
    String changedSn =
        resObj
            .findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "sn"))
            .getValues(String.class)
            .iterator()
            .next()
            .getValue();
    String addedStreet =
        resObj
            .findAttribute(new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "street"))
            .getValues(String.class)
            .iterator()
            .next()
            .getValue();

    System.out.println("changed employee number: " + addedEmployeeNumber);
    System.out.println("changed sn: " + changedSn);
    System.out.println("added street: " + addedStreet);

    AssertJUnit.assertEquals("123123123", addedEmployeeNumber);
    AssertJUnit.assertEquals("Smith007", changedSn);
    AssertJUnit.assertEquals("Wall Street", addedStreet);
  }
  @Test
  public void testFetchChanges() throws Exception {
    TestUtil.displayTestTile(this, "testFetchChanges");

    OperationResult result = new OperationResult(this.getClass().getName() + ".testFetchChanges");
    ObjectClassComplexTypeDefinition accountDefinition =
        resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
    PrismProperty lastToken = cc.fetchCurrentToken(accountDefinition, result);

    System.out.println("Property:");
    System.out.println(SchemaDebugUtil.prettyPrint(lastToken));

    System.out.println("token " + lastToken.toString());
    List<Change<ShadowType>> changes = cc.fetchChanges(accountDefinition, lastToken, null, result);
    AssertJUnit.assertEquals(0, changes.size());
  }