StringRequestConverterFunction implements RequestConverterFunction { @Override public Object convertRequest( ServiceRequestContext ctx, AggregatedHttpRequest request, Class<?> expectedResultType, @Nullable ParameterizedType expectedParameterizedResultType) throws Exception { if (expectedResultType == String.class || expectedResultType == CharSequence.class) { final Charset charset; final MediaType contentType = request.contentType(); if (contentType != null) { charset = contentType.charset(ArmeriaHttpUtil.HTTP_DEFAULT_CONTENT_CHARSET); } else { charset = ArmeriaHttpUtil.HTTP_DEFAULT_CONTENT_CHARSET; } return request.content(charset); } return RequestConverterFunction.fallthrough(); }  @Override Object convertRequest(
            ServiceRequestContext ctx, AggregatedHttpRequest request, Class<?> expectedResultType,
            @Nullable ParameterizedType expectedParameterizedResultType);  }
@Test void jsonTextToString() throws Exception { when(req.contentType()).thenReturn(MediaType.JSON); when(req.content(ArmeriaHttpUtil.HTTP_DEFAULT_CONTENT_CHARSET)).thenReturn(JSON_TEXT); final Object result = function.convertRequest(ctx, req, String.class, null); assertThat(result).isInstanceOf(String.class); }
@Test void jsonTextToCharSequence() throws Exception { when(req.contentType()).thenReturn(MediaType.JSON); when(req.content(ArmeriaHttpUtil.HTTP_DEFAULT_CONTENT_CHARSET)).thenReturn(JSON_TEXT); final Object result = function.convertRequest(ctx, req, CharSequence.class, null); assertThat(result).isInstanceOf(CharSequence.class); }