@Bean
  protected WebClientFactoryI mockWebClientFactory() throws WebException {
    WebClientI client = mock(WebClientI.class);
    WebResponseI response = mock(WebResponseI.class);
    when(response.getBody())
        .thenReturn(StringUtils.getBytesUtf8(FURBY_CHECK_SESSION_JSON_RESPONSE));
    when(response.getEncoding()).thenReturn("UTF-8");
    when(client.execute(any())).thenReturn(response);
    WebClientFactoryI factory = mock(WebClientFactoryI.class);
    when(factory.createWebClient(anyString())).thenReturn(client);

    return factory;
  }
Пример #2
0
 private static WebResponseI prepareWebResponse(String body, String encoding) {
   WebResponseI response = mock(WebResponseI.class);
   when(response.getBody()).thenReturn(body.getBytes());
   when(response.getEncoding()).thenReturn(encoding);
   return response;
 }