### Question:
ConfidentialString { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final ConfidentialString other = (ConfidentialString) obj; if (string == null) { if (other.string != null) { return false; } } else if (!string.equals(other.string)) { return false; } return true; } ConfidentialString(final String string); String getString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj);  }### Answer:
@Test public void shouldBeEqual_withSameStringContent() { final String string1 = randomString(); final String string2 = new String(string1); final ConfidentialString s1 = new ConfidentialString(string1); final ConfidentialString s2 = new ConfidentialString(string2); final boolean isEquals = s1.equals(s2); assertTrue("ConfidentialStrings with same content should be equal", isEquals); }
@Test public void shouldNotBeEqual_withDifferentStringContent() { final String string1 = randomString(); final String string2 = randomString(1 + string1.length()); final ConfidentialString s1 = new ConfidentialString(string1); final ConfidentialString s2 = new ConfidentialString(string2); final boolean isEquals = s1.equals(s2); assertFalse("ConfidentialStrings with different content should not be equal", isEquals); }