### Question:
Datastream { @Override public boolean equals(Object object) { if (object == null) { return false; } if (object instanceof Datastream) { Datastream rightHand = (Datastream) object; return name.equals(rightHand.name) && (rightHand.owner == null || owner == null || owner.equals(rightHand.owner)); } if (object instanceof String) { String rightHandString = (String) object; if (rightHandString.equals(this.name)) { return true; } try { Datastream rightHand = new Datastream(rightHandString); return this.equals(rightHand); } catch (IllegalArgumentException e) { } } return false; } Datastream(String owner, String name, Long filesize, String mimetype, String filename, String extension,
            String checksum);  Datastream(String datastream); @Override String toString(); @Override boolean equals(Object object); @Override int hashCode(); String getDatastreamIdentifier(); String getName(); String getOwner(); Long getFilesize(); String getMimetype(); String getExtension(); String getChecksum(); String getFilename(); void setFilename(String filename); void setChecksum(String checksum); void setMimetype(String mimetype); void setExtension(String extension); void setOwner(String owner); void setFilesize(Long filesize);  }### Answer:
@Test public void testDatastreamEqualsString() { String dsName = "data_stream"; Datastream ds = new Datastream("data_stream|image/jpeg|ds.jpg|jpg|0||"); assertTrue(ds.equals(dsName)); }
@Test public void testDatastreamNotEqualsString() { String dsName = "other_ds"; Datastream ds = new Datastream("data_stream|image/jpeg|ds.jpg|jpg|0||"); assertFalse(ds.equals(dsName)); }
@Test public void testDatastreamEqualsFullDSString() { String dsName = "data_stream|image/jpeg|ds.jpg|jpg|0||"; Datastream ds = new Datastream("data_stream|image/jpeg|ds.jpg|jpg|0||"); assertTrue(ds.equals(dsName)); }
@Test public void testDatastreamEqualsDatastream() { Datastream ds1 = new Datastream("data_stream|image/jpeg|ds.jpg|jpg|0||"); Datastream ds2 = new Datastream("data_stream|image/jpeg|ds.jpg|jpg|0||"); assertTrue(ds1.equals(ds2)); }
@Test public void testDatastreamEqualsDatastreamByNameAndOwner() { Datastream ds1 = new Datastream("data_stream|image/jpeg|ds.jpg|jpg|0||owner_id"); Datastream ds2 = new Datastream("data_stream||||||owner_id"); assertTrue(ds1.equals(ds2)); }
@Test public void testDatastreamNotEqualsDatastreamByOwner() { Datastream ds1 = new Datastream("data_stream|image/jpeg|ds.jpg|jpg|0||owner_2"); Datastream ds2 = new Datastream("data_stream|image/jpeg|ds.jpg|jpg|0||owner_1"); assertFalse(ds1.equals(ds2)); }