use of com.unboundid.ldif.LDIFDeleteChangeRecord in project ldapsdk by pingidentity.
the class ChangeLogEntryTestCase method testGetNewDN.
/**
* Provides test coverage for the {@code getNewDN} method with various types
* of changes.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testGetNewDN() throws Exception {
// For add and modify operations, the new DN should always be the same as
// the target DN.
ChangeLogEntry e = ChangeLogEntry.constructChangeLogEntry(1L, new LDIFAddChangeRecord(new Entry("dn: dc=example,dc=com", "objectClass: top", "objectClass: domain", "dc: example")));
assertEquals(new DN(e.getNewDN()), new DN("dc=example,dc=com"));
e = ChangeLogEntry.constructChangeLogEntry(2L, new LDIFModifyChangeRecord("dc=example,dc=com", new Modification(ModificationType.REPLACE, "description", "foo")));
assertEquals(new DN(e.getNewDN()), new DN("dc=example,dc=com"));
// For delete operations, the new DN should always be null.
e = ChangeLogEntry.constructChangeLogEntry(3L, new LDIFDeleteChangeRecord("dc=example,dc=com"));
assertNull(e.getNewDN());
// For modify DN operations, then the new DN will depend on whether or not
// there's a new superior DN.
e = ChangeLogEntry.constructChangeLogEntry(4L, new LDIFModifyDNChangeRecord("ou=People,dc=example,dc=com", "ou=Users", true, null));
assertEquals(new DN(e.getNewDN()), new DN("ou=Users,dc=example,dc=com"));
e = ChangeLogEntry.constructChangeLogEntry(5L, new LDIFModifyDNChangeRecord("ou=People,dc=example,dc=com", "ou=Users", true, "o=example.com"));
assertEquals(new DN(e.getNewDN()), new DN("ou=Users,o=example.com"));
e = ChangeLogEntry.constructChangeLogEntry(6L, new LDIFModifyDNChangeRecord("o=example.com", "o=example.net", true, null));
assertEquals(new DN(e.getNewDN()), new DN("o=example.net"));
}
use of com.unboundid.ldif.LDIFDeleteChangeRecord in project ldapsdk by pingidentity.
the class DebugTestCase method testDebugLDIFRead4EnabledOnlyLDIF.
/**
* Tests the fourth {@code debugLDIFRead} method with the debugger enabled
* and a debug type set that includes only the LDIF type.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDebugLDIFRead4EnabledOnlyLDIF() throws Exception {
Debug.setEnabled(true, EnumSet.of(DebugType.LDIF));
testLogHandler.resetMessageCount();
assertTrue(Debug.debugEnabled(DebugType.LDIF));
Debug.debugLDIFRead(Level.FINEST, new LDIFDeleteChangeRecord("dc=example,dc=com"));
assertTrue(testLogHandler.getMessageCount() >= 1);
}
use of com.unboundid.ldif.LDIFDeleteChangeRecord in project ldapsdk by pingidentity.
the class DebugTestCase method testDebugLDIFRead2EnabledIncludeLDIF.
/**
* Tests the second {@code debugLDIFRead} method with the debugger enabled
* and a debug type set that includes the LDIF type among others.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDebugLDIFRead2EnabledIncludeLDIF() throws Exception {
Debug.setEnabled(true, EnumSet.of(DebugType.LDIF, DebugType.OTHER));
testLogHandler.resetMessageCount();
assertTrue(Debug.debugEnabled(DebugType.LDIF));
Debug.debugLDIFRead(new LDIFDeleteChangeRecord("dc=example,dc=com"));
assertTrue(testLogHandler.getMessageCount() >= 1);
}
use of com.unboundid.ldif.LDIFDeleteChangeRecord 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.ldif.LDIFDeleteChangeRecord 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);
}
Aggregations