### Question:
PwnedCredentialsChecker { public boolean isPasswordPwned(final String password) { return pwnedPasswordMetrics.report(() -> isPwned(password)); } PwnedCredentialsChecker(final BloomFilterCheck pwnedFilter,
                                   final int maxPasswordLength,
                                   final PwnedPasswordMetricsReporter pwnedPasswordMetrics); boolean isPasswordPwned(final String password);  }### Answer:
@Test void shouldDetectPwnedPassword() { given(pwnedFilter.test(SAMPLE_PASSWORD)).willReturn(true); final boolean result = pwnedCredentialsChecker.isPasswordPwned(SAMPLE_PASSWORD); assertThat(result).isTrue(); verify(pwnedFilter).test(SAMPLE_PASSWORD); }
@Test void shouldDetectNotPwnedPassword() { given(pwnedFilter.test(SAMPLE_PASSWORD)).willReturn(false); final boolean result = pwnedCredentialsChecker.isPasswordPwned(SAMPLE_PASSWORD); assertThat(result).isFalse(); verify(pwnedFilter).test(SAMPLE_PASSWORD); }
@Test void shouldSkipCheckForMissingPassword() { final boolean result = pwnedCredentialsChecker.isPasswordPwned(null); assertThat(result).isFalse(); verifyNoInteractions(pwnedFilter); }
@Test void shouldSkipCheckForTooLongPassword() { final String tooLongPassword = Strings.repeat("a", MAX_PASSWORD_LENGTH + 1); final boolean result = pwnedCredentialsChecker.isPasswordPwned(tooLongPassword); assertThat(result).isFalse(); verifyNoInteractions(pwnedFilter); }