ByteArrayRequestConverterFunction implements RequestConverterFunction { @Override public Object convertRequest( ServiceRequestContext ctx, AggregatedHttpRequest request, Class<?> expectedResultType, @Nullable ParameterizedType expectedParameterizedResultType) throws Exception { final HttpData content = request.content(); if (expectedResultType == byte[].class) { return content.array(); } if (expectedResultType == HttpData.class) { return content; } return RequestConverterFunction.fallthrough(); }  @Override Object convertRequest(
            ServiceRequestContext ctx, AggregatedHttpRequest request, Class<?> expectedResultType,
            @Nullable ParameterizedType expectedParameterizedResultType);  }
@Test void jsonTextToByteArray() throws Exception { when(req.contentType()).thenReturn(MediaType.JSON); when(req.content()).thenReturn(HttpData.ofUtf8(JSON_TEXT)); final Object result = function.convertRequest(ctx, req, byte[].class, null); assertThat(result).isInstanceOf(byte[].class); }
@Test void jsonTextToHttpData() throws Exception { when(req.contentType()).thenReturn(MediaType.JSON); when(req.content()).thenReturn(HttpData.ofUtf8(JSON_TEXT)); final Object result = function.convertRequest(ctx, req, HttpData.class, null); assertThat(result).isInstanceOf(HttpData.class); }