Search in sources :

Example 11 with ChangeLogEntry

use of com.unboundid.ldap.sdk.ChangeLogEntry in project ldapsdk by pingidentity.

the class UnboundIDChangeLogEntryTestCase method testExtendedModifyChangeLogEntryWithExceededBeforeValues.

/**
 * Provides coverage for cases in which an UnboundID changelog entry is
 * created for a modify operation without an extended set of content that
 * includes attributes with exceeded before but non-exceeded after value
 * counts.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExtendedModifyChangeLogEntryWithExceededBeforeValues() throws Exception {
    final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(4L, new LDIFModifyChangeRecord("cn=Test,ou=Groups,dc=example,dc=com", new Modification(ModificationType.DELETE, "member", "uid=user.4,ou=People,dc=example,dc=com")));
    assertNotNull(e);
    // Construct after values for the member attribute.
    final StringBuilder afterBuffer = new StringBuilder();
    afterBuffer.append("member: uid=user.1,ou=People,dc=example,dc=com");
    afterBuffer.append(StaticUtils.EOL);
    afterBuffer.append("member: uid=user.2,ou=People,dc=example,dc=com");
    afterBuffer.append(StaticUtils.EOL);
    afterBuffer.append("member: uid=user.3,ou=People,dc=example,dc=com");
    afterBuffer.append(StaticUtils.EOL);
    // Construct a key attribute value for the "cn" attribute.
    final StringBuilder keyAttrBuffer = new StringBuilder();
    keyAttrBuffer.append("cn: Test");
    keyAttrBuffer.append(StaticUtils.EOL);
    final Entry extendedEntry = e.duplicate();
    extendedEntry.addAttribute("ds-changelog-after-values", afterBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-attr-exceeded-max-values-count", "attr=member,beforeCount=4,afterCount=3");
    extendedEntry.addAttribute("ds-changelog-entry-key-attr-values", keyAttrBuffer.toString());
    extendedEntry.addAttribute("targetUniqueID", "468c6887-4fcc-38ea-9425-abcaa3c88be6");
    extendedEntry.addAttribute("localCSN", "00000131EDEDD535000000000006");
    extendedEntry.addAttribute("changeTime", "20110821200012Z");
    extendedEntry.addAttribute("ds-changelog-target-attribute", "member");
    extendedEntry.addAttribute("ds-notification-destination-entry-uuid", "12345678-90ab-cdef-1234-567890abcdef", "23456789-0abC-def1-2345-67890abcdef1");
    extendedEntry.addAttribute("ds-changelog-notification-properties", "notification-property-1", "notification-property-2", "notification-property-3");
    final UnboundIDChangeLogEntry ue = new UnboundIDChangeLogEntry(extendedEntry);
    assertNotNull(ue);
    assertEquals(ue.getChangeNumber(), 4L);
    assertNotNull(ue.getTargetDN());
    assertEquals(new DN(ue.getTargetDN()), new DN("cn=Test,ou=Groups,dc=example,dc=com"));
    assertNotNull(ue.getChangeType());
    assertEquals(ue.getChangeType(), ChangeType.MODIFY);
    assertNull(ue.getAddAttributes());
    assertNull(ue.getDeletedEntryAttributes());
    assertNotNull(ue.getModifications());
    assertEquals(ue.getModifications().size(), 1);
    assertTrue(ue.getModifications().contains(new Modification(ModificationType.DELETE, "member", "uid=user.4,ou=People,dc=example,dc=com")));
    assertNull(ue.getNewRDN());
    assertFalse(ue.deleteOldRDN());
    assertNull(ue.getNewSuperior());
    assertNull(ue.getSoftDeleteToDN());
    assertNull(ue.getUndeleteFromDN());
    assertNull(ue.getChangeToSoftDeletedEntry());
    assertNotNull(ue.getNewDN());
    assertEquals(new DN(ue.getNewDN()), new DN("cn=Test,ou=Groups,dc=example,dc=com"));
    assertNotNull(ue.getUpdatedAttributesBeforeChange());
    assertTrue(ue.getUpdatedAttributesBeforeChange().isEmpty());
    assertNotNull(ue.getUpdatedAttributesAfterChange());
    assertEquals(ue.getUpdatedAttributesAfterChange().size(), 1);
    assertTrue(ue.getUpdatedAttributesAfterChange().contains(new Attribute("member", "uid=user.1,ou=People,dc=example,dc=com", "uid=user.2,ou=People,dc=example,dc=com", "uid=user.3,ou=People,dc=example,dc=com")));
    assertNotNull(ue.getAttributesThatExceededMaxValuesCount());
    assertEquals(ue.getAttributesThatExceededMaxValuesCount().size(), 1);
    assertTrue(ue.getAttributesThatExceededMaxValuesCount().contains(new ChangeLogEntryAttributeExceededMaxValuesCount("attr=member,beforeCount=4,afterCount=3")));
    assertNotNull(ue.getKeyEntryAttributes());
    assertEquals(ue.getKeyEntryAttributes().size(), 1);
    assertTrue(ue.getKeyEntryAttributes().contains(new Attribute("cn", "Test")));
    assertNull(ue.getAttributeBeforeChange("uid"));
    assertNotNull(ue.getAttributeBeforeChange("cn"));
    assertEquals(ue.getAttributeAfterChange("cn"), new Attribute("cn", "Test"));
    try {
        ue.getAttributeBeforeChange("member");
        fail("Expected an exception when trying to get member before values");
    } catch (final ChangeLogEntryAttributeExceededMaxValuesException ex) {
        // This was expected.
        assertNotNull(ex.getAttributeInfo());
        assertTrue(ex.getAttributeInfo().getAttributeName().equalsIgnoreCase("member"));
        assertEquals(ex.getAttributeInfo().getBeforeCount(), 4);
        assertEquals(ex.getAttributeInfo().getAfterCount(), 3);
    }
    assertNull(ue.getAttributeAfterChange("uid"));
    assertNotNull(ue.getAttributeAfterChange("cn"));
    assertEquals(ue.getAttributeAfterChange("cn"), new Attribute("cn", "Test"));
    assertNotNull(ue.getAttributeAfterChange("member"));
    assertEquals(ue.getAttributeAfterChange("member"), new Attribute("member", "uid=user.1,ou=People,dc=example,dc=com", "uid=user.2,ou=People,dc=example,dc=com", "uid=user.3,ou=People,dc=example,dc=com"));
    assertNotNull(ue.constructPartialEntryBeforeChange());
    assertEquals(ue.constructPartialEntryBeforeChange(), new Entry("dn: cn=Test,ou=Groups,dc=example,dc=com", "cn: Test"));
    assertNotNull(ue.constructPartialEntryAfterChange());
    assertEquals(ue.constructPartialEntryAfterChange(), new Entry("dn: cn=Test,ou=Groups,dc=example,dc=com", "cn: Test", "member: uid=user.1,ou=People,dc=example,dc=com", "member: uid=user.2,ou=People,dc=example,dc=com", "member: uid=user.3,ou=People,dc=example,dc=com"));
    assertNotNull(ue.getTargetUniqueID());
    assertEquals(ue.getTargetUniqueID(), "468c6887-4fcc-38ea-9425-abcaa3c88be6");
    assertNotNull(ue.getLocalCSN());
    assertEquals(ue.getLocalCSN(), "00000131EDEDD535000000000006");
    assertNotNull(ue.getChangeTime());
    assertEquals(ue.getChangeTime().getTime(), StaticUtils.decodeGeneralizedTime("20110821200012Z").getTime());
    assertNotNull(ue.getTargetAttributeNames());
    assertFalse(ue.getTargetAttributeNames().isEmpty());
    assertEquals(ue.getTargetAttributeNames().size(), 1);
    assertNotNull(ue.getNotificationDestinationEntryUUIDs());
    assertFalse(ue.getNotificationDestinationEntryUUIDs().isEmpty());
    assertEquals(ue.getNotificationDestinationEntryUUIDs().size(), 2);
    assertNotNull(ue.getNotificationProperties());
    assertFalse(ue.getNotificationProperties().isEmpty());
    assertEquals(ue.getNotificationProperties().size(), 3);
}
Also used : Modification(com.unboundid.ldap.sdk.Modification) Entry(com.unboundid.ldap.sdk.Entry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) Attribute(com.unboundid.ldap.sdk.Attribute) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) RDN(com.unboundid.ldap.sdk.RDN) DN(com.unboundid.ldap.sdk.DN) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) Test(org.testng.annotations.Test)

Example 12 with ChangeLogEntry

use of com.unboundid.ldap.sdk.ChangeLogEntry in project ldapsdk by pingidentity.

the class UnboundIDChangeLogEntryTestCase method testExtendedModifyDNChangeLogEntry.

/**
 * Provides coverage for cases in which an UnboundID changelog entry is
 * created for a modify DN operation an extended set of content.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExtendedModifyDNChangeLogEntry() throws Exception {
    final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(4L, new LDIFModifyDNChangeRecord("uid=test.1,ou=People,dc=example,dc=com", "uid=test.2", true, "ou=Users,o=example.com"));
    assertNotNull(e);
    // Construct before values for the uid attribute.
    final StringBuilder beforeBuffer = new StringBuilder();
    beforeBuffer.append("uid: test.1");
    beforeBuffer.append(StaticUtils.EOL);
    // Construct after values for the uid attribute.
    final StringBuilder afterBuffer = new StringBuilder();
    afterBuffer.append("uid: test.2");
    afterBuffer.append(StaticUtils.EOL);
    // Construct a key attribute value for the "cn" attribute.
    final StringBuilder keyAttrBuffer = new StringBuilder();
    keyAttrBuffer.append("cn: Test User");
    keyAttrBuffer.append(StaticUtils.EOL);
    final Entry extendedEntry = e.duplicate();
    extendedEntry.addAttribute("ds-changelog-before-values", beforeBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-after-values", afterBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-entry-key-attr-values", keyAttrBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-num-excluded-operational-attributes", "2");
    extendedEntry.addAttribute("ds-changelog-excluded-operational-attribute", "modifiersName", "modifyTimestamp");
    extendedEntry.addAttribute("targetUniqueID", "468c6887-4fcc-38ea-9425-abcaa3c88be6");
    extendedEntry.addAttribute("localCSN", "00000131EDEDD535000000000006");
    extendedEntry.addAttribute("changeTime", "20110821200012Z");
    extendedEntry.addAttribute("ds-changelog-target-attribute", "uid");
    extendedEntry.addAttribute("ds-notification-destination-entry-uuid", "12345678-90ab-cdef-1234-567890abcdef", "23456789-0abC-def1-2345-67890abcdef1");
    extendedEntry.addAttribute("ds-changelog-notification-properties", "notification-property-1", "notification-property-2", "notification-property-3");
    final UnboundIDChangeLogEntry ue = new UnboundIDChangeLogEntry(extendedEntry);
    assertNotNull(ue);
    assertEquals(ue.getChangeNumber(), 4L);
    assertNotNull(ue.getTargetDN());
    assertEquals(new DN(ue.getTargetDN()), new DN("uid=test.1,ou=People,dc=example,dc=com"));
    assertNotNull(ue.getChangeType());
    assertEquals(ue.getChangeType(), ChangeType.MODIFY_DN);
    assertNull(ue.getAddAttributes());
    assertNull(ue.getDeletedEntryAttributes());
    assertNull(ue.getModifications());
    assertNotNull(ue.getNewRDN());
    assertEquals(new RDN(ue.getNewRDN()), new RDN("uid=test.2"));
    assertTrue(ue.deleteOldRDN());
    assertNotNull(ue.getNewSuperior());
    assertEquals(new DN(ue.getNewSuperior()), new DN("ou=Users,o=example.com"));
    assertNull(ue.getSoftDeleteToDN());
    assertNull(ue.getUndeleteFromDN());
    assertNull(ue.getChangeToSoftDeletedEntry());
    assertNotNull(ue.getNewDN());
    assertEquals(new DN(ue.getNewDN()), new DN("uid=test.2,ou=Users,o=example.com"));
    assertNotNull(ue.getUpdatedAttributesBeforeChange());
    assertEquals(ue.getUpdatedAttributesBeforeChange().size(), 1);
    assertTrue(ue.getUpdatedAttributesBeforeChange().contains(new Attribute("uid", "test.1")));
    assertNotNull(ue.getUpdatedAttributesAfterChange());
    assertEquals(ue.getUpdatedAttributesAfterChange().size(), 1);
    assertTrue(ue.getUpdatedAttributesAfterChange().contains(new Attribute("uid", "test.2")));
    assertNotNull(ue.getAttributesThatExceededMaxValuesCount());
    assertTrue(ue.getAttributesThatExceededMaxValuesCount().isEmpty());
    assertNotNull(ue.getKeyEntryAttributes());
    assertEquals(ue.getKeyEntryAttributes().size(), 1);
    assertTrue(ue.getKeyEntryAttributes().contains(new Attribute("cn", "Test User")));
    assertEquals(ue.getNumExcludedUserAttributes(), -1);
    assertEquals(ue.getNumExcludedOperationalAttributes(), 2);
    assertNotNull(ue.getExcludedUserAttributeNames());
    assertTrue(ue.getExcludedUserAttributeNames().isEmpty());
    assertNotNull(ue.getExcludedOperationalAttributeNames());
    assertFalse(ue.getExcludedOperationalAttributeNames().isEmpty());
    assertTrue(ue.getExcludedOperationalAttributeNames().contains("modifiersName"));
    assertTrue(ue.getExcludedOperationalAttributeNames().contains("modifyTimestamp"));
    assertNotNull(ue.getAttributeBeforeChange("uid"));
    assertEquals(ue.getAttributeBeforeChange("uid"), new Attribute("uid", "test.1"));
    assertNotNull(ue.getAttributeBeforeChange("cn"));
    assertEquals(ue.getAttributeBeforeChange("cn"), new Attribute("cn", "Test User"));
    assertNull(ue.getAttributeBeforeChange("description"));
    assertNotNull(ue.getAttributeAfterChange("uid"));
    assertEquals(ue.getAttributeAfterChange("uid"), new Attribute("uid", "test.2"));
    assertNotNull(ue.getAttributeAfterChange("cn"));
    assertEquals(ue.getAttributeAfterChange("cn"), new Attribute("cn", "Test User"));
    assertNull(ue.getAttributeAfterChange("description"));
    assertNotNull(ue.constructPartialEntryBeforeChange());
    assertEquals(ue.constructPartialEntryBeforeChange(), new Entry("dn: uid=test.1,ou=People,dc=example,dc=com", "uid: test.1", "cn: Test User"));
    assertNotNull(ue.constructPartialEntryAfterChange());
    assertEquals(ue.constructPartialEntryAfterChange(), new Entry("dn: uid=test.2,ou=Users,o=example.com", "uid: test.2", "cn: Test User"));
    assertNotNull(ue.getTargetUniqueID());
    assertEquals(ue.getTargetUniqueID(), "468c6887-4fcc-38ea-9425-abcaa3c88be6");
    assertNotNull(ue.getLocalCSN());
    assertEquals(ue.getLocalCSN(), "00000131EDEDD535000000000006");
    assertNotNull(ue.getChangeTime());
    assertEquals(ue.getChangeTime().getTime(), StaticUtils.decodeGeneralizedTime("20110821200012Z").getTime());
    assertNotNull(ue.getTargetAttributeNames());
    assertFalse(ue.getTargetAttributeNames().isEmpty());
    assertEquals(ue.getTargetAttributeNames().size(), 1);
    assertNotNull(ue.getNotificationDestinationEntryUUIDs());
    assertFalse(ue.getNotificationDestinationEntryUUIDs().isEmpty());
    assertEquals(ue.getNotificationDestinationEntryUUIDs().size(), 2);
    assertNotNull(ue.getNotificationProperties());
    assertFalse(ue.getNotificationProperties().isEmpty());
    assertEquals(ue.getNotificationProperties().size(), 3);
}
Also used : Entry(com.unboundid.ldap.sdk.Entry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) Attribute(com.unboundid.ldap.sdk.Attribute) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) RDN(com.unboundid.ldap.sdk.RDN) DN(com.unboundid.ldap.sdk.DN) RDN(com.unboundid.ldap.sdk.RDN) LDIFModifyDNChangeRecord(com.unboundid.ldif.LDIFModifyDNChangeRecord) Test(org.testng.annotations.Test)

Example 13 with ChangeLogEntry

use of com.unboundid.ldap.sdk.ChangeLogEntry in project ldapsdk by pingidentity.

the class UnboundIDChangeLogEntryTestCase method testBasicAddChangeLogEntry.

/**
 * Provides coverage for cases in which an UnboundID changelog entry is
 * created for an add operation without any UnboundID-specific content.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testBasicAddChangeLogEntry() throws Exception {
    final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(1L, new LDIFAddChangeRecord(new Entry("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example")));
    assertNotNull(e);
    final UnboundIDChangeLogEntry ue = new UnboundIDChangeLogEntry(e);
    assertNotNull(ue);
    assertEquals(ue.getChangeNumber(), 1L);
    assertNotNull(ue.getTargetDN());
    assertEquals(new DN(ue.getTargetDN()), new DN("dc=example,dc=com"));
    assertNotNull(ue.getChangeType());
    assertEquals(ue.getChangeType(), ChangeType.ADD);
    assertNotNull(ue.getAddAttributes());
    assertEquals(ue.getAddAttributes().size(), 2);
    assertTrue(ue.getAddAttributes().contains(new Attribute("objectClass", "top", "domain")));
    assertTrue(ue.getAddAttributes().contains(new Attribute("dc", "example")));
    assertNotNull(ue.getAddAttributes(true));
    assertEquals(ue.getAddAttributes(true).size(), 2);
    assertTrue(ue.getAddAttributes(true).contains(new Attribute("objectClass", "top", "domain")));
    assertTrue(ue.getAddAttributes(true).contains(new Attribute("dc", "example")));
    assertNotNull(ue.getAddVirtualAttributes());
    assertTrue(ue.getAddVirtualAttributes().isEmpty());
    assertNull(ue.getDeletedEntryAttributes());
    assertNull(ue.getDeletedEntryAttributes(true));
    assertNull(ue.getDeletedEntryVirtualAttributes());
    assertNull(ue.getModifications());
    assertNull(ue.getNewRDN());
    assertFalse(ue.deleteOldRDN());
    assertNull(ue.getNewSuperior());
    assertNull(ue.getSoftDeleteToDN());
    assertNull(ue.getUndeleteFromDN());
    assertNull(ue.getChangeToSoftDeletedEntry());
    assertNotNull(ue.getNewDN());
    assertEquals(new DN(ue.getNewDN()), new DN("dc=example,dc=com"));
    assertNotNull(ue.getUpdatedAttributesBeforeChange());
    assertTrue(ue.getUpdatedAttributesBeforeChange().isEmpty());
    assertNotNull(ue.getUpdatedAttributesBeforeChange(true));
    assertTrue(ue.getUpdatedAttributesBeforeChange(true).isEmpty());
    assertNotNull(ue.getUpdatedVirtualAttributesBeforeChange());
    assertTrue(ue.getUpdatedVirtualAttributesBeforeChange().isEmpty());
    assertNotNull(ue.getUpdatedAttributesAfterChange());
    assertTrue(ue.getUpdatedAttributesAfterChange().isEmpty());
    assertNotNull(ue.getUpdatedAttributesAfterChange(true));
    assertTrue(ue.getUpdatedAttributesAfterChange(true).isEmpty());
    assertNotNull(ue.getUpdatedVirtualAttributesAfterChange());
    assertTrue(ue.getUpdatedVirtualAttributesAfterChange().isEmpty());
    assertNotNull(ue.getAttributesThatExceededMaxValuesCount());
    assertTrue(ue.getAttributesThatExceededMaxValuesCount().isEmpty());
    assertNotNull(ue.getVirtualAttributesThatExceededMaxValuesCount());
    assertTrue(ue.getVirtualAttributesThatExceededMaxValuesCount().isEmpty());
    assertNotNull(ue.getKeyEntryAttributes());
    assertTrue(ue.getKeyEntryAttributes().isEmpty());
    assertNotNull(ue.getKeyEntryAttributes(true));
    assertTrue(ue.getKeyEntryAttributes(true).isEmpty());
    assertNotNull(ue.getKeyEntryVirtualAttributes());
    assertTrue(ue.getKeyEntryVirtualAttributes().isEmpty());
    assertEquals(ue.getNumExcludedUserAttributes(), -1);
    assertEquals(ue.getNumExcludedOperationalAttributes(), -1);
    assertNotNull(ue.getExcludedUserAttributeNames());
    assertTrue(ue.getExcludedUserAttributeNames().isEmpty());
    assertNotNull(ue.getExcludedOperationalAttributeNames());
    assertTrue(ue.getExcludedOperationalAttributeNames().isEmpty());
    assertNull(ue.getAttributeBeforeChange("dc"));
    assertNull(ue.getAttributeBeforeChange("dc", true));
    assertNotNull(ue.getAttributeAfterChange("dc"));
    assertEquals(ue.getAttributeAfterChange("dc"), new Attribute("dc", "example"));
    assertNotNull(ue.getAttributeAfterChange("dc", true));
    assertEquals(ue.getAttributeAfterChange("dc", true), new Attribute("dc", "example"));
    assertNull(ue.getAttributeAfterChange("missing"));
    assertNull(ue.getAttributeAfterChange("missing", true));
    assertNull(ue.constructPartialEntryBeforeChange());
    assertNull(ue.constructPartialEntryBeforeChange(true));
    assertNotNull(ue.constructPartialEntryAfterChange());
    assertEquals(ue.constructPartialEntryAfterChange(), new Entry("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example"));
    assertNotNull(ue.constructPartialEntryAfterChange(true));
    assertEquals(ue.constructPartialEntryAfterChange(true), new Entry("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example"));
    assertNull(ue.getTargetUniqueID());
    assertNull(ue.getLocalCSN());
    assertNull(ue.getChangeTime());
    assertNotNull(ue.getTargetAttributeNames());
    assertTrue(ue.getTargetAttributeNames().isEmpty());
    assertNotNull(ue.getNotificationDestinationEntryUUIDs());
    assertTrue(ue.getNotificationDestinationEntryUUIDs().isEmpty());
    assertNotNull(ue.getNotificationProperties());
    assertTrue(ue.getNotificationProperties().isEmpty());
}
Also used : Entry(com.unboundid.ldap.sdk.Entry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) Attribute(com.unboundid.ldap.sdk.Attribute) LDIFAddChangeRecord(com.unboundid.ldif.LDIFAddChangeRecord) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) RDN(com.unboundid.ldap.sdk.RDN) DN(com.unboundid.ldap.sdk.DN) Test(org.testng.annotations.Test)

Example 14 with ChangeLogEntry

use of com.unboundid.ldap.sdk.ChangeLogEntry in project ldapsdk by pingidentity.

the class UnboundIDChangeLogEntryTestCase method testExtendedDeleteChangeLogEntry.

/**
 * Provides coverage for cases in which an UnboundID changelog entry is
 * created for a delete operation without an extended set of content.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExtendedDeleteChangeLogEntry() throws Exception {
    final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(4L, new LDIFDeleteChangeRecord("uid=test.user,ou=People,dc=example,dc=com"));
    assertNotNull(e);
    // Construct a set of deleted entry attributes.
    final StringBuilder deletedAttrsBuffer = new StringBuilder();
    deletedAttrsBuffer.append("objectClass: top");
    deletedAttrsBuffer.append(StaticUtils.EOL);
    deletedAttrsBuffer.append("objectClass: person");
    deletedAttrsBuffer.append(StaticUtils.EOL);
    deletedAttrsBuffer.append("objectClass: organizationalPerson");
    deletedAttrsBuffer.append(StaticUtils.EOL);
    deletedAttrsBuffer.append("objectClass: inetOrgPerson");
    deletedAttrsBuffer.append(StaticUtils.EOL);
    deletedAttrsBuffer.append("uid: test.user");
    deletedAttrsBuffer.append(StaticUtils.EOL);
    deletedAttrsBuffer.append("givenName: Test");
    deletedAttrsBuffer.append(StaticUtils.EOL);
    deletedAttrsBuffer.append("sn: User");
    deletedAttrsBuffer.append(StaticUtils.EOL);
    deletedAttrsBuffer.append("cn: Test User");
    deletedAttrsBuffer.append(StaticUtils.EOL);
    deletedAttrsBuffer.append("cn: User, Test");
    deletedAttrsBuffer.append(StaticUtils.EOL);
    // Construct virtual attributes for the entry.
    final StringBuilder virtualAttrBuffer = new StringBuilder();
    virtualAttrBuffer.append("cn: Virtual cn");
    virtualAttrBuffer.append(StaticUtils.EOL);
    virtualAttrBuffer.append("description: Virtual description");
    virtualAttrBuffer.append(StaticUtils.EOL);
    // Construct a key attribute value for the "cn" attribute.
    final StringBuilder keyAttrBuffer = new StringBuilder();
    keyAttrBuffer.append("cn: Test User");
    keyAttrBuffer.append(StaticUtils.EOL);
    keyAttrBuffer.append("cn: User, Test");
    keyAttrBuffer.append(StaticUtils.EOL);
    // Construct a key virtual attribute value for the "cn" attribute.
    final StringBuilder keyVirtualAttrBuffer = new StringBuilder();
    keyVirtualAttrBuffer.append("cn: Virtual cn");
    keyVirtualAttrBuffer.append(StaticUtils.EOL);
    final Entry extendedEntry = e.duplicate();
    extendedEntry.addAttribute("deletedEntryAttrs", deletedAttrsBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-virtual-attributes", virtualAttrBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-entry-key-attr-values", keyAttrBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-entry-key-virtual-values", keyVirtualAttrBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-num-excluded-user-attributes", "2");
    extendedEntry.addAttribute("ds-changelog-num-excluded-operational-attributes", "5");
    extendedEntry.addAttribute("ds-changelog-excluded-user-attribute", "description", "userPassword");
    extendedEntry.addAttribute("ds-changelog-excluded-operational-attribute", "creatorsName", "createTimestamp", "modifiersName", "modifyTimestamp", "entryUUID");
    extendedEntry.addAttribute("targetUniqueID", "468c6887-4fcc-38ea-9425-abcaa3c88be6");
    extendedEntry.addAttribute("localCSN", "00000131EDEDD535000000000006");
    extendedEntry.addAttribute("changeTime", "20110821200012Z");
    extendedEntry.addAttribute("ds-soft-delete-entry-dn", "uid=test.user,ou=People,dc=example,dc=com");
    extendedEntry.addAttribute("ds-change-to-soft-deleted-entry", "false");
    extendedEntry.addAttribute("ds-changelog-target-attribute", "objectClass", "uid", "givenName", "sn", "cn");
    extendedEntry.addAttribute("ds-notification-destination-entry-uuid", "12345678-90ab-cdef-1234-567890abcdef", "23456789-0abC-def1-2345-67890abcdef1");
    extendedEntry.addAttribute("ds-changelog-notification-properties", "notification-property-1", "notification-property-2", "notification-property-3");
    final UnboundIDChangeLogEntry ue = new UnboundIDChangeLogEntry(extendedEntry);
    assertNotNull(ue);
    assertEquals(ue.getChangeNumber(), 4L);
    assertNotNull(ue.getTargetDN());
    assertEquals(new DN(ue.getTargetDN()), new DN("uid=test.user,ou=People,dc=example,dc=com"));
    assertNotNull(ue.getChangeType());
    assertEquals(ue.getChangeType(), ChangeType.DELETE);
    assertNull(ue.getAddAttributes());
    assertNull(ue.getAddAttributes(true));
    assertNull(ue.getAddVirtualAttributes());
    assertNotNull(ue.getDeletedEntryAttributes());
    assertEquals(ue.getDeletedEntryAttributes().size(), 5);
    assertTrue(ue.getDeletedEntryAttributes().contains(new Attribute("objectClass", "top", "person", "organizationalPerson", "inetOrgPerson")));
    assertTrue(ue.getDeletedEntryAttributes().contains(new Attribute("uid", "test.user")));
    assertTrue(ue.getDeletedEntryAttributes().contains(new Attribute("givenName", "Test")));
    assertTrue(ue.getDeletedEntryAttributes().contains(new Attribute("sn", "User")));
    assertTrue(ue.getDeletedEntryAttributes().contains(new Attribute("cn", "Test User", "User, Test")));
    assertNotNull(ue.getDeletedEntryAttributes(true));
    assertEquals(ue.getDeletedEntryAttributes(true).size(), 6);
    assertTrue(ue.getDeletedEntryAttributes(true).contains(new Attribute("objectClass", "top", "person", "organizationalPerson", "inetOrgPerson")));
    assertTrue(ue.getDeletedEntryAttributes(true).contains(new Attribute("uid", "test.user")));
    assertTrue(ue.getDeletedEntryAttributes(true).contains(new Attribute("givenName", "Test")));
    assertTrue(ue.getDeletedEntryAttributes(true).contains(new Attribute("sn", "User")));
    assertTrue(ue.getDeletedEntryAttributes(true).contains(new Attribute("cn", "Test User", "User, Test", "Virtual cn")));
    assertTrue(ue.getDeletedEntryAttributes(true).contains(new Attribute("description", "Virtual description")));
    assertNotNull(ue.getDeletedEntryVirtualAttributes());
    assertEquals(ue.getDeletedEntryVirtualAttributes().size(), 2);
    assertTrue(ue.getDeletedEntryVirtualAttributes().contains(new Attribute("cn", "Virtual cn")));
    assertTrue(ue.getDeletedEntryVirtualAttributes().contains(new Attribute("description", "Virtual description")));
    assertNull(ue.getModifications());
    assertNull(ue.getNewRDN());
    assertFalse(ue.deleteOldRDN());
    assertNull(ue.getNewSuperior());
    assertNotNull(ue.getSoftDeleteToDN());
    assertNull(ue.getUndeleteFromDN());
    assertNotNull(ue.getChangeToSoftDeletedEntry());
    assertFalse(ue.getChangeToSoftDeletedEntry());
    assertNull(ue.getNewDN());
    assertNotNull(ue.getUpdatedAttributesBeforeChange());
    assertTrue(ue.getUpdatedAttributesBeforeChange().isEmpty());
    assertNotNull(ue.getUpdatedAttributesBeforeChange(true));
    assertTrue(ue.getUpdatedAttributesBeforeChange(true).isEmpty());
    assertNotNull(ue.getUpdatedVirtualAttributesBeforeChange());
    assertTrue(ue.getUpdatedVirtualAttributesBeforeChange().isEmpty());
    assertNotNull(ue.getUpdatedAttributesAfterChange());
    assertTrue(ue.getUpdatedAttributesAfterChange().isEmpty());
    assertNotNull(ue.getUpdatedAttributesAfterChange(true));
    assertTrue(ue.getUpdatedAttributesAfterChange(true).isEmpty());
    assertNotNull(ue.getUpdatedVirtualAttributesAfterChange());
    assertTrue(ue.getUpdatedVirtualAttributesAfterChange().isEmpty());
    assertNotNull(ue.getAttributesThatExceededMaxValuesCount());
    assertTrue(ue.getAttributesThatExceededMaxValuesCount().isEmpty());
    assertNotNull(ue.getVirtualAttributesThatExceededMaxValuesCount());
    assertTrue(ue.getVirtualAttributesThatExceededMaxValuesCount().isEmpty());
    assertNotNull(ue.getKeyEntryAttributes());
    assertEquals(ue.getKeyEntryAttributes().size(), 1);
    assertTrue(ue.getKeyEntryAttributes().contains(new Attribute("cn", "Test User", "User, Test")));
    assertNotNull(ue.getKeyEntryAttributes(true));
    assertEquals(ue.getKeyEntryAttributes(true).size(), 1);
    assertTrue(ue.getKeyEntryAttributes(true).contains(new Attribute("cn", "Test User", "User, Test", "Virtual cn")));
    assertNotNull(ue.getKeyEntryVirtualAttributes());
    assertEquals(ue.getKeyEntryVirtualAttributes().size(), 1);
    assertTrue(ue.getKeyEntryVirtualAttributes().contains(new Attribute("cn", "Virtual cn")));
    assertEquals(ue.getNumExcludedUserAttributes(), 2);
    assertEquals(ue.getNumExcludedOperationalAttributes(), 5);
    assertNotNull(ue.getExcludedUserAttributeNames());
    assertFalse(ue.getExcludedUserAttributeNames().isEmpty());
    assertTrue(ue.getExcludedUserAttributeNames().contains("description"));
    assertTrue(ue.getExcludedUserAttributeNames().contains("userPassword"));
    assertNotNull(ue.getExcludedOperationalAttributeNames());
    assertFalse(ue.getExcludedOperationalAttributeNames().isEmpty());
    assertTrue(ue.getExcludedOperationalAttributeNames().contains("creatorsName"));
    assertTrue(ue.getExcludedOperationalAttributeNames().contains("createTimestamp"));
    assertTrue(ue.getExcludedOperationalAttributeNames().contains("modifiersName"));
    assertTrue(ue.getExcludedOperationalAttributeNames().contains("modifyTimestamp"));
    assertTrue(ue.getExcludedOperationalAttributeNames().contains("entryUUID"));
    assertNotNull(ue.getAttributeBeforeChange("uid"));
    assertEquals(ue.getAttributeBeforeChange("uid"), new Attribute("uid", "test.user"));
    assertNotNull(ue.getAttributeBeforeChange("uid", true));
    assertEquals(ue.getAttributeBeforeChange("uid", true), new Attribute("uid", "test.user"));
    assertNotNull(ue.getAttributeBeforeChange("cn"));
    assertEquals(ue.getAttributeBeforeChange("cn"), new Attribute("cn", "Test User", "User, Test"));
    assertNotNull(ue.getAttributeBeforeChange("cn", true));
    assertEquals(ue.getAttributeBeforeChange("cn", true), new Attribute("cn", "Test User", "User, Test", "Virtual cn"));
    assertNull(ue.getAttributeBeforeChange("missing"));
    assertNull(ue.getAttributeBeforeChange("missing", true));
    assertNull(ue.getAttributeBeforeChange("description"));
    assertNotNull(ue.getAttributeBeforeChange("description", true));
    assertEquals(ue.getAttributeBeforeChange("description", true), new Attribute("description", "Virtual description"));
    assertNull(ue.getAttributeAfterChange("uid"));
    assertNull(ue.getAttributeAfterChange("uid", true));
    assertNotNull(ue.constructPartialEntryBeforeChange());
    assertEquals(ue.constructPartialEntryBeforeChange(), new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "objectClass: top", "objectClass: person", "objectClass: organizationalPerson", "objectClass: inetOrgPerson", "uid: test.user", "givenName: Test", "sn: User", "cn: Test User", "cn: User, Test"));
    assertNotNull(ue.constructPartialEntryBeforeChange(true));
    assertEquals(ue.constructPartialEntryBeforeChange(true), new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "objectClass: top", "objectClass: person", "objectClass: organizationalPerson", "objectClass: inetOrgPerson", "uid: test.user", "givenName: Test", "sn: User", "cn: Test User", "cn: User, Test", "cn: Virtual cn", "description: Virtual description"));
    assertNull(ue.constructPartialEntryAfterChange());
    assertNull(ue.constructPartialEntryAfterChange(true));
    assertNotNull(ue.getTargetUniqueID());
    assertEquals(ue.getTargetUniqueID(), "468c6887-4fcc-38ea-9425-abcaa3c88be6");
    assertNotNull(ue.getLocalCSN());
    assertEquals(ue.getLocalCSN(), "00000131EDEDD535000000000006");
    assertNotNull(ue.getChangeTime());
    assertEquals(ue.getChangeTime().getTime(), StaticUtils.decodeGeneralizedTime("20110821200012Z").getTime());
    assertNotNull(ue.getTargetAttributeNames());
    assertFalse(ue.getTargetAttributeNames().isEmpty());
    assertEquals(ue.getTargetAttributeNames().size(), 5);
    assertNotNull(ue.getNotificationDestinationEntryUUIDs());
    assertFalse(ue.getNotificationDestinationEntryUUIDs().isEmpty());
    assertEquals(ue.getNotificationDestinationEntryUUIDs().size(), 2);
    assertNotNull(ue.getNotificationProperties());
    assertFalse(ue.getNotificationProperties().isEmpty());
    assertEquals(ue.getNotificationProperties().size(), 3);
}
Also used : Entry(com.unboundid.ldap.sdk.Entry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) Attribute(com.unboundid.ldap.sdk.Attribute) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) RDN(com.unboundid.ldap.sdk.RDN) DN(com.unboundid.ldap.sdk.DN) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord) Test(org.testng.annotations.Test)

Example 15 with ChangeLogEntry

use of com.unboundid.ldap.sdk.ChangeLogEntry in project ldapsdk by pingidentity.

the class UnboundIDChangeLogEntryTestCase method testExtendedModifyChangeLogEntryWithExceededAfterValues.

/**
 * Provides coverage for cases in which an UnboundID changelog entry is
 * created for a modify operation without an extended set of content that
 * includes attributes with non-exceeded before but exceeded after value
 * counts.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExtendedModifyChangeLogEntryWithExceededAfterValues() throws Exception {
    final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(4L, new LDIFModifyChangeRecord("cn=Test,ou=Groups,dc=example,dc=com", new Modification(ModificationType.ADD, "member", "uid=user.4,ou=People,dc=example,dc=com")));
    assertNotNull(e);
    // Construct before values for the member attribute.
    final StringBuilder beforeBuffer = new StringBuilder();
    beforeBuffer.append("member: uid=user.1,ou=People,dc=example,dc=com");
    beforeBuffer.append(StaticUtils.EOL);
    beforeBuffer.append("member: uid=user.2,ou=People,dc=example,dc=com");
    beforeBuffer.append(StaticUtils.EOL);
    beforeBuffer.append("member: uid=user.3,ou=People,dc=example,dc=com");
    beforeBuffer.append(StaticUtils.EOL);
    // Construct a key attribute value for the "cn" attribute.
    final StringBuilder keyAttrBuffer = new StringBuilder();
    keyAttrBuffer.append("cn: Test");
    keyAttrBuffer.append(StaticUtils.EOL);
    final Entry extendedEntry = e.duplicate();
    extendedEntry.addAttribute("ds-changelog-before-values", beforeBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-attr-exceeded-max-values-count", "attr=member,beforeCount=3,afterCount=4");
    extendedEntry.addAttribute("ds-changelog-entry-key-attr-values", keyAttrBuffer.toString());
    extendedEntry.addAttribute("targetUniqueID", "468c6887-4fcc-38ea-9425-abcaa3c88be6");
    extendedEntry.addAttribute("localCSN", "00000131EDEDD535000000000006");
    extendedEntry.addAttribute("changeTime", "20110821200012Z");
    extendedEntry.addAttribute("ds-changelog-target-attribute", "member");
    extendedEntry.addAttribute("ds-notification-destination-entry-uuid", "12345678-90ab-cdef-1234-567890abcdef", "23456789-0abC-def1-2345-67890abcdef1");
    extendedEntry.addAttribute("ds-changelog-notification-properties", "notification-property-1", "notification-property-2", "notification-property-3");
    final UnboundIDChangeLogEntry ue = new UnboundIDChangeLogEntry(extendedEntry);
    assertNotNull(ue);
    assertEquals(ue.getChangeNumber(), 4L);
    assertNotNull(ue.getTargetDN());
    assertEquals(new DN(ue.getTargetDN()), new DN("cn=Test,ou=Groups,dc=example,dc=com"));
    assertNotNull(ue.getChangeType());
    assertEquals(ue.getChangeType(), ChangeType.MODIFY);
    assertNull(ue.getAddAttributes());
    assertNull(ue.getDeletedEntryAttributes());
    assertNotNull(ue.getModifications());
    assertEquals(ue.getModifications().size(), 1);
    assertTrue(ue.getModifications().contains(new Modification(ModificationType.ADD, "member", "uid=user.4,ou=People,dc=example,dc=com")));
    assertNull(ue.getNewRDN());
    assertFalse(ue.deleteOldRDN());
    assertNull(ue.getNewSuperior());
    assertNull(ue.getSoftDeleteToDN());
    assertNull(ue.getUndeleteFromDN());
    assertNull(ue.getChangeToSoftDeletedEntry());
    assertNotNull(ue.getNewDN());
    assertEquals(new DN(ue.getNewDN()), new DN("cn=Test,ou=Groups,dc=example,dc=com"));
    assertNotNull(ue.getUpdatedAttributesBeforeChange());
    assertEquals(ue.getUpdatedAttributesBeforeChange().size(), 1);
    assertTrue(ue.getUpdatedAttributesBeforeChange().contains(new Attribute("member", "uid=user.1,ou=People,dc=example,dc=com", "uid=user.2,ou=People,dc=example,dc=com", "uid=user.3,ou=People,dc=example,dc=com")));
    assertNotNull(ue.getUpdatedAttributesAfterChange());
    assertTrue(ue.getUpdatedAttributesAfterChange().isEmpty());
    assertNotNull(ue.getAttributesThatExceededMaxValuesCount());
    assertEquals(ue.getAttributesThatExceededMaxValuesCount().size(), 1);
    assertTrue(ue.getAttributesThatExceededMaxValuesCount().contains(new ChangeLogEntryAttributeExceededMaxValuesCount("attr=member,beforeCount=3,afterCount=4")));
    assertNotNull(ue.getKeyEntryAttributes());
    assertEquals(ue.getKeyEntryAttributes().size(), 1);
    assertTrue(ue.getKeyEntryAttributes().contains(new Attribute("cn", "Test")));
    assertNull(ue.getAttributeBeforeChange("uid"));
    assertNotNull(ue.getAttributeBeforeChange("cn"));
    assertEquals(ue.getAttributeAfterChange("cn"), new Attribute("cn", "Test"));
    assertNotNull(ue.getAttributeBeforeChange("member"));
    assertEquals(ue.getAttributeBeforeChange("member"), new Attribute("member", "uid=user.1,ou=People,dc=example,dc=com", "uid=user.2,ou=People,dc=example,dc=com", "uid=user.3,ou=People,dc=example,dc=com"));
    assertNull(ue.getAttributeAfterChange("uid"));
    assertNotNull(ue.getAttributeAfterChange("cn"));
    assertEquals(ue.getAttributeAfterChange("cn"), new Attribute("cn", "Test"));
    try {
        ue.getAttributeAfterChange("member");
        fail("Expected an exception when trying to get member after values");
    } catch (final ChangeLogEntryAttributeExceededMaxValuesException ex) {
        // This was expected.
        assertNotNull(ex.getAttributeInfo());
        assertTrue(ex.getAttributeInfo().getAttributeName().equalsIgnoreCase("member"));
        assertEquals(ex.getAttributeInfo().getBeforeCount(), 3);
        assertEquals(ex.getAttributeInfo().getAfterCount(), 4);
    }
    assertNotNull(ue.constructPartialEntryBeforeChange());
    assertEquals(ue.constructPartialEntryBeforeChange(), new Entry("dn: cn=Test,ou=Groups,dc=example,dc=com", "cn: Test", "member: uid=user.1,ou=People,dc=example,dc=com", "member: uid=user.2,ou=People,dc=example,dc=com", "member: uid=user.3,ou=People,dc=example,dc=com"));
    assertNotNull(ue.constructPartialEntryAfterChange());
    assertEquals(ue.constructPartialEntryAfterChange(), new Entry("dn: cn=Test,ou=Groups,dc=example,dc=com", "cn: Test"));
    assertNotNull(ue.getTargetUniqueID());
    assertEquals(ue.getTargetUniqueID(), "468c6887-4fcc-38ea-9425-abcaa3c88be6");
    assertNotNull(ue.getLocalCSN());
    assertEquals(ue.getLocalCSN(), "00000131EDEDD535000000000006");
    assertNotNull(ue.getChangeTime());
    assertEquals(ue.getChangeTime().getTime(), StaticUtils.decodeGeneralizedTime("20110821200012Z").getTime());
    assertNotNull(ue.getTargetAttributeNames());
    assertFalse(ue.getTargetAttributeNames().isEmpty());
    assertEquals(ue.getTargetAttributeNames().size(), 1);
    assertNotNull(ue.getNotificationDestinationEntryUUIDs());
    assertFalse(ue.getNotificationDestinationEntryUUIDs().isEmpty());
    assertEquals(ue.getNotificationDestinationEntryUUIDs().size(), 2);
    assertNotNull(ue.getNotificationProperties());
    assertFalse(ue.getNotificationProperties().isEmpty());
    assertEquals(ue.getNotificationProperties().size(), 3);
}
Also used : Modification(com.unboundid.ldap.sdk.Modification) Entry(com.unboundid.ldap.sdk.Entry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) Attribute(com.unboundid.ldap.sdk.Attribute) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) RDN(com.unboundid.ldap.sdk.RDN) DN(com.unboundid.ldap.sdk.DN) LDIFModifyChangeRecord(com.unboundid.ldif.LDIFModifyChangeRecord) Test(org.testng.annotations.Test)

Aggregations

ChangeLogEntry (com.unboundid.ldap.sdk.ChangeLogEntry)21 Entry (com.unboundid.ldap.sdk.Entry)20 Test (org.testng.annotations.Test)19 DN (com.unboundid.ldap.sdk.DN)13 RDN (com.unboundid.ldap.sdk.RDN)13 Attribute (com.unboundid.ldap.sdk.Attribute)11 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)7 Control (com.unboundid.ldap.sdk.Control)6 Modification (com.unboundid.ldap.sdk.Modification)6 LDIFModifyChangeRecord (com.unboundid.ldif.LDIFModifyChangeRecord)5 LDIFDeleteChangeRecord (com.unboundid.ldif.LDIFDeleteChangeRecord)3 LDAPResult (com.unboundid.ldap.sdk.LDAPResult)2 ReadOnlyEntry (com.unboundid.ldap.sdk.ReadOnlyEntry)2 SearchResultEntry (com.unboundid.ldap.sdk.SearchResultEntry)2 UnboundIDChangeLogEntry (com.unboundid.ldap.sdk.unboundidds.UnboundIDChangeLogEntry)2 LDIFAddChangeRecord (com.unboundid.ldif.LDIFAddChangeRecord)2 LDIFModifyDNChangeRecord (com.unboundid.ldif.LDIFModifyDNChangeRecord)2 DeleteRequest (com.unboundid.ldap.sdk.DeleteRequest)1 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1