### Question:
ConfidentialString { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((string == null) ? 0 : string.hashCode()); return result; } ConfidentialString(final String string); String getString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj);  }### Answer:
@Test public void shouldHaveEqualHash_withSameStringContent() { final String string1 = randomString(); final String string2 = new String(string1); final int s1HashCode = new ConfidentialString(string1).hashCode(); final int s2HashCode = new ConfidentialString(string2).hashCode(); final boolean isHashEquals = s1HashCode == s2HashCode; assertTrue("ConfidentialStrings with same content should have equal hashCode", isHashEquals); }