### Question:
CoapTcpPacketSerializer { public static byte[] serialize(CoapPacket coapPacket) throws CoapException, IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); writeTo(os, coapPacket); return os.toByteArray(); }  static CoapPacket deserialize(InetSocketAddress remoteAddress, InputStream inputStream); static Optional<CoapPacket> deserializeIfEnoughData(InetSocketAddress remoteAddress, InputStream inputStream); static byte[] serialize(CoapPacket coapPacket); static void writeTo(OutputStream os, CoapPacket coapPacket);  }### Answer:
@Test(expected = IllegalStateException.class) public void bothMethodAndCodeUsed() throws CoapException, IOException { CoapPacket cp = new CoapPacket(Method.DELETE, null, "", null); cp.setCode(Code.C202_DELETED); CoapTcpPacketSerializer.serialize(cp); }