### Question:
Validator { public void checkPlayerInRoom(String id, String roomName) { checkRoomName(roomName, CANT_BE_NULL); checkPlayerId(id, CANT_BE_NULL); if (!playerService.get(id).getRoomName().equals(roomName)) { throw new IllegalArgumentException(String.format("Player '%s' is not in room '%s'", id, roomName)); } } Validator(); void checkPlayerId(String input); boolean isReadableName(String input); boolean isNickName(String input); boolean isFullName(String input); void checkPlayerId(String input, boolean canBeNull); boolean isPlayerId(String input, boolean canBeNull); boolean isEmail(String input, boolean canBeNull); void checkEmail(String input, boolean canBeNull); boolean isCode(String input, boolean canBeNull); void checkCode(String input, boolean canBeNull); boolean isEmpty(String input); boolean isGameName(String input, boolean canBeNull); boolean isRoomName(String input, boolean canBeNull); boolean is(String input, boolean canBeNull, Pattern pattern); void checkRoomName(String input, boolean canBeNull); void checkGameName(String input, boolean canBeNull); void checkNotEmpty(String name, String input); GameType checkGameType(String input); void checkMD5(String input); void checkCommand(String input); void checkPlayerCode(String id, String code); void checkNotNull(String name, Object input); void checkPlayerInRoom(String id, String roomName); static final boolean CAN_BE_NULL; static final boolean CANT_BE_NULL; }### Answer:
@Test public void validateCheckPlayerInRoom() { givenPlayer("validPlayerId", "validRoomName"); givenPlayer("otherPlayer", "otherRoomName"); shouldOk(() -> validator.checkPlayerInRoom("validPlayerId", "validRoomName")); shouldError("Player id is invalid: '$bad$'", () -> validator.checkPlayerInRoom("$bad$", "validRoomName")); shouldError("Room name is invalid: '$bad$'", () -> validator.checkPlayerInRoom("validPlayerId", "$bad$")); shouldError("Player 'otherPlayer' is not in room 'validRoomName'", () -> validator.checkPlayerInRoom("otherPlayer", "validRoomName")); }