### Question:
ObjectSerDe implements Serializer<Object>, Deserializer<Object> { @Override public Object deserialize(byte[] input) throws DeserializationException, IOException { if (input == null || input.length == 0) { return null; } try (final ByteArrayInputStream in = new ByteArrayInputStream(input); final ObjectInputStream objIn = new ObjectInputStream(in)) { return objIn.readObject(); } catch (ClassNotFoundException e) { throw new DeserializationException("Could not deserialize object due to ClassNotFoundException", e); } }  @Override Object deserialize(byte[] input); @Override void serialize(Object value, OutputStream output);  }### Answer:
@Test public void testDeserializeSuccessful() throws IOException { final ObjectSerDe serDe = new ObjectSerDe(); final String myObject = "myObject"; final ByteArrayOutputStream bOut = new ByteArrayOutputStream(); final ObjectOutputStream out = new ObjectOutputStream(bOut); out.writeObject(myObject); byte[] myObjectBytes = bOut.toByteArray(); Assert.assertNotNull(myObjectBytes); Assert.assertTrue(myObjectBytes.length > 0); final Object deserialized = serDe.deserialize(myObjectBytes); Assert.assertTrue(deserialized instanceof String); Assert.assertEquals(myObject, deserialized); }
@Test public void testDeserializeNull() throws IOException { final ObjectSerDe serDe = new ObjectSerDe(); final Object deserialized = serDe.deserialize(null); Assert.assertNull(deserialized); }