### Question:
PlayerServiceImpl implements PlayerService { @Override public Player createPlayer(String username, String password) throws CreatePlayerException { Preconditions.checkNotNull(username, "username"); Preconditions.checkNotNull(password, "password"); if (!ALLOWED_USERNAMES.matcher(username).matches()) { throw new CreatePlayerException(CreatePlayerException.Reason.INVALID_USERNAME); } if (playerDAO.findWithUsername(username).isPresent()) { throw new CreatePlayerException(CreatePlayerException.Reason.DUPLICATE_USERNAME); } UUID id = uuidFactory.create(); String hash = passwordService.hash(password); Player player = new Player(id, username, hash); playerDAO.insert(player); LOGGER.debug("Created player {}", player); Planet planet; try { planet = planetService.createStartPlanet(player); } catch (CreateStartPlanetException e) { switch (e.getReason()) { case UNIVERSE_FULL: throw new CreatePlayerException(CreatePlayerException.Reason.UNIVERSE_FULL, e); default: throw new AssertionError("Unknown reason: " + e.getReason()); } } LOGGER.debug("Created player starting planet at {}", planet); return player; } @Inject  PlayerServiceImpl(UUIDFactory uuidFactory, PlayerDAO playerDAO, PlanetService planetService, PasswordService passwordService); @Override Player createPlayer(String username, String password); @Override Optional<Player> findWithUsername(String username);  }### Answer:
@Test public void testCreatePlayer() throws Exception { UUID id = UUID.randomUUID(); when(uuidFactory.create()).thenReturn(id); Player actual = sut.createPlayer("username", "password"); Player expectedPlayer = new Player(id, "username", "dummy-hash"); assertThat(actual.getId(), is(expectedPlayer.getId())); assertThat(actual.getUsername(), is(expectedPlayer.getUsername())); assertThat(actual.getPassword(), is(expectedPlayer.getPassword())); verify(playerDAO).insert(expectedPlayer); verify(planetService).createStartPlanet(expectedPlayer); }