### Question:
DigestPasswordCredentials extends PasswordCredentials { @Override public boolean verify(final Object credentials) throws UnsupportedCredentialException { if (credentials instanceof String) { final byte[] bytes = ((String) credentials).getBytes(StandardCharsets.UTF_8); return digestAndVerify(bytes); } if (credentials instanceof char[]) { final byte[] bytes = new String((char[])credentials).getBytes(StandardCharsets.UTF_8); return digestAndVerify(bytes); } if (credentials instanceof DigestPasswordCredentials) { return this.equals(credentials); } if (credentials instanceof PasswordCredentials) { final byte[] bytes = ((PasswordCredentials) credentials).password.getBytes(StandardCharsets.UTF_8); return digestAndVerify(bytes); } throw new UnsupportedCredentialException("Can't validate credentials, type is unsupported '" + credentials.getClass()+ "'"); } DigestPasswordCredentials(final String algorithm, final String password); @Override boolean equals(Object o); @Override int hashCode(); @Override boolean verify(final Object credentials);  }### Answer:
@Test public void testGivenString() { boolean verified = credentials.verify("password"); Assertions.assertTrue(verified); }
@Test public void testGivenPlainPassword() { boolean verified = credentials.verify(new PlainPasswordCredentials("password")); Assertions.assertTrue(verified); }
@Test public void testGivenPlainCharArray() { boolean verified = credentials.verify("password".toCharArray()); Assertions.assertTrue(verified); }