Kata #2: Bank Account Service

Objective: This kata is about using mocks as you TDD in the service layer. You should complete coding the kata before restarting it the next time.

You are to write a bank account service that provides the following functionality. You are recommended to add features to the service in this order.

  1. Open a new bank account given an account number. The balance of the new account should be zero. Don't worry about other information like account owner or contact addresses.
  2. Query information about an account, given the account number.
  3. Deposit money to an account, given the amount, account number, and the description of the transaction. The account's balance should be increased by the deposit amount.
  4. Withdraw money from an account, given the amount, account number, and the description of the transaction. The amount should be deducted from the account's balance.
  5. All information about each deposit or withdraw, including its timestamp, should be stored in the DB.
  6. Retrieve a list of transactions that occurred during a period of time, given a start time and an end time.
  7. Retrieve a list of transactions that have occurred since a given time.
  8. Retrieve a list of n most recent transactions.

Notes:

  • The service classes would depend on some class in the data access level, which you have not yet implemented and of which you will use mocks in tests instead of writing one now. Keep in mind that you should not create anything before it is actually needed to run the tests. The business entity classes should be incrementally created on demand, while you're developing the service classes. So should the DAO interfaces.
  • A test's name should be a statement describing the behavior that it verifies. It should not simply be of the form testMethodUnderTest()