### Question:
CodeVerifierUtil { public static String generateRandomCodeVerifier() { return generateRandomCodeVerifier(new SecureRandom(), DEFAULT_CODE_VERIFIER_ENTROPY); } private  CodeVerifierUtil(); static void checkCodeVerifier(String codeVerifier); static String generateRandomCodeVerifier(); static String generateRandomCodeVerifier(SecureRandom entropySource, int entropyBytes); static String deriveCodeVerifierChallenge(String codeVerifier); static String getCodeVerifierChallengeMethod(); static String generateRandomState(); static final int MIN_CODE_VERIFIER_LENGTH; static final int MAX_CODE_VERIFIER_LENGTH; static final int DEFAULT_CODE_VERIFIER_ENTROPY; static final int MIN_CODE_VERIFIER_ENTROPY; static final int MAX_CODE_VERIFIER_ENTROPY; }### Answer:
@Test public void generateRandomCodeVerifier_nullEntropySource_throwsException() { try { CodeVerifierUtil.generateRandomCodeVerifier( null, CodeVerifierUtil.MIN_CODE_VERIFIER_ENTROPY); fail("expected exception not thrown"); } catch (NullPointerException ex) { assertThat(ex.getMessage()) .isEqualTo("entropySource cannot be null"); } }
@Test public void generateRandomCodeVerifier_tooLittleEntropy_throwsException() { try { CodeVerifierUtil.generateRandomCodeVerifier( new SecureRandom(), CodeVerifierUtil.MIN_CODE_VERIFIER_ENTROPY - 1); fail("expected exception not thrown"); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()) .isEqualTo("entropyBytes is less than the minimum permitted"); } }
@Test public void generateRandomCodeVerifier_tooMuchEntropy_throwsException() { try { CodeVerifierUtil.generateRandomCodeVerifier( new SecureRandom(), CodeVerifierUtil.MAX_CODE_VERIFIER_ENTROPY + 1); fail("expected exception not thrown"); } catch (IllegalArgumentException ex) { assertThat(ex.getMessage()) .isEqualTo("entropyBytes is greater than the maximum permitted"); } }