### Question:
CopyVariantOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.COPY); dos.writeLong(to); dos.writeLong(variantSpan.start); dos.writeLong(variantSpan.width); } os.flush(); return os.toByteArray(); } CopyVariantOp(DataInputStream dis);  CopyVariantOp(long to, VariantSpan variantSpan); @Override byte[] encode(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); final long to; final VariantSpan variantSpan; }### Answer:
@Test public void encodeDecode() throws Exception { CopyVariantOp op = new CopyVariantOp(100, new VariantSpan(50, 75)); byte[] data = op.encode(); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(data)); assertEquals(Op.COPY, dis.readByte()); CopyVariantOp decoded = new CopyVariantOp(dis); assertEquals(op, decoded); }