Код: Выделить всё
try (MockedStatic webClientStatic = Mockito.mockStatic(WebClient.class)) {
webClientStatic.when(WebClient::builder).thenReturn(webClientBuilder);
webClientStatic.when(WebClient::builder).thenReturn(webClientBuilder);
when(webClientBuilder.clientConnector(Mockito.any(ReactorClientHttpConnector.class))).thenReturn(webClientBuilder);
when(webClientBuilder.baseUrl(anyString())).thenReturn(webClientBuilder);
when(webClientBuilder.build()).thenReturn(webClient);
when(webClient.post()).thenReturn(requestBodyUriSpec);
when(requestBodyUriSpec.header(anyString(), anyString())).thenReturn(requestBodySpec);
when(requestHeadersSpec.retrieve()).thenReturn(responseSpec);
when(requestBodySpec.retrieve()).thenReturn(responseSpec);
when(responseSpec.bodyToMono(ZoomAccessToken.class)).thenReturn(Mono.just(zoomAccessToken));
}
Код: Выделить всё
webClientBuilder.build()Подробнее здесь: https://stackoverflow.com/questions/787 ... -in-a-test
Мобильная версия