use of com.unboundid.ldap.sdk.ChangeLogEntry in project ldapsdk by pingidentity.
the class InMemoryDirectoryServerChangeLogTestCase method testLDIFExportWithChangelog.
/**
* Tests the LDIF export behavior when a changelog is enabled.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testLDIFExportWithChangelog() throws Exception {
// Create a directory server instance with a changelog enabled.
final InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig("dc=example,dc=com");
config.setMaxChangeLogEntries(10);
final InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
// Add some entries to the server and verify that changelog records are
// properly created for them.
ds.addEntries(generateDomainEntry("example", "dc=com"), generateOrgUnitEntry("People", "dc=example,dc=com"), generateUserEntry("test.user", "ou=People,dc=example,dc=com", "Tets", "User", "password"));
Entry changeLogEntry = ds.getEntry("changeNumber=1,cn=changelog", "*", "+");
assertNotNull(changeLogEntry);
changeLogEntry = ds.getEntry("changeNumber=2,cn=changelog", "*", "+");
assertNotNull(changeLogEntry);
changeLogEntry = ds.getEntry("changeNumber=3,cn=changelog", "*", "+");
assertNotNull(changeLogEntry);
changeLogEntry = ds.getEntry("changeNumber=4,cn=changelog", "*", "+");
assertNull(changeLogEntry);
// Write the contents of the server to LDIF, excluding changelog content,
// as well as generated operational attributes. Only three entries should
// be written.
final File userOnlyPath = createTempFile();
assertEquals(ds.exportToLDIF(userOnlyPath.getAbsolutePath(), true, true), 3);
// Read back the entries and verify they are the ones we expect.
LDIFReader ldifReader = new LDIFReader(userOnlyPath);
while (true) {
final Entry e = ldifReader.readEntry();
if (e == null) {
break;
}
assertTrue(e.getParsedDN().isDescendantOf("dc=example,dc=com", true));
assertFalse(e.getParsedDN().isDescendantOf("cn=changelog", true));
assertFalse(e.hasAttribute("entryDN"));
assertFalse(e.hasAttribute("entryUUID"));
assertFalse(e.hasAttribute("creatorsName"));
assertFalse(e.hasAttribute("createTimestamp"));
assertFalse(e.hasAttribute("modifiersName"));
assertFalse(e.hasAttribute("modifyTimestamp"));
assertFalse(e.hasAttribute("subschemaSubentry"));
}
ldifReader.close();
// Write a second LDIF file, this time including the changelog content and
// generated operational attributes.
final File genDataPath = createTempFile();
assertEquals(ds.exportToLDIF(genDataPath.getAbsolutePath(), false, false), 7);
// Read back the entries and verify they are the ones we expect.
ldifReader = new LDIFReader(genDataPath);
boolean changeLogFound = false;
boolean userFound = false;
while (true) {
final Entry e = ldifReader.readEntry();
if (e == null) {
break;
}
if (e.getParsedDN().isDescendantOf("dc=example,dc=com", true)) {
userFound = true;
} else if (e.getParsedDN().isDescendantOf("cn=changelog", true)) {
changeLogFound = true;
} else {
fail("Unexpected entry '" + e.getDN() + "' found in export.");
}
assertTrue(e.hasAttribute("entryDN"), e.toLDIFString());
assertTrue(e.hasAttribute("entryUUID"), e.toLDIFString());
assertTrue(e.hasAttribute("creatorsName"), e.toLDIFString());
assertTrue(e.hasAttribute("createTimestamp"), e.toLDIFString());
assertTrue(e.hasAttribute("modifiersName"), e.toLDIFString());
assertTrue(e.hasAttribute("modifyTimestamp"), e.toLDIFString());
assertTrue(e.hasAttribute("subschemaSubentry"), e.toLDIFString());
}
assertTrue(userFound);
assertTrue(changeLogFound);
ldifReader.close();
}
use of com.unboundid.ldap.sdk.ChangeLogEntry in project ldapsdk by pingidentity.
the class UnboundIDChangeLogEntryTestCase method testExtendedModifyChangeLogEntryNoExceededValues.
/**
* Provides coverage for cases in which an UnboundID changelog entry is
* created for a modify operation without an extended set of content that
* does not have any attributes with an exceeded value count.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testExtendedModifyChangeLogEntryNoExceededValues() throws Exception {
final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(4L, new LDIFModifyChangeRecord("uid=test.user,ou=People,dc=example,dc=com", new Modification(ModificationType.REPLACE, "description", "bar"), new Modification(ModificationType.ADD, "cn", "User, Test"), new Modification(ModificationType.DELETE, "mail")));
assertNotNull(e);
// Construct before values for the description, cn and mail attributes.
final StringBuilder beforeBuffer = new StringBuilder();
beforeBuffer.append("description: foo");
beforeBuffer.append(StaticUtils.EOL);
beforeBuffer.append("cn: Test User");
beforeBuffer.append(StaticUtils.EOL);
beforeBuffer.append("mail: test.user@example.com");
beforeBuffer.append(StaticUtils.EOL);
// Construct virtual before values for the description and cn attributes.
final StringBuilder virtualBeforeBuffer = new StringBuilder();
virtualBeforeBuffer.append("description: Virtual description");
virtualBeforeBuffer.append(StaticUtils.EOL);
virtualBeforeBuffer.append("cn: Virtual cn");
virtualBeforeBuffer.append(StaticUtils.EOL);
// Construct after values for the description and cn attributes.
final StringBuilder afterBuffer = new StringBuilder();
afterBuffer.append("description: bar");
afterBuffer.append(StaticUtils.EOL);
afterBuffer.append("cn: Test User");
afterBuffer.append(StaticUtils.EOL);
afterBuffer.append("cn: User, Test");
afterBuffer.append(StaticUtils.EOL);
// Construct virtual after values for the description and cn attributes.
final StringBuilder virtualAfterBuffer = new StringBuilder();
virtualAfterBuffer.append("description: Virtual description");
virtualAfterBuffer.append(StaticUtils.EOL);
virtualAfterBuffer.append("cn: Virtual cn");
virtualAfterBuffer.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("ds-changelog-before-values", beforeBuffer.toString());
extendedEntry.addAttribute("ds-changelog-before-virtual-values", virtualBeforeBuffer.toString());
extendedEntry.addAttribute("ds-changelog-after-values", afterBuffer.toString());
extendedEntry.addAttribute("ds-changelog-after-virtual-values", virtualAfterBuffer.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", "1");
extendedEntry.addAttribute("ds-changelog-num-excluded-operational-attributes", "2");
extendedEntry.addAttribute("ds-changelog-excluded-user-attribute", "userPassword");
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-change-to-soft-deleted-entry", "false");
extendedEntry.addAttribute("ds-changelog-target-attribute", "description", "cn", "mail");
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.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(), 3);
assertTrue(ue.getModifications().contains(new Modification(ModificationType.REPLACE, "description", "bar")));
assertTrue(ue.getModifications().contains(new Modification(ModificationType.ADD, "cn", "User, Test")));
assertTrue(ue.getModifications().contains(new Modification(ModificationType.DELETE, "mail")));
assertNull(ue.getNewRDN());
assertFalse(ue.deleteOldRDN());
assertNull(ue.getNewSuperior());
assertNull(ue.getSoftDeleteToDN());
assertNull(ue.getUndeleteFromDN());
assertNotNull(ue.getChangeToSoftDeletedEntry());
assertFalse(ue.getChangeToSoftDeletedEntry());
assertNotNull(ue.getNewDN());
assertEquals(new DN(ue.getNewDN()), new DN("uid=test.user,ou=People,dc=example,dc=com"));
assertNotNull(ue.getUpdatedAttributesBeforeChange());
assertEquals(ue.getUpdatedAttributesBeforeChange().size(), 3);
assertTrue(ue.getUpdatedAttributesBeforeChange().contains(new Attribute("description", "foo")));
assertTrue(ue.getUpdatedAttributesBeforeChange().contains(new Attribute("cn", "Test User")));
assertTrue(ue.getUpdatedAttributesBeforeChange().contains(new Attribute("mail", "test.user@example.com")));
assertNotNull(ue.getUpdatedAttributesBeforeChange(true));
assertEquals(ue.getUpdatedAttributesBeforeChange(true).size(), 3);
assertTrue(ue.getUpdatedAttributesBeforeChange(true).contains(new Attribute("description", "foo", "Virtual description")));
assertTrue(ue.getUpdatedAttributesBeforeChange(true).contains(new Attribute("cn", "Test User", "Virtual cn")));
assertTrue(ue.getUpdatedAttributesBeforeChange(true).contains(new Attribute("mail", "test.user@example.com")));
assertNotNull(ue.getUpdatedVirtualAttributesBeforeChange());
assertEquals(ue.getUpdatedVirtualAttributesBeforeChange().size(), 2);
assertTrue(ue.getUpdatedVirtualAttributesBeforeChange().contains(new Attribute("description", "Virtual description")));
assertTrue(ue.getUpdatedVirtualAttributesBeforeChange().contains(new Attribute("cn", "Virtual cn")));
assertNotNull(ue.getUpdatedAttributesAfterChange());
assertEquals(ue.getUpdatedAttributesAfterChange().size(), 2);
assertTrue(ue.getUpdatedAttributesAfterChange().contains(new Attribute("description", "bar")));
assertTrue(ue.getUpdatedAttributesAfterChange().contains(new Attribute("cn", "Test User", "User, Test")));
assertNotNull(ue.getUpdatedAttributesAfterChange(true));
assertEquals(ue.getUpdatedAttributesAfterChange(true).size(), 2);
assertTrue(ue.getUpdatedAttributesAfterChange(true).contains(new Attribute("description", "bar", "Virtual description")));
assertTrue(ue.getUpdatedAttributesAfterChange(true).contains(new Attribute("cn", "Test User", "User, Test", "Virtual cn")));
assertNotNull(ue.getUpdatedVirtualAttributesAfterChange());
assertEquals(ue.getUpdatedVirtualAttributesAfterChange().size(), 2);
assertTrue(ue.getUpdatedVirtualAttributesAfterChange().contains(new Attribute("description", "Virtual description")));
assertTrue(ue.getUpdatedVirtualAttributesAfterChange().contains(new Attribute("cn", "Virtual cn")));
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(), 1);
assertEquals(ue.getNumExcludedOperationalAttributes(), 2);
assertNotNull(ue.getExcludedUserAttributeNames());
assertFalse(ue.getExcludedUserAttributeNames().isEmpty());
assertTrue(ue.getExcludedUserAttributeNames().contains("userPassword"));
assertNotNull(ue.getExcludedOperationalAttributeNames());
assertFalse(ue.getExcludedOperationalAttributeNames().isEmpty());
assertTrue(ue.getExcludedOperationalAttributeNames().contains("modifiersName"));
assertTrue(ue.getExcludedOperationalAttributeNames().contains("modifyTimestamp"));
assertNull(ue.getAttributeBeforeChange("uid"));
assertNull(ue.getAttributeBeforeChange("uid", true));
assertNotNull(ue.getAttributeBeforeChange("description"));
assertEquals(ue.getAttributeBeforeChange("description"), new Attribute("description", "foo"));
assertNotNull(ue.getAttributeBeforeChange("description", true));
assertEquals(ue.getAttributeBeforeChange("description", true), new Attribute("description", "foo", "Virtual description"));
assertNotNull(ue.getAttributeBeforeChange("cn"));
assertEquals(ue.getAttributeBeforeChange("cn"), new Attribute("cn", "Test User"));
assertNotNull(ue.getAttributeBeforeChange("cn", true));
assertEquals(ue.getAttributeBeforeChange("cn", true), new Attribute("cn", "Test User", "Virtual cn"));
assertNotNull(ue.getAttributeBeforeChange("mail"));
assertEquals(ue.getAttributeBeforeChange("mail"), new Attribute("mail", "test.user@example.com"));
assertNotNull(ue.getAttributeBeforeChange("mail", true));
assertEquals(ue.getAttributeBeforeChange("mail", true), new Attribute("mail", "test.user@example.com"));
assertNull(ue.getAttributeAfterChange("uid"));
assertNull(ue.getAttributeAfterChange("uid", true));
assertNull(ue.getAttributeAfterChange("mail"));
assertNull(ue.getAttributeAfterChange("mail", true));
assertNotNull(ue.getAttributeAfterChange("description"));
assertEquals(ue.getAttributeAfterChange("description"), new Attribute("description", "bar"));
assertNotNull(ue.getAttributeAfterChange("description", true));
assertEquals(ue.getAttributeAfterChange("description", true), new Attribute("description", "bar", "Virtual description"));
assertNotNull(ue.getAttributeAfterChange("cn"));
assertEquals(ue.getAttributeAfterChange("cn"), new Attribute("cn", "Test User", "User, Test"));
assertNotNull(ue.getAttributeAfterChange("cn", true));
assertEquals(ue.getAttributeAfterChange("cn", true), new Attribute("cn", "Test User", "User, Test", "Virtual cn"));
assertNotNull(ue.constructPartialEntryBeforeChange());
assertEquals(ue.constructPartialEntryBeforeChange(), new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "description: foo", "cn: Test User", "mail: test.user@example.com"));
assertNotNull(ue.constructPartialEntryBeforeChange(true));
assertEquals(ue.constructPartialEntryBeforeChange(true), new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "description: foo", "description: Virtual description", "cn: Test User", "cn: Virtual cn", "mail: test.user@example.com"));
assertNotNull(ue.constructPartialEntryAfterChange());
assertEquals(ue.constructPartialEntryAfterChange(), new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "description: bar", "cn: Test User", "cn: User, Test"));
assertNotNull(ue.constructPartialEntryAfterChange(true));
assertEquals(ue.constructPartialEntryAfterChange(true), new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "description: bar", "description: Virtual description", "cn: Test User", "cn: User, 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(), 3);
assertNotNull(ue.getNotificationDestinationEntryUUIDs());
assertFalse(ue.getNotificationDestinationEntryUUIDs().isEmpty());
assertEquals(ue.getNotificationDestinationEntryUUIDs().size(), 2);
assertNotNull(ue.getNotificationProperties());
assertFalse(ue.getNotificationProperties().isEmpty());
assertEquals(ue.getNotificationProperties().size(), 3);
}
use of com.unboundid.ldap.sdk.ChangeLogEntry in project ldapsdk by pingidentity.
the class UnboundIDChangeLogEntryTestCase method testBasicModifyDNChangeLogEntry.
/**
* Provides coverage for cases in which an UnboundID changelog entry is
* created for a modify DN operation without any UnboundID-specific content.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testBasicModifyDNChangeLogEntry() throws Exception {
final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(4L, new LDIFModifyDNChangeRecord("uid=test.user,ou=People,dc=example,dc=com", "cn=Test User", false, null));
assertNotNull(e);
final UnboundIDChangeLogEntry ue = new UnboundIDChangeLogEntry(e);
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.MODIFY_DN);
assertNull(ue.getAddAttributes());
assertNull(ue.getDeletedEntryAttributes());
assertNull(ue.getModifications());
assertNotNull(ue.getNewRDN());
assertEquals(new RDN(ue.getNewRDN()), new RDN("cn=Test User"));
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 User,ou=People,dc=example,dc=com"));
assertNotNull(ue.getUpdatedAttributesBeforeChange());
assertTrue(ue.getUpdatedAttributesBeforeChange().isEmpty());
assertNotNull(ue.getUpdatedAttributesAfterChange());
assertTrue(ue.getUpdatedAttributesAfterChange().isEmpty());
assertNotNull(ue.getAttributesThatExceededMaxValuesCount());
assertTrue(ue.getAttributesThatExceededMaxValuesCount().isEmpty());
assertNotNull(ue.getKeyEntryAttributes());
assertTrue(ue.getKeyEntryAttributes().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("uid"));
assertNull(ue.getAttributeBeforeChange("cn"));
assertNull(ue.getAttributeBeforeChange("description"));
assertNull(ue.getAttributeAfterChange("uid"));
assertNull(ue.getAttributeAfterChange("cn"));
assertNull(ue.getAttributeAfterChange("description"));
assertNotNull(ue.constructPartialEntryBeforeChange());
assertEquals(ue.constructPartialEntryBeforeChange(), new Entry("uid=test.user,ou=People,dc=example,dc=com"));
assertNotNull(ue.constructPartialEntryAfterChange());
assertEquals(ue.constructPartialEntryAfterChange(), new Entry("cn=Test User,ou=People,dc=example,dc=com"));
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());
}
use of com.unboundid.ldap.sdk.ChangeLogEntry in project ldapsdk by pingidentity.
the class UnboundIDChangeLogEntryTestCase method testBasicDeleteChangeLogEntry.
/**
* Provides coverage for cases in which an UnboundID changelog entry is
* created for a delete operation without any UnboundID-specific content.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testBasicDeleteChangeLogEntry() throws Exception {
final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(2L, new LDIFDeleteChangeRecord("dc=example,dc=com"));
assertNotNull(e);
final UnboundIDChangeLogEntry ue = new UnboundIDChangeLogEntry(e);
assertNotNull(ue);
assertEquals(ue.getChangeNumber(), 2L);
assertNotNull(ue.getTargetDN());
assertEquals(new DN(ue.getTargetDN()), new DN("dc=example,dc=com"));
assertNotNull(ue.getChangeType());
assertEquals(ue.getChangeType(), ChangeType.DELETE);
assertNull(ue.getAddAttributes());
assertNull(ue.getAddAttributes(true));
assertNull(ue.getAddVirtualAttributes());
assertNull(ue.getDeletedEntryAttributes());
assertNull(ue.getDeletedEntryAttributes(true));
assertNotNull(ue.getDeletedEntryVirtualAttributes());
assertTrue(ue.getDeletedEntryVirtualAttributes().isEmpty());
assertNull(ue.getModifications());
assertNull(ue.getNewRDN());
assertFalse(ue.deleteOldRDN());
assertNull(ue.getNewSuperior());
assertNull(ue.getSoftDeleteToDN());
assertNull(ue.getUndeleteFromDN());
assertNull(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());
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));
assertNull(ue.getAttributeAfterChange("dc"));
assertNull(ue.getAttributeAfterChange("dc", true));
assertNotNull(ue.constructPartialEntryBeforeChange());
assertEquals(ue.constructPartialEntryBeforeChange(), new Entry("dc=example,dc=com"));
assertNotNull(ue.constructPartialEntryBeforeChange(true));
assertEquals(ue.constructPartialEntryBeforeChange(true), new Entry("dc=example,dc=com"));
assertNull(ue.constructPartialEntryAfterChange());
assertNull(ue.constructPartialEntryAfterChange(true));
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());
}
use of com.unboundid.ldap.sdk.ChangeLogEntry in project ldapsdk by pingidentity.
the class UnboundIDChangeLogEntryTestCase method testBasicModifyChangeLogEntry.
/**
* Provides coverage for cases in which an UnboundID changelog entry is
* created for a modify operation without any UnboundID-specific content.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testBasicModifyChangeLogEntry() throws Exception {
final ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(4L, new LDIFModifyChangeRecord("uid=test.user,ou=People,dc=example,dc=com", new Modification(ModificationType.REPLACE, "description", "foo")));
assertNotNull(e);
final UnboundIDChangeLogEntry ue = new UnboundIDChangeLogEntry(e);
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.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.REPLACE, "description", "foo")));
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("uid=test.user,ou=People,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("uid"));
assertNull(ue.getAttributeBeforeChange("uid", true));
assertNull(ue.getAttributeBeforeChange("description"));
assertNull(ue.getAttributeBeforeChange("description", true));
assertNull(ue.getAttributeAfterChange("uid"));
assertNull(ue.getAttributeAfterChange("uid", true));
assertNotNull(ue.getAttributeAfterChange("description"));
assertEquals(ue.getAttributeAfterChange("description"), new Attribute("description", "foo"));
assertNotNull(ue.getAttributeAfterChange("description", true));
assertEquals(ue.getAttributeAfterChange("description", true), new Attribute("description", "foo"));
assertNotNull(ue.constructPartialEntryBeforeChange());
assertEquals(ue.constructPartialEntryBeforeChange(), new Entry("uid=test.user,ou=People,dc=example,dc=com"));
assertNotNull(ue.constructPartialEntryBeforeChange(true));
assertEquals(ue.constructPartialEntryBeforeChange(true), new Entry("uid=test.user,ou=People,dc=example,dc=com"));
assertNotNull(ue.constructPartialEntryAfterChange());
assertEquals(ue.constructPartialEntryAfterChange(), new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "description: foo"));
assertNotNull(ue.constructPartialEntryAfterChange(true));
assertEquals(ue.constructPartialEntryAfterChange(true), new Entry("dn: uid=test.user,ou=People,dc=example,dc=com", "description: foo"));
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());
}
Aggregations