### Question:
Segment implements Timestamp, Freezable<Segment>, Sizeable { @Override public Segment clone() { Segment clone = new Segment(); if (getData() != null) { getData().rewind(); clone.setData(getData()); getData().rewind(); } clone.dataId = dataId; clone.dataIds.add(dataId); clone.transmissionIds.addAll(transmissionIds); return clone; } Segment(Short dataId, ByteBuffer data);  Segment(); Short getDataId(); NavigableSet<Short> getDataIds(); NavigableSet<Short> getTransmissionIds(); Short getFirstTransmissionId(); Short getLastTransmissionId(); ByteBuffer getData(); long getNewestSentTime(); void setNewestSentTime(long timeNow); long getAckedTime(); @Override long getTime(); Integer getPacketId(); void setPacketId(Integer packetId); @Override String toString(); static void writeExternalStatic(Segment segment, ObjectOutput out); static Segment readExternalStatic(ObjectInput in); @Override void writeExternal(ObjectOutput out); @Override void readExternal(ObjectInput in); @Override Segment clone(); @Override int getSize(); @Override boolean equals(Object o); @Override int hashCode();  }### Answer:
@Test @Parameters public final void testClone(Short[] refs, String value) throws Exception { Segment original = new Segment(refs[0], serialize(value)); for (Short ref : refs) original.addTransmissionId(ref); Segment clone = original.clone(); assertEquals("Value mismatch.", deserialize(original.getData()), deserialize(clone.getData())); assertEquals("Value mismatch", original.getDataId(), clone.getDataId()); assertArrayEquals("References mismatch", original.getTransmissionIds().toArray(), clone.getTransmissionIds().toArray()); assertNotSame("References have to differ.", Deencapsulation.getField(original, "data"), Deencapsulation.getField(clone, "data")); assertSame("Objects have to be same", Deencapsulation.getField(original, "dataId"), Deencapsulation.getField(clone, "dataId")); assertNotSame("References have to differ.", Deencapsulation.getField(original, "transmissionIds"), Deencapsulation.getField(clone, "transmissionIds")); Deencapsulation.setField(original, "data", serialize("__NEW_DATA__")); Deencapsulation.setField(original, "dataOut", serialize("__NEW_DATA__")); assertEquals("Original value did change", "__NEW_DATA__", deserialize(original.getData())); assertNotEquals("Cloned value did not change", deserialize(original.getData()), deserialize(clone.getData())); Deencapsulation.setField(original, "dataId", Short.MIN_VALUE); assertEquals("Original dataId did change", new Short(Short.MIN_VALUE), original.getDataId()); assertNotEquals("Cloned reference did not change", original.getDataId(), clone.getDataId()); original.addTransmissionId((short) -1); assertEquals("Original reference count did change", refs.length + 1, original.getTransmissionIds().size()); assertTrue("Original reference was added", original.getTransmissionIds().contains((short)-1)); assertEquals("Cloned reference count did not change", refs.length, clone.getTransmissionIds().size()); NavigableSet<Short> sortedRefs = new TreeSet<Short>(Arrays.asList(refs)); assertArrayEquals("Cloned references did not change", sortedRefs.toArray(), clone.getTransmissionIds().toArray()); }