/cleancoders_openchat

Exercise for learning outside-in TDD (and a bit of Spring Boot)

Primary LanguageJava

OpenChat kata

This exercise was created by Sandro Mancuso for the excellent video series about Outside-in TDD.

The original source is at https://github.com/sandromancuso/cleancoders_openchat

This version was modified for Spring Boot, and also to make it easier to start for learners.

Instructions

We are about to implement the backend for an online chat application, similar to Twitter.

The APIs are described in the APIs.md document, and also in the integration tests.

The integration tests are all disabled, save one, and that one is failing!

We are aiming for a standard Spring Boot backend design, with

  • A controller for every API
  • A command object for every request, and a corresponding response object
  • A service for every API
  • A set of domain objects that represent domain concepts (e.g., User)
  • A repository that hides persistency issues (can be implemented with a simple Map in memory)
     End 2 End      /-----------\   +------------+   +------------+   +------------+   +------------+
    Integration --->|Spring Boot|-->| Controller |-->| Service    |-->| Repository |-->| DB or Map  |
       Test         \-----------/   +------------+   +------------+   +------------+   +------------+
                                          ^                ^                ^               
                                          |                |                |               
                                      Unit Test         Unit Test        Focused
                                                                       Integration
                                                                          Test

Your job is to:

  1. Read through the integration tests to understand what we're trying to achieve.
  2. Run all integration tests, and verify that the one integration test is failing; observe the error and understand why we are getting that error.
  3. Examine the unit tests; one unit test has been provided to make it easier and faster to start
  4. Run the unit tests; verify that the test is failing, and understand why it is failing
  5. Change the production code to make the unit test pass
  6. Create a unit test for the RegisterNewUserService, and then make it pass
  7. Create a unit test for the UsersRepository, and then make it pass. It's OK to implement it with a simple Map in memory.
  8. Run the integration tests again; fix any remaining integration errors to make it pass.

Next steps:

  • download the web client for this backend, and see it running
  • enable the other test in IT_RegistrationAPI and make it pass
  • enable the other test files and make them pass
  • when in doubt, use the APIs.md document as a reference

How to

Run unit tests

./gradlew test

Run integration tests

./gradlew integrationTest

Start the application

./gradlew bootRun