Playing the game
In this section, we will test-drive the code to play the game. This involves submitting multiple guess attempts to the endpoint until a game-over response is received.
We start by creating an integration test for the new /guess route in our endpoint:
- The first step is to code the Arrange step. Our domain model provides the
assess()method onclass Wordzto assess the score for a guess, along with reporting whether the game is over. To test-drive this, we set up themockWordzstub to return a validGuessResultobject when theassess()method is called:@Test
void partiallyCorrectGuess() {Â Â Â Â var score = new Score("-U---");Â Â Â Â score.assess("GUESS");Â Â Â Â var result = new GuessResult(score, false, false);
    when(mockWordz.assess(eq(player), eq("GUESS")))            .thenReturn(result);
}
- The...