RemoteDocument implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } RemoteDocument other = (RemoteDocument) obj; if (!Arrays.equals(bytes, other.bytes)) { return false; } if (digestAlgorithm != other.digestAlgorithm) { return false; } if (name == null) { if (other.name != null) { return false; } } else if (!name.equals(other.name)) { return false; } return true; } RemoteDocument();  RemoteDocument(byte[] bytes, String name);  RemoteDocument(byte[] bytes, DigestAlgorithm digestAlgorithm, String name); byte[] getBytes(); void setBytes(byte[] bytes); DigestAlgorithm getDigestAlgorithm(); void setDigestAlgorithm(DigestAlgorithm digestAlgorithm); String getName(); void setName(String name); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testEquals() { RemoteDocument doc1 = new RemoteDocument(new byte[] { 1, 2, 3 }, "bla"); RemoteDocument doc2 = new RemoteDocument(new byte[] { 1, 2, 3 }, "bla"); assertEquals(doc1, doc2); assertNotNull(doc1.toString()); doc2.setDigestAlgorithm(DigestAlgorithm.SHA256); assertNotEquals(doc1, doc2); assertNotNull(doc2.toString()); doc2.setDigestAlgorithm(null); assertEquals(doc1, doc2); doc2.setName("bli"); assertNotEquals(doc1, doc2); doc2.setName("bla"); assertEquals(doc1, doc2); doc2.setBytes(new byte[] { 0, 0, 0 }); assertNotEquals(doc1, doc2); doc2.setBytes(new byte[] { 1, 2, 3 }); assertEquals(doc1, doc2); }