### Question:
KafkaPrincipal implements Principal { @Override public int hashCode() { int result = principalType.hashCode(); result = 31 * result + name.hashCode(); return result; } KafkaPrincipal(String principalType, String name); static KafkaPrincipal fromString(String str); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); @Override String getName(); String getPrincipalType(); static final String SEPARATOR; static final String USER_TYPE; final static KafkaPrincipal ANONYMOUS; }### Answer:
@Test public void testEqualsAndHashCode() { String name = "KafkaUser"; KafkaPrincipal principal1 = new KafkaPrincipal(KafkaPrincipal.USER_TYPE, name); KafkaPrincipal principal2 = new KafkaPrincipal(KafkaPrincipal.USER_TYPE, name); Assert.assertEquals(principal1.hashCode(), principal2.hashCode()); Assert.assertEquals(principal1, principal2); }