LdapCompensatingTransactionOperationFactory implements CompensatingTransactionOperationFactory { public CompensatingTransactionOperationRecorder createRecordingOperation(Object resource, String operation) { if (ObjectUtils.nullSafeEquals(operation, LdapTransactionUtils.BIND_METHOD_NAME)) { log.debug("Bind operation recorded"); return new BindOperationRecorder(createLdapOperationsInstance((DirContext) resource)); } else if (ObjectUtils.nullSafeEquals(operation, LdapTransactionUtils.REBIND_METHOD_NAME)) { log.debug("Rebind operation recorded"); return new RebindOperationRecorder(createLdapOperationsInstance((DirContext) resource), renamingStrategy); } else if (ObjectUtils.nullSafeEquals(operation, LdapTransactionUtils.RENAME_METHOD_NAME)) { log.debug("Rename operation recorded"); return new RenameOperationRecorder(createLdapOperationsInstance((DirContext) resource)); } else if (ObjectUtils.nullSafeEquals(operation, LdapTransactionUtils.MODIFY_ATTRIBUTES_METHOD_NAME)) { return new ModifyAttributesOperationRecorder(createLdapOperationsInstance((DirContext) resource)); } else if (ObjectUtils.nullSafeEquals(operation, LdapTransactionUtils.UNBIND_METHOD_NAME)) { return new UnbindOperationRecorder(createLdapOperationsInstance((DirContext) resource), renamingStrategy); } log.warn("No suitable CompensatingTransactionOperationRecorder found for method " + operation + ". Operation will not be transacted."); return new NullOperationRecorder(); } LdapCompensatingTransactionOperationFactory(TempEntryRenamingStrategy renamingStrategy); CompensatingTransactionOperationRecorder createRecordingOperation(Object resource, String operation);  }
@Test public void testGetRecordingOperation_Bind() throws Exception { CompensatingTransactionOperationRecorder result = tested .createRecordingOperation(dirContextMock, "bind"); assertThat(result instanceof BindOperationRecorder).isTrue(); BindOperationRecorder bindOperationRecorder = (BindOperationRecorder) result; assertThat(bindOperationRecorder.getLdapOperations()).isSameAs(ldapOperationsMock); }
@Test public void testGetRecordingOperation_Rebind() throws Exception { CompensatingTransactionOperationRecorder result = tested .createRecordingOperation(dirContextMock, "rebind"); assertThat(result instanceof RebindOperationRecorder).isTrue(); RebindOperationRecorder rebindOperationRecorder = (RebindOperationRecorder) result; assertThat(rebindOperationRecorder.getLdapOperations()).isSameAs(ldapOperationsMock); assertThat(rebindOperationRecorder.getRenamingStrategy()).isSameAs(renamingStrategyMock); }
@Test public void testGetRecordingOperation_Rename() throws Exception { CompensatingTransactionOperationRecorder result = tested .createRecordingOperation(dirContextMock, "rename"); assertThat(result instanceof RenameOperationRecorder).isTrue(); RenameOperationRecorder recordingOperation = (RenameOperationRecorder) result; assertThat(recordingOperation.getLdapOperations()).isSameAs(ldapOperationsMock); }
@Test public void testGetRecordingOperation_ModifyAttributes() throws Exception { CompensatingTransactionOperationRecorder result = tested .createRecordingOperation(dirContextMock, "modifyAttributes"); assertThat(result instanceof ModifyAttributesOperationRecorder).isTrue(); ModifyAttributesOperationRecorder recordingOperation = (ModifyAttributesOperationRecorder) result; assertThat(recordingOperation.getLdapOperations()).isSameAs(ldapOperationsMock); }
@Test public void testGetRecordingOperation_Unbind() throws Exception { CompensatingTransactionOperationRecorder result = tested .createRecordingOperation(dirContextMock, "unbind"); assertThat(result instanceof UnbindOperationRecorder).isTrue(); UnbindOperationRecorder recordingOperation = (UnbindOperationRecorder) result; assertThat(recordingOperation.getLdapOperations()).isSameAs(ldapOperationsMock); assertThat(recordingOperation.getRenamingStrategy()).isSameAs(renamingStrategyMock); }