DeserializeStrategyPostJson implements IDeserializeStrategy<FullHttpRequest> { @Override public IObject deserialize(final FullHttpRequest request) throws DeserializationException { ByteBuf content = request.content(); byte[] bytes = new byte[content.capacity()]; content.getBytes(0, bytes); try { return messageMapper.deserialize(bytes); } catch (ResolutionException e) { throw new DeserializationException("Failed to deserialize request. It should be json", e); } } DeserializeStrategyPostJson(final IMessageMapper<byte[]> messageMapper); @Override IObject deserialize(final FullHttpRequest request);  }
@Test public void testDeserializationResult() throws InvalidArgumentException, ResolutionException, URISyntaxException, DeserializationException, SerializeException { mapperStub = mock(IMessageMapper.class); DeserializeStrategyPostJson deserializeStrategy = new DeserializeStrategyPostJson(mapperStub); when(mapperStub.deserialize(any(byte[].class))).thenReturn(new DSObject("{\"hello\": \"world\"}")); IObject iObject = deserializeStrategy.deserialize(new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.POST, "http: String iObjectString = iObject.serialize().toString(); verify(iObjectString.equals("{\"hello\":\"world\"}")); }