### Question:
PutOverlayMediaOp extends Op { @Override public byte[] encode() throws IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); try (DataOutputStream dos = new DataOutputStream(os)) { dos.writeByte(Op.PUT_OVERLAY_MEDIA); dos.writeLong(to); dos.writeInt(hash); dos.writeInt(linkTypes.size()); for (Integer i : linkTypes) { dos.writeInt(i); } } os.flush(); return os.toByteArray(); } PutOverlayMediaOp(DataInputStream dis);  PutOverlayMediaOp(long to, int hash, Set<Integer> linkTypes); @Override byte[] encode(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); final int hash; final Set<Integer> linkTypes; final long to; }### Answer:
@Test public void encodeDecode() throws Exception { PutOverlayMediaOp op = new PutOverlayMediaOp(1, 1, Sets.newSet(10, 5)); byte[] data = op.encode(); DataInputStream dis = new DataInputStream(new ByteArrayInputStream(data)); assertEquals(Op.PUT_OVERLAY_MEDIA, dis.readByte()); PutOverlayMediaOp decoded = new PutOverlayMediaOp(dis); assertEquals(op, decoded); }