Skip to content

Commit 48e0681

Browse files
authored
fix: change to generation script in manipulating googleapis/WORKSPACE. (#3120)
* fix: change to generation script in manipulating googleapis/WORKSPACE. * fix: mocked method in test needs to change after java.time introduced in gax. * fix: address review comment, create a custom InstantiatingGrpcChannelProvider instead of using mocks. * chore: use mvn wrapper in shocase test ci. * address review comments.
1 parent a9ec698 commit 48e0681

File tree

4 files changed

+15
-21
lines changed

4 files changed

+15
-21
lines changed

.github/workflows/showcaseTests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ jobs:
4343
bash scripts/generate-showcase.sh
4444
- name: Unit tests for showcase-spring-starter
4545
# Runs showcase-spring-starter unit tests
46-
working-directory: spring-cloud-generator
46+
working-directory: spring-cloud-generator/showcase/showcase-spring-starter
4747
run: |
48-
cd showcase/showcase-spring-starter && mvn verify
48+
../../../mvnw verify

spring-cloud-generator/scripts/generate-steps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function modify_workspace_file(){
9191
# delete existing maven_install rules
9292
buildozer 'delete' ${path_to_workspace}:%maven_install
9393
# add custom maven_install rules
94-
perl -pi -e "s{(^_gapic_generator_java_version[^\n]*)}{\$1\n$(cat ${path_to_modification_string})}" ${path_to_workspace}
94+
perl -pi -e "s{(^api_dependencies()[^\n]*)}{\$1\n$(cat ${path_to_modification_string})}" ${path_to_workspace}
9595
}
9696

9797
# For individual library, set up bazel rules

spring-cloud-generator/scripts/resources/googleapis_modification_string.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ _spring_cloud_generator_version = "5.5.1-SNAPSHOT" # {x-version-update:spring-cl
22

33
maven_install(
44
artifacts = [
5-
"com.google.cloud:spring-cloud-generator:" + _spring_cloud_generator_version,
6-
],
5+
"com.google.cloud:spring-cloud-generator:" + _spring_cloud_generator_version,
6+
] +
7+
IO_GRPC_GRPC_JAVA_ARTIFACTS,
8+
generate_compat_repositories = True,
9+
override_targets = IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS,
710
#Update this False for local development
811
fail_on_missing_checksum = False,
912
repositories = [
1013
"m2Local",
1114
"https://repo.maven.apache.org/maven2/",
1215
]
13-
)
16+
)

spring-cloud-generator/showcase/showcase-spring-starter/src/test/java/com/google/showcase/v1beta1/spring/EchoAutoConfigurationTests.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
package com.google.showcase.v1beta1.spring;
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
20-
import static org.mockito.ArgumentMatchers.any;
21-
import static org.mockito.Mockito.when;
2220

2321
import com.google.api.gax.core.CredentialsProvider;
2422
import com.google.api.gax.core.InstantiatingExecutorProvider;
23+
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
2524
import com.google.api.gax.retrying.RetrySettings;
2625
import com.google.api.gax.rpc.ApiCallContext;
2726
import com.google.api.gax.rpc.TransportChannel;
@@ -189,27 +188,19 @@ void testExecutorThreadCountFromProperties() {
189188

190189
@Test
191190
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();
203194
contextRunner
204195
.withBean(
205196
TRANSPORT_CHANNEL_PROVIDER_QUALIFIER_NAME,
206197
TransportChannelProvider.class,
207-
() -> mockTransportChannelProvider)
198+
() -> channelProvider)
208199
.run(
209200
ctx -> {
210201
EchoClient client = ctx.getBean(EchoClient.class);
211202
assertThat(client.getSettings().getTransportChannelProvider())
212-
.isSameAs(mockTransportChannelProvider);
203+
.isSameAs(channelProvider);
213204
});
214205
}
215206

0 commit comments

Comments
 (0)