Search in sources :

Example 31 with LDIFModifyDNChangeRecord

use of com.unboundid.ldif.LDIFModifyDNChangeRecord in project ldapsdk by pingidentity.

the class ExcludeChangeTypeTransformationTestCase method testExcludeNullSet.

/**
 * Tests the behavior when the set of change types to exclude is
 * {@code null}}.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExcludeNullSet() throws Exception {
    final ExcludeChangeTypeTransformation t = new ExcludeChangeTypeTransformation((ChangeType[]) null);
    final LDIFAddChangeRecord addChangeRecord = new LDIFAddChangeRecord(new Entry("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example"));
    assertNotNull(t.transformChangeRecord(addChangeRecord));
    assertEquals(t.transformChangeRecord(addChangeRecord), addChangeRecord);
    assertNotNull(t.translate(addChangeRecord, 0));
    assertEquals(t.translate(addChangeRecord, 0), addChangeRecord);
    assertNotNull(t.translateChangeRecordToWrite(addChangeRecord));
    assertEquals(t.translateChangeRecordToWrite(addChangeRecord), addChangeRecord);
    final LDIFDeleteChangeRecord deleteChangeRecord = new LDIFDeleteChangeRecord("dc=example,dc=com");
    assertNotNull(t.transformChangeRecord(deleteChangeRecord));
    assertEquals(t.transformChangeRecord(deleteChangeRecord), deleteChangeRecord);
    assertNotNull(t.translate(deleteChangeRecord, 0));
    assertEquals(t.translate(deleteChangeRecord, 0), deleteChangeRecord);
    assertNotNull(t.translateChangeRecordToWrite(deleteChangeRecord));
    assertEquals(t.translateChangeRecordToWrite(deleteChangeRecord), deleteChangeRecord);
    final LDIFModifyChangeRecord modifyChangeRecord = new LDIFModifyChangeRecord(new ModifyRequest("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: foo"));
    assertNotNull(t.transformChangeRecord(modifyChangeRecord));
    assertEquals(t.transformChangeRecord(modifyChangeRecord), modifyChangeRecord);
    assertNotNull(t.translate(modifyChangeRecord, 0));
    assertEquals(t.translate(modifyChangeRecord, 0), modifyChangeRecord);
    assertNotNull(t.translateChangeRecordToWrite(modifyChangeRecord));
    assertEquals(t.translateChangeRecordToWrite(modifyChangeRecord), modifyChangeRecord);
    final LDIFModifyDNChangeRecord modifyDNChangeRecord = new LDIFModifyDNChangeRecord("ou=People,dc=example,dc=com", "ou=Users", true, null);
    assertNotNull(t.transformChangeRecord(modifyDNChangeRecord));
    assertEquals(t.transformChangeRecord(modifyDNChangeRecord), modifyDNChangeRecord);
    assertNotNull(t.translate(modifyDNChangeRecord, 0));
    assertEquals(t.translate(modifyDNChangeRecord, 0), modifyDNChangeRecord);
    assertNotNull(t.translateChangeRecordToWrite(modifyDNChangeRecord));
    assertEquals(t.translateChangeRecordToWrite(modifyDNChangeRecord), modifyDNChangeRecord);
}
Also used : Entry(com.unboundid.ldap.sdk.Entry) ChangeType(com.unboundid.ldap.sdk.ChangeType) LDIFAddChangeRecord(com.unboundid.ldif.LDIFAddChangeRecord) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord) LDIFModifyDNChangeRecord(com.unboundid.ldif.LDIFModifyDNChangeRecord) Test(org.testng.annotations.Test)

Example 32 with LDIFModifyDNChangeRecord

use of com.unboundid.ldif.LDIFModifyDNChangeRecord in project ldapsdk by pingidentity.

the class MoveSubtreeTransformationTestCase method testTransformModifyDNChangeRecord.

/**
 * Provides general test coverage for the transformChangeRecord method for
 * modify DN change records.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testTransformModifyDNChangeRecord() throws Exception {
    final MoveSubtreeTransformation t = new MoveSubtreeTransformation(new DN("o=example.com"), new DN("dc=example,dc=com"));
    final LDIFChangeRecord r = t.transformChangeRecord(new LDIFModifyDNChangeRecord("uid=test.user,ou=Users,o=example.com", "cn=Test User", false, "ou=People,o=example.com"));
    assertNotNull(r);
    assertEquals(r, new LDIFModifyDNChangeRecord("uid=test.user,ou=Users,dc=example,dc=com", "cn=Test User", false, "ou=People,dc=example,dc=com"));
}
Also used : LDIFChangeRecord(com.unboundid.ldif.LDIFChangeRecord) DN(com.unboundid.ldap.sdk.DN) LDIFModifyDNChangeRecord(com.unboundid.ldif.LDIFModifyDNChangeRecord) Test(org.testng.annotations.Test)

Example 33 with LDIFModifyDNChangeRecord

use of com.unboundid.ldif.LDIFModifyDNChangeRecord in project ldapsdk by pingidentity.

the class ExcludeAttributeTransformationTestCase method testExcludeForModifyDNChangeRecord.

/**
 * Tests the behavior for LDIF modify DN change records.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExcludeForModifyDNChangeRecord() throws Exception {
    final ExcludeAttributeTransformation t = new ExcludeAttributeTransformation(Schema.getDefaultStandardSchema(), "description", "displayName");
    final LDIFChangeRecord r = t.transformChangeRecord(new LDIFModifyDNChangeRecord("ou=People,dc=example,dc=com", "ou=users", true, "o=example.com"));
    assertNotNull(r);
    assertEquals(r, new LDIFModifyDNChangeRecord("ou=People,dc=example,dc=com", "ou=users", true, "o=example.com"));
}
Also used : LDIFChangeRecord(com.unboundid.ldif.LDIFChangeRecord) LDIFModifyDNChangeRecord(com.unboundid.ldif.LDIFModifyDNChangeRecord) Test(org.testng.annotations.Test)

Example 34 with LDIFModifyDNChangeRecord

use of com.unboundid.ldif.LDIFModifyDNChangeRecord in project ldapsdk by pingidentity.

the class ExcludeChangeTypeTransformationTestCase method testExcludeEmptySet.

/**
 * Tests the behavior when the set of change types to exclude is empty.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExcludeEmptySet() throws Exception {
    final ExcludeChangeTypeTransformation t = new ExcludeChangeTypeTransformation();
    final LDIFAddChangeRecord addChangeRecord = new LDIFAddChangeRecord(new Entry("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example"));
    assertNotNull(t.transformChangeRecord(addChangeRecord));
    assertEquals(t.transformChangeRecord(addChangeRecord), addChangeRecord);
    assertNotNull(t.translate(addChangeRecord, 0));
    assertEquals(t.translate(addChangeRecord, 0), addChangeRecord);
    assertNotNull(t.translateChangeRecordToWrite(addChangeRecord));
    assertEquals(t.translateChangeRecordToWrite(addChangeRecord), addChangeRecord);
    final LDIFDeleteChangeRecord deleteChangeRecord = new LDIFDeleteChangeRecord("dc=example,dc=com");
    assertNotNull(t.transformChangeRecord(deleteChangeRecord));
    assertEquals(t.transformChangeRecord(deleteChangeRecord), deleteChangeRecord);
    assertNotNull(t.translate(deleteChangeRecord, 0));
    assertEquals(t.translate(deleteChangeRecord, 0), deleteChangeRecord);
    assertNotNull(t.translateChangeRecordToWrite(deleteChangeRecord));
    assertEquals(t.translateChangeRecordToWrite(deleteChangeRecord), deleteChangeRecord);
    final LDIFModifyChangeRecord modifyChangeRecord = new LDIFModifyChangeRecord(new ModifyRequest("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: foo"));
    assertNotNull(t.transformChangeRecord(modifyChangeRecord));
    assertEquals(t.transformChangeRecord(modifyChangeRecord), modifyChangeRecord);
    assertNotNull(t.translate(modifyChangeRecord, 0));
    assertEquals(t.translate(modifyChangeRecord, 0), modifyChangeRecord);
    assertNotNull(t.translateChangeRecordToWrite(modifyChangeRecord));
    assertEquals(t.translateChangeRecordToWrite(modifyChangeRecord), modifyChangeRecord);
    final LDIFModifyDNChangeRecord modifyDNChangeRecord = new LDIFModifyDNChangeRecord("ou=People,dc=example,dc=com", "ou=Users", true, null);
    assertNotNull(t.transformChangeRecord(modifyDNChangeRecord));
    assertEquals(t.transformChangeRecord(modifyDNChangeRecord), modifyDNChangeRecord);
    assertNotNull(t.translate(modifyDNChangeRecord, 0));
    assertEquals(t.translate(modifyDNChangeRecord, 0), modifyDNChangeRecord);
    assertNotNull(t.translateChangeRecordToWrite(modifyDNChangeRecord));
    assertEquals(t.translateChangeRecordToWrite(modifyDNChangeRecord), modifyDNChangeRecord);
}
Also used : Entry(com.unboundid.ldap.sdk.Entry) LDIFAddChangeRecord(com.unboundid.ldif.LDIFAddChangeRecord) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord) LDIFModifyDNChangeRecord(com.unboundid.ldif.LDIFModifyDNChangeRecord) Test(org.testng.annotations.Test)

Example 35 with LDIFModifyDNChangeRecord

use of com.unboundid.ldif.LDIFModifyDNChangeRecord in project ldapsdk by pingidentity.

the class ExcludeChangeTypeTransformationTestCase method testExcludeAllChangeTypes.

/**
 * Tests the behavior when the set of change types to exclude contains all of
 * the change types.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExcludeAllChangeTypes() throws Exception {
    final ExcludeChangeTypeTransformation t = new ExcludeChangeTypeTransformation(ChangeType.ADD, ChangeType.DELETE, ChangeType.MODIFY, ChangeType.MODIFY_DN);
    final LDIFAddChangeRecord addChangeRecord = new LDIFAddChangeRecord(new Entry("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example"));
    assertNull(t.transformChangeRecord(addChangeRecord));
    assertNull(t.translate(addChangeRecord, 0));
    assertNull(t.translateChangeRecordToWrite(addChangeRecord));
    final LDIFDeleteChangeRecord deleteChangeRecord = new LDIFDeleteChangeRecord("dc=example,dc=com");
    assertNull(t.transformChangeRecord(deleteChangeRecord));
    assertNull(t.translate(deleteChangeRecord, 0));
    assertNull(t.translateChangeRecordToWrite(deleteChangeRecord));
    final LDIFModifyChangeRecord modifyChangeRecord = new LDIFModifyChangeRecord(new ModifyRequest("dn: dc=example,dc=com", "changetype: modify", "replace: description", "description: foo"));
    assertNull(t.transformChangeRecord(modifyChangeRecord));
    assertNull(t.translate(modifyChangeRecord, 0));
    assertNull(t.translateChangeRecordToWrite(modifyChangeRecord));
    final LDIFModifyDNChangeRecord modifyDNChangeRecord = new LDIFModifyDNChangeRecord("ou=People,dc=example,dc=com", "ou=Users", true, null);
    assertNull(t.transformChangeRecord(modifyDNChangeRecord));
    assertNull(t.translate(modifyDNChangeRecord, 0));
    assertNull(t.translateChangeRecordToWrite(modifyDNChangeRecord));
}
Also used : Entry(com.unboundid.ldap.sdk.Entry) LDIFAddChangeRecord(com.unboundid.ldif.LDIFAddChangeRecord) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord) LDIFModifyDNChangeRecord(com.unboundid.ldif.LDIFModifyDNChangeRecord) Test(org.testng.annotations.Test)

Aggregations

LDIFModifyDNChangeRecord (com.unboundid.ldif.LDIFModifyDNChangeRecord)45 Test (org.testng.annotations.Test)35 LDIFModifyChangeRecord (com.unboundid.ldif.LDIFModifyChangeRecord)20 LDIFChangeRecord (com.unboundid.ldif.LDIFChangeRecord)19 LDIFAddChangeRecord (com.unboundid.ldif.LDIFAddChangeRecord)17 LDIFDeleteChangeRecord (com.unboundid.ldif.LDIFDeleteChangeRecord)17 Calendar (java.util.Calendar)13 GregorianCalendar (java.util.GregorianCalendar)13 Entry (com.unboundid.ldap.sdk.Entry)10 Modification (com.unboundid.ldap.sdk.Modification)8 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)8 DN (com.unboundid.ldap.sdk.DN)7 LDAPException (com.unboundid.ldap.sdk.LDAPException)5 Schema (com.unboundid.ldap.sdk.schema.Schema)5 LDIFReader (com.unboundid.ldif.LDIFReader)4 Nullable (com.unboundid.util.Nullable)4 File (java.io.File)4 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)3 Attribute (com.unboundid.ldap.sdk.Attribute)3 RDN (com.unboundid.ldap.sdk.RDN)3