### Question:
Validator { public GameType checkGameType(String input) { checkGameName(input, Validator.CANT_BE_NULL); GameType type = gameService.getGame(input); if (type == NullGameType.INSTANCE) { throw new IllegalArgumentException("Game not found: " + input); } return type; } 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 validateCheckGameType() { shouldError("Game name is invalid: 'Null'", () -> validator.checkGameType("Null")); shouldError("Game name is invalid: 'null'", () -> validator.checkGameType(null)); shouldError("Game name is invalid: 'NULL'", () -> validator.checkGameType("NULL")); shouldError("Game name is invalid: 'null'", () -> validator.checkGameType("null")); shouldError("Game name is invalid: ''", () -> validator.checkGameType("")); shouldOk(() -> validator.checkGameType("not-empty")); when(gameService.getGame("valid-game")).thenReturn(mock(GameType.class)); when(gameService.getGame("bad-game")).thenReturn(NullGameType.INSTANCE); shouldOk(() -> validator.checkGameType("valid-game")); shouldError("Game not found: bad-game", () -> validator.checkGameType("bad-game")); }