|
17 | 17 | package com.google.showcase.v1beta1.spring; |
18 | 18 |
|
19 | 19 | import static org.assertj.core.api.Assertions.assertThat; |
20 | | -import static org.mockito.ArgumentMatchers.any; |
21 | | -import static org.mockito.Mockito.when; |
22 | 20 |
|
23 | 21 | import com.google.api.gax.core.CredentialsProvider; |
24 | 22 | import com.google.api.gax.core.InstantiatingExecutorProvider; |
| 23 | +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; |
25 | 24 | import com.google.api.gax.retrying.RetrySettings; |
26 | 25 | import com.google.api.gax.rpc.ApiCallContext; |
27 | 26 | import com.google.api.gax.rpc.TransportChannel; |
@@ -189,27 +188,19 @@ void testExecutorThreadCountFromProperties() { |
189 | 188 |
|
190 | 189 | @Test |
191 | 190 | void testCustomTransportChannelProviderUsedWhenProvided() throws IOException { |
192 | | - when(mockTransportChannelProvider.getTransportName()).thenReturn("grpc"); |
193 | | - when(mockTransportChannelProvider.getTransportChannel()).thenReturn(mockTransportChannel); |
194 | | - when(mockTransportChannel.getEmptyCallContext()).thenReturn(mockApiCallContext); |
195 | | - // Mock no-ops for ApiCallContext since this test only intends to verify override of |
196 | | - // TransportChannelProvider bean |
197 | | - when(mockApiCallContext.withCredentials(any())).thenReturn(mockApiCallContext); |
198 | | - when(mockApiCallContext.withTransportChannel(any())).thenReturn(mockApiCallContext); |
199 | | - when(mockApiCallContext.withStreamWaitTimeout(any())).thenReturn(mockApiCallContext); |
200 | | - when(mockApiCallContext.withStreamIdleTimeout(any())).thenReturn(mockApiCallContext); |
201 | | - when(mockApiCallContext.withEndpointContext(any())).thenReturn(mockApiCallContext); |
202 | | - |
| 191 | + InstantiatingGrpcChannelProvider channelProvider = |
| 192 | + InstantiatingGrpcChannelProvider.newBuilder() |
| 193 | + .build(); |
203 | 194 | contextRunner |
204 | 195 | .withBean( |
205 | 196 | TRANSPORT_CHANNEL_PROVIDER_QUALIFIER_NAME, |
206 | 197 | TransportChannelProvider.class, |
207 | | - () -> mockTransportChannelProvider) |
| 198 | + () -> channelProvider) |
208 | 199 | .run( |
209 | 200 | ctx -> { |
210 | 201 | EchoClient client = ctx.getBean(EchoClient.class); |
211 | 202 | assertThat(client.getSettings().getTransportChannelProvider()) |
212 | | - .isSameAs(mockTransportChannelProvider); |
| 203 | + .isSameAs(channelProvider); |
213 | 204 | }); |
214 | 205 | } |
215 | 206 |
|
|
0 commit comments