Search in sources :

Example 46 with LDIFDeleteChangeRecord

use of com.unboundid.ldif.LDIFDeleteChangeRecord 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 47 with LDIFDeleteChangeRecord

use of com.unboundid.ldif.LDIFDeleteChangeRecord 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)

Example 48 with LDIFDeleteChangeRecord

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

the class ExcludeChangeTypeTransformationTestCase method testExcludeAddChangeType.

/**
 * Tests the behavior when the set of change types to exclude contains only
 * the add change type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExcludeAddChangeType() throws Exception {
    final ExcludeChangeTypeTransformation t = new ExcludeChangeTypeTransformation(ChangeType.ADD);
    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");
    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 49 with LDIFDeleteChangeRecord

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

the class ExcludeChangeTypeTransformationTestCase method testExcludeModifyChangeType.

/**
 * Tests the behavior when the set of change types to exclude contains only
 * the modify change type.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExcludeModifyChangeType() throws Exception {
    final ExcludeChangeTypeTransformation t = new ExcludeChangeTypeTransformation(ChangeType.MODIFY);
    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"));
    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);
    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 50 with LDIFDeleteChangeRecord

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

the class RedactAttributeTransformationTestCase method testTransformDeleteChangeRecordProcessDNsTruePreserveCountTrue.

/**
 * Provides test coverage for the transformChangeRecord method for a delete
 * record with both processDNs and preserveValueCount arguments set to true.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testTransformDeleteChangeRecordProcessDNsTruePreserveCountTrue() throws Exception {
    final Schema schema = Schema.getDefaultStandardSchema();
    final RedactAttributeTransformation t = new RedactAttributeTransformation(schema, true, true, "description", "displayName", "cn", "ou");
    final LDIFChangeRecord r = t.transformChangeRecord(new LDIFDeleteChangeRecord("cn=Test,ou=People,dc=example,dc=com"));
    assertNotNull(r);
    assertEquals(r, new LDIFDeleteChangeRecord("cn=***REDACTED***,ou=***REDACTED***,dc=example,dc=com"));
}
Also used : LDIFChangeRecord(com.unboundid.ldif.LDIFChangeRecord) Schema(com.unboundid.ldap.sdk.schema.Schema) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord) Test(org.testng.annotations.Test)

Aggregations

LDIFDeleteChangeRecord (com.unboundid.ldif.LDIFDeleteChangeRecord)67 Test (org.testng.annotations.Test)58 LDIFAddChangeRecord (com.unboundid.ldif.LDIFAddChangeRecord)29 LDIFChangeRecord (com.unboundid.ldif.LDIFChangeRecord)20 LDIFModifyChangeRecord (com.unboundid.ldif.LDIFModifyChangeRecord)18 LDIFModifyDNChangeRecord (com.unboundid.ldif.LDIFModifyDNChangeRecord)17 Calendar (java.util.Calendar)17 GregorianCalendar (java.util.GregorianCalendar)17 Entry (com.unboundid.ldap.sdk.Entry)10 Attribute (com.unboundid.ldap.sdk.Attribute)9 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)9 ReadOnlyEntry (com.unboundid.ldap.sdk.ReadOnlyEntry)9 DN (com.unboundid.ldap.sdk.DN)7 LDAPException (com.unboundid.ldap.sdk.LDAPException)6 File (java.io.File)5 Schema (com.unboundid.ldap.sdk.schema.Schema)4 Nullable (com.unboundid.util.Nullable)4 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)3 ChangeLogEntry (com.unboundid.ldap.sdk.ChangeLogEntry)3 Modification (com.unboundid.ldap.sdk.Modification)3