### Question:
Validator { public void checkCode(String input, boolean canBeNull) { if (!isCode(input, canBeNull)) { throw new IllegalArgumentException(String.format("Player code is invalid: '%s'", input)); } } 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 validateCheckCode() { shouldError("Player code is invalid: 'null'", () -> validator.checkCode(null, CANT_BE_NULL)); shouldOk(() -> validator.checkCode(null, CAN_BE_NULL)); shouldError("Player code is invalid: ''", () -> validator.checkCode("", CANT_BE_NULL)); shouldOk(() -> validator.checkCode("", CAN_BE_NULL)); shouldError("Player code is invalid: 'NuLL'", () -> validator.checkCode("NuLL", CANT_BE_NULL)); shouldOk(() -> validator.checkCode("NuLL", CAN_BE_NULL)); shouldError("Player code is invalid: 'null'", () -> validator.checkCode("null", CANT_BE_NULL)); shouldOk(() -> validator.checkCode("null", CAN_BE_NULL)); shouldError("Player code is invalid: 'NULL'", () -> validator.checkCode("NULL", CANT_BE_NULL)); shouldOk(() -> validator.checkCode("NULL", CAN_BE_NULL)); shouldError("Player code is invalid: '*F(@DF^@(&@DF(@^'", () -> validator.checkCode("*F(@DF^@(&@DF(@^", CANT_BE_NULL)); shouldError("Player code is invalid: 'too large aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'", () -> validator.checkCode("too large aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", CANT_BE_NULL)); shouldOk(() -> validator.checkCode("1", CANT_BE_NULL)); shouldOk(() -> validator.checkCode("0", CAN_BE_NULL)); shouldOk(() -> validator.checkCode("434589345613405760956134056340596345903465", CANT_BE_NULL)); shouldError("Player code is invalid: 'someId'", () -> validator.checkCode("someId", CANT_BE_NULL)); shouldError("Player code is invalid: 'some@email.com'", () -> validator.checkCode("some@email.com", CANT_BE_NULL)); }