@Test public void testPerformOperation() { Object[] expectedArgs = new Object[0]; Object expectedResource = new Object(); when(operationFactoryMock.createRecordingOperation(expectedResource, "some method")) .thenReturn(operationRecorderMock); when(operationRecorderMock.recordOperation(expectedArgs)).thenReturn(operationExecutorMock); DefaultCompensatingTransactionOperationManager tested = new DefaultCompensatingTransactionOperationManager( operationFactoryMock); tested.performOperation(expectedResource, "some method", expectedArgs); verify(operationExecutorMock).performOperation(); Stack result = tested.getOperationExecutors(); assertThat(result.isEmpty()).isFalse(); assertThat(result.peek()).isSameAs(operationExecutorMock); }
public void performOperation(Object resource, String operation, Object[] args) { CompensatingTransactionOperationRecorder recorder = operationFactory .createRecordingOperation(resource, operation); CompensatingTransactionOperationExecutor executor = recorder .recordOperation(args); executor.performOperation(); operationExecutors.push(executor); }
DefaultCompensatingTransactionOperationManager implements
        CompensatingTransactionOperationManager { public void performOperation(Object resource, String operation, Object[] args) { CompensatingTransactionOperationRecorder recorder = operationFactory .createRecordingOperation(resource, operation); CompensatingTransactionOperationExecutor executor = recorder .recordOperation(args); executor.performOperation(); operationExecutors.push(executor); } }
DefaultCompensatingTransactionOperationManager implements
        CompensatingTransactionOperationManager { public void performOperation(Object resource, String operation, Object[] args) { CompensatingTransactionOperationRecorder recorder = operationFactory .createRecordingOperation(resource, operation); CompensatingTransactionOperationExecutor executor = recorder .recordOperation(args); executor.performOperation(); operationExecutors.push(executor); } DefaultCompensatingTransactionOperationManager(
            CompensatingTransactionOperationFactory operationFactory); }
DefaultCompensatingTransactionOperationManager implements
        CompensatingTransactionOperationManager { public void performOperation(Object resource, String operation, Object[] args) { CompensatingTransactionOperationRecorder recorder = operationFactory .createRecordingOperation(resource, operation); CompensatingTransactionOperationExecutor executor = recorder .recordOperation(args); executor.performOperation(); operationExecutors.push(executor); } DefaultCompensatingTransactionOperationManager(
            CompensatingTransactionOperationFactory operationFactory); void performOperation(Object resource, String operation,
            Object[] args); void rollback(); void commit(); }
DefaultCompensatingTransactionOperationManager implements
        CompensatingTransactionOperationManager { public void performOperation(Object resource, String operation, Object[] args) { CompensatingTransactionOperationRecorder recorder = operationFactory .createRecordingOperation(resource, operation); CompensatingTransactionOperationExecutor executor = recorder .recordOperation(args); executor.performOperation(); operationExecutors.push(executor); } DefaultCompensatingTransactionOperationManager(
            CompensatingTransactionOperationFactory operationFactory); void performOperation(Object resource, String operation,
            Object[] args); void rollback(); void commit();  }