RebindOperationRecorder implements
        CompensatingTransactionOperationRecorder { public CompensatingTransactionOperationExecutor recordOperation( Object[] args) { if (args == null || args.length != 3) { throw new IllegalArgumentException( "Invalid arguments for bind operation"); } Name dn = LdapTransactionUtils.getFirstArgumentAsName(args); Object object = args[1]; Attributes attributes = null; if (args[2] != null && !(args[2] instanceof Attributes)) { throw new IllegalArgumentException( "Invalid third argument to bind operation"); } else if (args[2] != null) { attributes = (Attributes) args[2]; } Name temporaryName = renamingStrategy.getTemporaryName(dn); return new RebindOperationExecutor(ldapOperations, dn, temporaryName, object, attributes); } RebindOperationRecorder(LdapOperations ldapOperations,
            TempEntryRenamingStrategy renamingStrategy); CompensatingTransactionOperationExecutor recordOperation(
            Object[] args); TempEntryRenamingStrategy getRenamingStrategy();  }
@Test public void testRecordOperation() { final LdapName expectedDn = LdapUtils.newLdapName( "cn=john doe"); final LdapName expectedTempDn = LdapUtils.newLdapName( "cn=john doe"); RebindOperationRecorder tested = new RebindOperationRecorder( ldapOperationsMock, renamingStrategyMock); when(renamingStrategyMock.getTemporaryName(expectedDn)) .thenReturn(expectedTempDn); Object expectedObject = new Object(); BasicAttributes expectedAttributes = new BasicAttributes(); CompensatingTransactionOperationExecutor result = tested .recordOperation(new Object[] { expectedDn, expectedObject, expectedAttributes }); assertThat(result instanceof RebindOperationExecutor).isTrue(); RebindOperationExecutor rollbackOperation = (RebindOperationExecutor) result; assertThat(rollbackOperation.getLdapOperations()).isSameAs(ldapOperationsMock); assertThat(rollbackOperation.getOriginalDn()).isSameAs(expectedDn); assertThat(rollbackOperation.getTemporaryDn()).isSameAs(expectedTempDn); assertThat(rollbackOperation.getOriginalObject()).isSameAs(expectedObject); assertThat(rollbackOperation.getOriginalAttributes()).isSameAs(expectedAttributes); }