@Override
    public int hashCode() {
        int result = principalType != null ? principalType.hashCode() : 0;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        return result;
    }
@Test
    public void testEqualsAndHashCode() {
        String name = "KafkaUser";
        KafkaPrincipal principal1 = new KafkaPrincipal(KafkaPrincipal.USER_TYPE, name);
        KafkaPrincipal principal2 = new KafkaPrincipal(KafkaPrincipal.USER_TYPE, name);

        assertEquals(principal1.hashCode(), principal2.hashCode());
        assertEquals(principal1, principal2);
    }