public void testReverseModifyAddNewOu() throws LdapException
{
Entry modifiedEntry = buildEntry();
Dn dn = new Dn( "cn=test, ou=system" );
Modification mod = new DefaultModification(
ModificationOperation.ADD_ATTRIBUTE,
new DefaultEntryAttribute( "ou", "BigCompany inc." ) );
LdifEntry reversed = LdifRevertor.reverseModify( dn,
Collections.<Modification>singletonList( mod ), modifiedEntry );
assertNotNull( reversed );
assertEquals( dn.getName(), reversed.getDn().getName() );
assertEquals( ChangeType.Modify, reversed.getChangeType() );
assertNull( reversed.getEntry() );
List<Modification> mods = reversed.getModificationItems();
assertNotNull( mods );
assertEquals( 1, mods.size() );
Modification modif = mods.get( 0 );
assertEquals( ModificationOperation.REMOVE_ATTRIBUTE, modif.getOperation() );
EntryAttribute attr = modif.getAttribute();
assertNotNull( attr );
assertEquals( "ou", attr.getId() );
assertEquals( "BigCompany inc.", attr.getString() );
}