Search in sources :

Example 16 with ChangeLogEntry

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

the class UnboundIDChangeLogEntryTestCase method testExtendedModifyChangeLogEntryWithBothExceededValues.

/**
 * 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 and after value counts.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExtendedModifyChangeLogEntryWithBothExceededValues() throws Exception {
    final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(4L, new LDIFModifyChangeRecord("cn=Test,ou=Groups,dc=example,dc=com", new Modification(ModificationType.ADD, "member", "uid=test.user,ou=People,dc=example,dc=com")));
    assertNotNull(e);
    // Construct a key attribute value for the "cn" attribute.
    final StringBuilder keyAttrBuffer = new StringBuilder();
    keyAttrBuffer.append("cn: 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("ds-changelog-attr-exceeded-max-values-count", "attr=member,beforeCount=5,afterCount=6");
    extendedEntry.addAttribute("ds-changelog-virtual-attr-exceeded-max-values-count", "attr=description,beforeCount=7,afterCount=7");
    extendedEntry.addAttribute("ds-changelog-entry-key-attr-values", keyAttrBuffer.toString());
    extendedEntry.addAttribute("ds-changelog-entry-key-virtual-values", keyVirtualAttrBuffer.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.getAddAttributes(true));
    assertNull(ue.getAddVirtualAttributes());
    assertNull(ue.getDeletedEntryAttributes());
    assertNull(ue.getDeletedEntryAttributes(true));
    assertNull(ue.getDeletedEntryVirtualAttributes());
    assertNotNull(ue.getModifications());
    assertEquals(ue.getModifications().size(), 1);
    assertTrue(ue.getModifications().contains(new Modification(ModificationType.ADD, "member", "uid=test.user,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.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());
    assertEquals(ue.getAttributesThatExceededMaxValuesCount().size(), 1);
    assertTrue(ue.getAttributesThatExceededMaxValuesCount().contains(new ChangeLogEntryAttributeExceededMaxValuesCount("attr=member,beforeCount=5,afterCount=6")));
    assertNotNull(ue.getVirtualAttributesThatExceededMaxValuesCount());
    assertEquals(ue.getVirtualAttributesThatExceededMaxValuesCount().size(), 1);
    assertTrue(ue.getVirtualAttributesThatExceededMaxValuesCount().contains(new ChangeLogEntryAttributeExceededMaxValuesCount("attr=description,beforeCount=7,afterCount=7")));
    assertNotNull(ue.getKeyEntryAttributes());
    assertEquals(ue.getKeyEntryAttributes().size(), 1);
    assertTrue(ue.getKeyEntryAttributes().contains(new Attribute("cn", "Test")));
    assertNotNull(ue.getKeyEntryAttributes(true));
    assertEquals(ue.getKeyEntryAttributes(true).size(), 1);
    assertTrue(ue.getKeyEntryAttributes(true).contains(new Attribute("cn", "Test", "Virtual cn")));
    assertNotNull(ue.getKeyEntryVirtualAttributes());
    assertEquals(ue.getKeyEntryVirtualAttributes().size(), 1);
    assertTrue(ue.getKeyEntryVirtualAttributes().contains(new Attribute("cn", "Virtual cn")));
    assertNull(ue.getAttributeBeforeChange("uid"));
    assertNull(ue.getAttributeBeforeChange("uid", true));
    assertNotNull(ue.getAttributeBeforeChange("cn"));
    assertEquals(ue.getAttributeAfterChange("cn"), new Attribute("cn", "Test"));
    assertNotNull(ue.getAttributeBeforeChange("cn", true));
    assertEquals(ue.getAttributeAfterChange("cn", true), new Attribute("cn", "Test", "Virtual cn"));
    try {
        ue.getAttributeBeforeChange("member");
        fail("Expected an exception when trying to member before values");
    } catch (final ChangeLogEntryAttributeExceededMaxValuesException ex) {
        // This was expected.
        assertNotNull(ex.getAttributeInfo());
        assertTrue(ex.getAttributeInfo().getAttributeName().equalsIgnoreCase("member"));
        assertEquals(ex.getAttributeInfo().getBeforeCount(), 5);
        assertEquals(ex.getAttributeInfo().getAfterCount(), 6);
    }
    try {
        ue.getAttributeBeforeChange("member", true);
        fail("Expected an exception when trying to member before values");
    } catch (final ChangeLogEntryAttributeExceededMaxValuesException ex) {
        // This was expected.
        assertNotNull(ex.getAttributeInfo());
        assertTrue(ex.getAttributeInfo().getAttributeName().equalsIgnoreCase("member"));
        assertEquals(ex.getAttributeInfo().getBeforeCount(), 5);
        assertEquals(ex.getAttributeInfo().getAfterCount(), 6);
    }
    assertNull(ue.getAttributeAfterChange("uid"));
    assertNull(ue.getAttributeAfterChange("uid", true));
    assertNotNull(ue.getAttributeAfterChange("cn"));
    assertEquals(ue.getAttributeAfterChange("cn"), new Attribute("cn", "Test"));
    assertNotNull(ue.getAttributeAfterChange("cn", true));
    assertEquals(ue.getAttributeAfterChange("cn", true), new Attribute("cn", "Test", "Virtual cn"));
    try {
        ue.getAttributeBeforeChange("member");
        fail("Expected an exception when trying to member after values");
    } catch (final ChangeLogEntryAttributeExceededMaxValuesException ex) {
        // This was expected.
        assertNotNull(ex.getAttributeInfo());
        assertTrue(ex.getAttributeInfo().getAttributeName().equalsIgnoreCase("member"));
        assertEquals(ex.getAttributeInfo().getBeforeCount(), 5);
        assertEquals(ex.getAttributeInfo().getAfterCount(), 6);
    }
    assertNull(ue.getAttributeAfterChange("description"));
    try {
        ue.getAttributeBeforeChange("description", true);
        fail("Expected an exception when trying to description after values");
    } catch (final ChangeLogEntryAttributeExceededMaxValuesException ex) {
        // This was expected.
        assertNotNull(ex.getAttributeInfo());
        assertTrue(ex.getAttributeInfo().getAttributeName().equalsIgnoreCase("description"));
        assertEquals(ex.getAttributeInfo().getBeforeCount(), 7);
        assertEquals(ex.getAttributeInfo().getAfterCount(), 7);
    }
    try {
        ue.getAttributeAfterChange("member", true);
        fail("Expected an exception when trying to member after values");
    } catch (final ChangeLogEntryAttributeExceededMaxValuesException ex) {
        // This was expected.
        assertNotNull(ex.getAttributeInfo());
        assertTrue(ex.getAttributeInfo().getAttributeName().equalsIgnoreCase("member"));
        assertEquals(ex.getAttributeInfo().getBeforeCount(), 5);
        assertEquals(ex.getAttributeInfo().getAfterCount(), 6);
    }
    assertNull(ue.getAttributeAfterChange("description"));
    try {
        ue.getAttributeAfterChange("description", true);
        fail("Expected an exception when trying to description after values");
    } catch (final ChangeLogEntryAttributeExceededMaxValuesException ex) {
        // This was expected.
        assertNotNull(ex.getAttributeInfo());
        assertTrue(ex.getAttributeInfo().getAttributeName().equalsIgnoreCase("description"));
        assertEquals(ex.getAttributeInfo().getBeforeCount(), 7);
        assertEquals(ex.getAttributeInfo().getAfterCount(), 7);
    }
    assertNotNull(ue.constructPartialEntryBeforeChange());
    assertEquals(ue.constructPartialEntryBeforeChange(), new Entry("dn: cn=Test,ou=Groups,dc=example,dc=com", "cn: Test"));
    assertNotNull(ue.constructPartialEntryBeforeChange(true));
    assertEquals(ue.constructPartialEntryBeforeChange(true), new Entry("dn: cn=Test,ou=Groups,dc=example,dc=com", "cn: Test", "cn: Virtual cn"));
    assertNotNull(ue.constructPartialEntryAfterChange());
    assertEquals(ue.constructPartialEntryAfterChange(), new Entry("dn: cn=Test,ou=Groups,dc=example,dc=com", "cn: Test"));
    assertNotNull(ue.constructPartialEntryAfterChange(true));
    assertEquals(ue.constructPartialEntryAfterChange(true), new Entry("dn: cn=Test,ou=Groups,dc=example,dc=com", "cn: Test", "cn: Virtual cn"));
    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 17 with ChangeLogEntry

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

the class UnboundIDChangeLogEntryTestCase method testExtendedAddChangeLogEntry.

/**
 * Provides coverage for cases in which an UnboundID changelog entry is
 * created for an add operation with an extended set of content.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testExtendedAddChangeLogEntry() throws Exception {
    // Create the basic entry.
    final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(3L, new LDIFAddChangeRecord(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")));
    assertNotNull(e);
    // 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);
    // 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("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", "3");
    extendedEntry.addAttribute("ds-changelog-excluded-user-attribute", "description", "userPassword");
    extendedEntry.addAttribute("ds-changelog-excluded-operational-attribute", "creatorsName", "createTimestamp", "entryUUID");
    extendedEntry.addAttribute("targetUniqueID", "468c6887-4fcc-38ea-9425-abcaa3c88be6");
    extendedEntry.addAttribute("localCSN", "00000131EDEDD535000000000006");
    extendedEntry.addAttribute("changeTime", "20110821200012Z");
    extendedEntry.addAttribute("ds-undelete-from-dn", "entryUUID=468c6887-4fcc-38ea-9425-abcaa3c88be6+uid=test.user," + "ou=People,dc=example,dc=com");
    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(), 3L);
    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.ADD);
    assertNotNull(ue.getAddAttributes());
    assertEquals(ue.getAddAttributes().size(), 5);
    assertTrue(ue.getAddAttributes().contains(new Attribute("objectClass", "top", "person", "organizationalPerson", "inetOrgPerson")));
    assertTrue(ue.getAddAttributes().contains(new Attribute("uid", "test.user")));
    assertTrue(ue.getAddAttributes().contains(new Attribute("givenName", "Test")));
    assertTrue(ue.getAddAttributes().contains(new Attribute("sn", "User")));
    assertTrue(ue.getAddAttributes().contains(new Attribute("cn", "Test User")));
    assertFalse(ue.getAddAttributes().contains(new Attribute("cn", "Virtual cn")));
    assertFalse(ue.getAddAttributes().contains(new Attribute("description", "Virtual description")));
    assertNotNull(ue.getAddAttributes(true));
    assertEquals(ue.getAddAttributes(true).size(), 6);
    assertTrue(ue.getAddAttributes(true).contains(new Attribute("objectClass", "top", "person", "organizationalPerson", "inetOrgPerson")));
    assertTrue(ue.getAddAttributes(true).contains(new Attribute("uid", "test.user")));
    assertTrue(ue.getAddAttributes(true).contains(new Attribute("givenName", "Test")));
    assertTrue(ue.getAddAttributes(true).contains(new Attribute("sn", "User")));
    assertTrue(ue.getAddAttributes(true).contains(new Attribute("cn", "Test User", "Virtual cn")));
    assertTrue(ue.getAddAttributes(true).contains(new Attribute("description", "Virtual description")));
    assertNull(ue.getDeletedEntryAttributes());
    assertNull(ue.getDeletedEntryAttributes(true));
    assertNull(ue.getDeletedEntryVirtualAttributes());
    assertNull(ue.getModifications());
    assertNull(ue.getNewRDN());
    assertFalse(ue.deleteOldRDN());
    assertNull(ue.getNewSuperior());
    assertNotNull(ue.getNewDN());
    assertEquals(new DN(ue.getNewDN()), new DN("uid=test.user,ou=People,dc=example,dc=com"));
    assertNull(ue.getSoftDeleteToDN());
    assertNotNull(ue.getUndeleteFromDN());
    assertNull(ue.getChangeToSoftDeletedEntry());
    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")));
    assertFalse(ue.getKeyEntryAttributes().contains(new Attribute("cn", "Virtual cn")));
    assertNotNull(ue.getKeyEntryAttributes(true));
    assertEquals(ue.getKeyEntryAttributes(true).size(), 1);
    assertTrue(ue.getKeyEntryAttributes(true).contains(new Attribute("cn", "Test User", "Virtual cn")));
    assertNotNull(ue.getKeyEntryVirtualAttributes());
    assertEquals(ue.getKeyEntryVirtualAttributes().size(), 1);
    assertTrue(ue.getKeyEntryVirtualAttributes().contains(new Attribute("cn", "Virtual cn")));
    assertFalse(ue.getKeyEntryVirtualAttributes().contains(new Attribute("cn", "Test User")));
    assertEquals(ue.getNumExcludedUserAttributes(), 2);
    assertEquals(ue.getNumExcludedOperationalAttributes(), 3);
    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("entryUUID"));
    assertNull(ue.getAttributeBeforeChange("uid"));
    assertNull(ue.getAttributeBeforeChange("uid", true));
    assertNotNull(ue.getAttributeAfterChange("uid"));
    assertEquals(ue.getAttributeAfterChange("uid"), new Attribute("uid", "test.user"));
    assertNotNull(ue.getAttributeAfterChange("uid", true));
    assertEquals(ue.getAttributeAfterChange("uid", true), new Attribute("uid", "test.user"));
    assertNotNull(ue.getAttributeAfterChange("cn"));
    assertEquals(ue.getAttributeAfterChange("cn"), new Attribute("cn", "Test User"));
    assertNotNull(ue.getAttributeAfterChange("cn", true));
    assertEquals(ue.getAttributeAfterChange("cn", true), new Attribute("cn", "Test User", "Virtual cn"));
    assertNull(ue.getAttributeAfterChange("missing"));
    assertNull(ue.getAttributeAfterChange("missing", true));
    assertNull(ue.getAttributeAfterChange("description"));
    assertNotNull(ue.getAttributeAfterChange("description", true));
    assertEquals(ue.getAttributeAfterChange("description", true), new Attribute("description", "Virtual description"));
    assertNull(ue.constructPartialEntryBeforeChange());
    assertNull(ue.constructPartialEntryBeforeChange(true));
    assertNotNull(ue.constructPartialEntryAfterChange());
    assertEquals(ue.constructPartialEntryAfterChange(), 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"));
    assertNotNull(ue.constructPartialEntryAfterChange(true));
    assertEquals(ue.constructPartialEntryAfterChange(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: Virtual cn", "description: Virtual description"));
    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) 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 18 with ChangeLogEntry

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

the class GetChangelogBatchExtendedResultTestCase method testServerSideConstructorWithAllElementsAndEntryList.

/**
 * Tests the constructor intended for use on the server side to create an
 * extended result from the components of the result.  All elements of the
 * result will be provided, as well as an entry list.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testServerSideConstructorWithAllElementsAndEntryList() throws Exception {
    final StringBuilder changes = new StringBuilder();
    changes.append("objectClass: top").append(StaticUtils.EOL);
    changes.append("objectClass: domain").append(StaticUtils.EOL);
    changes.append("dc: example").append(StaticUtils.EOL);
    final ChangeLogEntry e = new ChangeLogEntry(new Entry("dn: changeNumber=1,cn=changelog", "objectClass: top", "objectClass: changeLogEntry", "changeNumber: 1", "targetDN: dc=example,dc=com", "changeType: add", "changes:: " + Base64.encode(changes.toString())));
    final String serverID = CryptoHelper.getRandomUUID().toString();
    final ASN1OctetString resumeToken = new ASN1OctetString("foo");
    final ChangelogEntryIntermediateResponse ir = new ChangelogEntryIntermediateResponse(e, serverID, resumeToken, new Control("1.2.3.4"), new Control("5.6.7.8"));
    final List<ChangelogEntryIntermediateResponse> entryList = Arrays.asList(ir);
    GetChangelogBatchExtendedResult r = new GetChangelogBatchExtendedResult(new LDAPResult(1, ResultCode.SUCCESS), 1, new ASN1OctetString("foo"), true, true, "bar");
    r = new GetChangelogBatchExtendedResult(r, entryList);
    assertTrue(r.hasValue());
    assertNotNull(r.getValue());
    assertNotNull(r.getResumeToken());
    assertTrue(Arrays.equals(r.getResumeToken().getValue(), new ASN1OctetString("foo").getValue()));
    assertTrue(r.moreChangesAvailable());
    assertEquals(r.getEstimatedChangesRemaining(), -1);
    assertTrue(r.changesAlreadyPurged());
    assertNotNull(r.getAdditionalInfo());
    assertEquals(r.getAdditionalInfo(), "bar");
    assertEquals(r.getEntryCount(), 1);
    assertNotNull(r.getChangelogEntries());
    assertEquals(r.getChangelogEntries(), entryList);
    assertNotNull(r.getExtendedResultName());
    assertNotNull(r.toString());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Entry(com.unboundid.ldap.sdk.Entry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) Control(com.unboundid.ldap.sdk.Control) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 19 with ChangeLogEntry

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

the class GetChangelogBatchIntermediateResponseListenerTestCase method testHandleChangelogEntry.

/**
 * Provides test coverage for the {@code intermediateResponseReturned} method
 * with a valid changelog entry intermediate response.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testHandleChangelogEntry() throws Exception {
    final StringBuilder changes = new StringBuilder();
    changes.append("objectClass: top").append(StaticUtils.EOL);
    changes.append("objectClass: domain").append(StaticUtils.EOL);
    changes.append("dc: example").append(StaticUtils.EOL);
    final ChangeLogEntry e = new ChangeLogEntry(new Entry("dn: changeNumber=1,cn=changelog", "objectClass: top", "objectClass: changeLogEntry", "changeNumber: 1", "targetDN: dc=example,dc=com", "changeType: add", "changes:: " + Base64.encode(changes.toString())));
    final String serverID = CryptoHelper.getRandomUUID().toString();
    final ASN1OctetString resumeToken = new ASN1OctetString("foo");
    ChangelogEntryIntermediateResponse ir = new ChangelogEntryIntermediateResponse(e, serverID, resumeToken, new Control("1.2.3.4"), new Control("5.6.7.8"));
    ir = new ChangelogEntryIntermediateResponse(ir);
    final TestChangelogEntryListener entryListener = new TestChangelogEntryListener();
    assertEquals(entryListener.getEntryCount(), 0);
    assertEquals(entryListener.getMissingChangesCount(), 0);
    assertEquals(entryListener.getOtherCount(), 0);
    final GetChangelogBatchIntermediateResponseListener l = new GetChangelogBatchIntermediateResponseListener(entryListener);
    assertEquals(l.getEntryCount(), 0);
    l.intermediateResponseReturned(ir);
    assertEquals(l.getEntryCount(), 1);
    assertEquals(entryListener.getEntryCount(), 1);
    assertEquals(entryListener.getMissingChangesCount(), 0);
    assertEquals(entryListener.getOtherCount(), 0);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Entry(com.unboundid.ldap.sdk.Entry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) Control(com.unboundid.ldap.sdk.Control) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 20 with ChangeLogEntry

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

the class GetChangelogBatchExtendedResultTestCase method testServerSideConstructorWithErrorResultAndEntryList.

/**
 * Tests the constructor intended for use on the server side to create an
 * extended result from the components of the result.  The result will
 * represent an error condition and no value should be generated.  However, an
 * entry list will be provided that makes it possible to get a resume token.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testServerSideConstructorWithErrorResultAndEntryList() throws Exception {
    final StringBuilder changes = new StringBuilder();
    changes.append("objectClass: top").append(StaticUtils.EOL);
    changes.append("objectClass: domain").append(StaticUtils.EOL);
    changes.append("dc: example").append(StaticUtils.EOL);
    final ChangeLogEntry e = new ChangeLogEntry(new Entry("dn: changeNumber=1,cn=changelog", "objectClass: top", "objectClass: changeLogEntry", "changeNumber: 1", "targetDN: dc=example,dc=com", "changeType: add", "changes:: " + Base64.encode(changes.toString())));
    final String serverID = CryptoHelper.getRandomUUID().toString();
    final ASN1OctetString resumeToken = new ASN1OctetString("foo");
    final ChangelogEntryIntermediateResponse ir = new ChangelogEntryIntermediateResponse(e, serverID, resumeToken, new Control("1.2.3.4"), new Control("5.6.7.8"));
    final List<ChangelogEntryIntermediateResponse> entryList = Arrays.asList(ir);
    GetChangelogBatchExtendedResult r = new GetChangelogBatchExtendedResult(new LDAPResult(1, ResultCode.OTHER));
    r = new GetChangelogBatchExtendedResult(r, entryList);
    assertFalse(r.hasValue());
    assertNull(r.getValue());
    assertNotNull(r.getResumeToken());
    assertTrue(Arrays.equals(r.getResumeToken().getValue(), new ASN1OctetString("foo").getValue()));
    assertFalse(r.moreChangesAvailable());
    assertFalse(r.changesAlreadyPurged());
    assertNull(r.getAdditionalInfo());
    assertEquals(r.getEntryCount(), 1);
    assertNotNull(r.getChangelogEntries());
    assertEquals(r.getChangelogEntries(), entryList);
    assertNotNull(r.getExtendedResultName());
    assertNotNull(r.toString());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Entry(com.unboundid.ldap.sdk.Entry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) Control(com.unboundid.ldap.sdk.Control) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) 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