### Question:
Credential { public static Credential from(String username, String password) { return new Credential(username, password); } private  Credential(String username, String password); static Credential from(String username, String password); String getUsername(); String getPassword(); boolean isOAuth2RefreshToken(); @Override boolean equals(Object other); @Override int hashCode(); @Override String toString(); static final String OAUTH2_TOKEN_USER_NAME; }### Answer:
@Test public void testCredentialsHash() { Credential credentialA1 = Credential.from("username", "password"); Credential credentialA2 = Credential.from("username", "password"); Credential credentialB1 = Credential.from("", ""); Credential credentialB2 = Credential.from("", ""); Assert.assertEquals(credentialA1, credentialA2); Assert.assertEquals(credentialB1, credentialB2); Assert.assertNotEquals(credentialA1, credentialB1); Assert.assertNotEquals(credentialA1, credentialB2); Set<Credential> credentialSet = new HashSet<>(Arrays.asList(credentialA1, credentialA2, credentialB1, credentialB2)); Assert.assertEquals(new HashSet<>(Arrays.asList(credentialA2, credentialB1)), credentialSet); }