MessageToBytesMapper implements IMessageMapper<byte[]> { @Override public IObject deserialize(final byte[] serializedInput) throws ResolutionException { if (serializedInput.length == 0) { return IOC.resolve(Keys.getOrAdd("EmptyIObject")); } String string = new String(serializedInput); string = string.substring(string.indexOf('{'), string.lastIndexOf('}') + 1); return IOC.resolve(Keys.getOrAdd("info.smart_tools.smartactors.iobject.iobject.IObject"), string); }  @Override IObject deserialize(final byte[] serializedInput); @Override byte[] serialize(final IObject message);  }
@Test public void messageToBytesMapperShouldReturnEmptyIObject_WhenByteArrayOnDeserializationIsEmpty() throws ResolutionException { MessageToBytesMapper mapper = new MessageToBytesMapper(); IObject iObject = mapper.deserialize(new byte[0]); verify(!iObject.iterator().hasNext()); }