0

我有这个代码:

AsyncRestTemplate asyncRestTemplate = new AsyncRestTemplate();
asyncRestTemplate.setMessageConverters(new ArrayList<HttpMessageConverter<?>>() {{
    add(new ByteArrayHttpMessageConverter());
    add(new MappingJackson2HttpMessageConverter(mapper));
    add(new StringHttpMessageConverter(Charset.forName("UTF-8")));
}});

ListenableFuture<ResponseEntity<byte[]>> f = asyncRestTemplate.exchange(
        templateUrlAndParams.getUrl(),
        HttpMethod.POST,
        new HttpEntity<>(reportScope, new HttpHeaders() {{
            add(HEADER_AUTHORIZATION, authToken);
            add(HEADER_ACCEPT, settings.getMediaType());
            add(HEADER_ACCEPT_LANGUAGE, DEFAULT_ACCEPT_LANGUAGE);
        }}),
        byte[].class, templateUrlAndParams.getQueryParams());

return FutureUtils.transformError(f, (ex)->chainSourceHttpException(ex, pathToInthinc, log));

其他人需要创建我正在调用的端点。但请记住,我需要添加一个“模拟响应”,并ResponseEntity<byte[]> 尝试覆盖响应,但仍然无法使其正常工作。知道我能做什么吗?或者如何发送虚假回复?

4

0 回答 0