|
67 | 67 |
|
68 | 68 | @RunWith(JUnit4.class) |
69 | 69 | public class InstantiatingGrpcChannelProviderTest extends AbstractMtlsTransportChannelTest { |
| 70 | + |
70 | 71 | @Test |
71 | 72 | public void testEndpoint() { |
72 | 73 | String endpoint = "localhost:8080"; |
@@ -164,11 +165,8 @@ public void testToBuilder() { |
164 | 165 | Duration keepaliveTime = Duration.ofSeconds(1); |
165 | 166 | Duration keepaliveTimeout = Duration.ofSeconds(2); |
166 | 167 | ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> channelConfigurator = |
167 | | - new ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder>() { |
168 | | - @Override |
169 | | - public ManagedChannelBuilder apply(ManagedChannelBuilder input) { |
170 | | - throw new UnsupportedOperationException(); |
171 | | - } |
| 168 | + builder -> { |
| 169 | + throw new UnsupportedOperationException(); |
172 | 170 | }; |
173 | 171 | Map<String, ?> directPathServiceConfig = ImmutableMap.of("loadbalancingConfig", "grpclb"); |
174 | 172 |
|
@@ -266,16 +264,13 @@ public void testWithGCECredentials() throws IOException { |
266 | 264 | executor.shutdown(); |
267 | 265 |
|
268 | 266 | ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> channelConfigurator = |
269 | | - new ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder>() { |
270 | | - @Override |
271 | | - public ManagedChannelBuilder apply(ManagedChannelBuilder channelBuilder) { |
272 | | - if (InstantiatingGrpcChannelProvider.isOnComputeEngine()) { |
273 | | - assertThat(channelBuilder instanceof ComputeEngineChannelBuilder).isTrue(); |
274 | | - } else { |
275 | | - assertThat(channelBuilder instanceof ComputeEngineChannelBuilder).isFalse(); |
276 | | - } |
277 | | - return channelBuilder; |
| 267 | + channelBuilder -> { |
| 268 | + if (InstantiatingGrpcChannelProvider.isOnComputeEngine()) { |
| 269 | + assertThat(channelBuilder).isInstanceOf(ComputeEngineChannelBuilder.class); |
| 270 | + } else { |
| 271 | + assertThat(channelBuilder).isNotInstanceOf(ComputeEngineChannelBuilder.class); |
278 | 272 | } |
| 273 | + return channelBuilder; |
279 | 274 | }; |
280 | 275 |
|
281 | 276 | TransportChannelProvider provider = |
@@ -304,13 +299,10 @@ public void testWithNonGCECredentials() throws IOException { |
304 | 299 | executor.shutdown(); |
305 | 300 |
|
306 | 301 | ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> channelConfigurator = |
307 | | - new ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder>() { |
308 | | - @Override |
309 | | - public ManagedChannelBuilder apply(ManagedChannelBuilder channelBuilder) { |
310 | | - // Clients with non-GCE credentials will not attempt DirectPath. |
311 | | - assertThat(channelBuilder instanceof ComputeEngineChannelBuilder).isFalse(); |
312 | | - return channelBuilder; |
313 | | - } |
| 302 | + channelBuilder -> { |
| 303 | + // Clients with non-GCE credentials will not attempt DirectPath. |
| 304 | + assertThat(channelBuilder instanceof ComputeEngineChannelBuilder).isFalse(); |
| 305 | + return channelBuilder; |
314 | 306 | }; |
315 | 307 |
|
316 | 308 | TransportChannelProvider provider = |
@@ -366,13 +358,10 @@ public void testWithNoDirectPathFlagSet() throws IOException { |
366 | 358 | executor.shutdown(); |
367 | 359 |
|
368 | 360 | ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> channelConfigurator = |
369 | | - new ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder>() { |
370 | | - @Override |
371 | | - public ManagedChannelBuilder apply(ManagedChannelBuilder channelBuilder) { |
372 | | - // Clients without setting attemptDirectPath flag will not attempt DirectPath |
373 | | - assertThat(channelBuilder instanceof ComputeEngineChannelBuilder).isFalse(); |
374 | | - return channelBuilder; |
375 | | - } |
| 361 | + channelBuilder -> { |
| 362 | + // Clients without setting attemptDirectPath flag will not attempt DirectPath |
| 363 | + assertThat(channelBuilder instanceof ComputeEngineChannelBuilder).isFalse(); |
| 364 | + return channelBuilder; |
376 | 365 | }; |
377 | 366 |
|
378 | 367 | TransportChannelProvider provider = |
|
0 commit comments