Skip to content

Commit 797695b

Browse files
[ggj][codegen] fix: use both map generics in ServiceClientTest codegen (#428)
* fix: support non-name fields with res-refs in resname def parsing * fix: add workaround for missing default_host and oauth_scopes annotation * fix: clarify LRO parsing error messages * feat: support deeply-nested types in AST and proto message parsing * fix: prevent resname tokens from matching subcomponents * fix: use TypeParser for proto message parsing * fix: use generic types in field instantiation in ServiceClientTest * fix: prevent descension into map types in nested message parsing * fix: merge master * fix: use both map generics in ServiceClientTest codegen * fix: add workaround for missing default_host and oauth_scopes annotation * [ggj][infra][3/5]feat: add goldens update bazel rules for Redis API (#396) * goldens update bazel rules * clean up * [ggj][infra][4/5]feat: add goldens update bazel rules for Asset API (#397) * goldens update bazel rules * clean up * goldens update rule for asset API * update goldens * [ggj][infra][3/5]feat: add goldens update bazel rules for Redis API (#396) * goldens update bazel rules * clean up * [ggj][infra][4/5]feat: add goldens update bazel rules for Asset API (#397) * goldens update bazel rules * clean up * goldens update rule for asset API * update goldens * [ggj][infra][3/5]feat: add goldens update bazel rules for Redis API (#396) * goldens update bazel rules * clean up * [ggj][infra][4/5]feat: add goldens update bazel rules for Asset API (#397) * goldens update bazel rules * clean up * goldens update rule for asset API * update goldens * fix: clarify LRO parsing error messages * feat: support deeply-nested types in AST and proto message parsing * fix: prevent resname tokens from matching subcomponents * fix: use TypeParser for proto message parsing * fix: merge master * fix: use generic types in field instantiation in ServiceClientTest * fix: prevent descension into map types in nested message parsing * fix: merge master * fix: merge master * fix: merge master * fix: merge master * fix: prevent descension into map types in nested message parsing * build: add logging, redis gradle assembly rules * fix: merge master Co-authored-by: Xiaozhen Liu <[email protected]>
1 parent 7a184e1 commit 797695b

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

src/main/java/com/google/api/generator/gapic/composer/DefaultValueComposer.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ static Expr createDefaultValue(Field f, boolean useExplicitInitTypeInGenerics) {
8585
ConcreteReference.Builder refBuilder =
8686
ConcreteReference.builder().setClazz(f.isMap() ? HashMap.class : ArrayList.class);
8787
if (useExplicitInitTypeInGenerics) {
88-
refBuilder = refBuilder.setGenerics(f.type().reference().generics().get(0));
88+
if (f.isMap()) {
89+
refBuilder = refBuilder.setGenerics(f.type().reference().generics().subList(0, 2));
90+
} else {
91+
refBuilder = refBuilder.setGenerics(f.type().reference().generics().get(0));
92+
}
8993
}
9094

9195
TypeNode newType = TypeNode.withReference(refBuilder.build());

src/test/java/com/google/api/generator/gapic/composer/goldens/SubscriberClientTest.golden

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public class SubscriberClientTest {
8181
.setPushConfig(PushConfig.newBuilder().build())
8282
.setAckDeadlineSeconds(2135351438)
8383
.setRetainAckedMessages(true)
84-
.putAllLabels(new HashMap<String>())
84+
.putAllLabels(new HashMap<String, String>())
8585
.setEnableMessageOrdering(true)
8686
.setExpirationPolicy(ExpirationPolicy.newBuilder().build())
8787
.setFilter("filter-1274492040")
@@ -140,7 +140,7 @@ public class SubscriberClientTest {
140140
.setPushConfig(PushConfig.newBuilder().build())
141141
.setAckDeadlineSeconds(2135351438)
142142
.setRetainAckedMessages(true)
143-
.putAllLabels(new HashMap<String>())
143+
.putAllLabels(new HashMap<String, String>())
144144
.setEnableMessageOrdering(true)
145145
.setExpirationPolicy(ExpirationPolicy.newBuilder().build())
146146
.setFilter("filter-1274492040")
@@ -199,7 +199,7 @@ public class SubscriberClientTest {
199199
.setPushConfig(PushConfig.newBuilder().build())
200200
.setAckDeadlineSeconds(2135351438)
201201
.setRetainAckedMessages(true)
202-
.putAllLabels(new HashMap<String>())
202+
.putAllLabels(new HashMap<String, String>())
203203
.setEnableMessageOrdering(true)
204204
.setExpirationPolicy(ExpirationPolicy.newBuilder().build())
205205
.setFilter("filter-1274492040")
@@ -258,7 +258,7 @@ public class SubscriberClientTest {
258258
.setPushConfig(PushConfig.newBuilder().build())
259259
.setAckDeadlineSeconds(2135351438)
260260
.setRetainAckedMessages(true)
261-
.putAllLabels(new HashMap<String>())
261+
.putAllLabels(new HashMap<String, String>())
262262
.setEnableMessageOrdering(true)
263263
.setExpirationPolicy(ExpirationPolicy.newBuilder().build())
264264
.setFilter("filter-1274492040")
@@ -317,7 +317,7 @@ public class SubscriberClientTest {
317317
.setPushConfig(PushConfig.newBuilder().build())
318318
.setAckDeadlineSeconds(2135351438)
319319
.setRetainAckedMessages(true)
320-
.putAllLabels(new HashMap<String>())
320+
.putAllLabels(new HashMap<String, String>())
321321
.setEnableMessageOrdering(true)
322322
.setExpirationPolicy(ExpirationPolicy.newBuilder().build())
323323
.setFilter("filter-1274492040")
@@ -366,7 +366,7 @@ public class SubscriberClientTest {
366366
.setPushConfig(PushConfig.newBuilder().build())
367367
.setAckDeadlineSeconds(2135351438)
368368
.setRetainAckedMessages(true)
369-
.putAllLabels(new HashMap<String>())
369+
.putAllLabels(new HashMap<String, String>())
370370
.setEnableMessageOrdering(true)
371371
.setExpirationPolicy(ExpirationPolicy.newBuilder().build())
372372
.setFilter("filter-1274492040")
@@ -415,7 +415,7 @@ public class SubscriberClientTest {
415415
.setPushConfig(PushConfig.newBuilder().build())
416416
.setAckDeadlineSeconds(2135351438)
417417
.setRetainAckedMessages(true)
418-
.putAllLabels(new HashMap<String>())
418+
.putAllLabels(new HashMap<String, String>())
419419
.setEnableMessageOrdering(true)
420420
.setExpirationPolicy(ExpirationPolicy.newBuilder().build())
421421
.setFilter("filter-1274492040")
@@ -1013,7 +1013,7 @@ public class SubscriberClientTest {
10131013
Snapshot.newBuilder()
10141014
.setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString())
10151015
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
1016-
.putAllLabels(new HashMap<String>())
1016+
.putAllLabels(new HashMap<String, String>())
10171017
.build();
10181018
mockSubscriber.addResponse(expectedResponse);
10191019

@@ -1053,7 +1053,7 @@ public class SubscriberClientTest {
10531053
Snapshot.newBuilder()
10541054
.setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString())
10551055
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
1056-
.putAllLabels(new HashMap<String>())
1056+
.putAllLabels(new HashMap<String, String>())
10571057
.build();
10581058
mockSubscriber.addResponse(expectedResponse);
10591059

@@ -1181,7 +1181,7 @@ public class SubscriberClientTest {
11811181
Snapshot.newBuilder()
11821182
.setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString())
11831183
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
1184-
.putAllLabels(new HashMap<String>())
1184+
.putAllLabels(new HashMap<String, String>())
11851185
.build();
11861186
mockSubscriber.addResponse(expectedResponse);
11871187

@@ -1224,7 +1224,7 @@ public class SubscriberClientTest {
12241224
Snapshot.newBuilder()
12251225
.setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString())
12261226
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
1227-
.putAllLabels(new HashMap<String>())
1227+
.putAllLabels(new HashMap<String, String>())
12281228
.build();
12291229
mockSubscriber.addResponse(expectedResponse);
12301230

@@ -1267,7 +1267,7 @@ public class SubscriberClientTest {
12671267
Snapshot.newBuilder()
12681268
.setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString())
12691269
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
1270-
.putAllLabels(new HashMap<String>())
1270+
.putAllLabels(new HashMap<String, String>())
12711271
.build();
12721272
mockSubscriber.addResponse(expectedResponse);
12731273

@@ -1310,7 +1310,7 @@ public class SubscriberClientTest {
13101310
Snapshot.newBuilder()
13111311
.setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString())
13121312
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
1313-
.putAllLabels(new HashMap<String>())
1313+
.putAllLabels(new HashMap<String, String>())
13141314
.build();
13151315
mockSubscriber.addResponse(expectedResponse);
13161316

@@ -1353,7 +1353,7 @@ public class SubscriberClientTest {
13531353
Snapshot.newBuilder()
13541354
.setName(SnapshotName.of("[PROJECT]", "[SNAPSHOT]").toString())
13551355
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
1356-
.putAllLabels(new HashMap<String>())
1356+
.putAllLabels(new HashMap<String, String>())
13571357
.build();
13581358
mockSubscriber.addResponse(expectedResponse);
13591359

test/integration/BUILD.bazel

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
load(
22
"@com_google_googleapis_imports//:imports.bzl",
33
"proto_library_with_info",
4+
java_gapic_assembly_gradle_pkg = "java_gapic_assembly_gradle_pkg2",
45
java_gapic_library = "java_gapic_library2",
56
)
67
load(
@@ -86,18 +87,13 @@ java_gapic_library(
8687
],
8788
)
8889

89-
# Logging API
90-
java_gapic_library(
91-
name = "redis_java_gapic",
92-
srcs = ["redis_proto_with_info"],
93-
grpc_service_config = "@com_google_googleapis//google/cloud/redis/v1:redis_grpc_service_config.json",
94-
package = "google.cloud.redis.v1",
95-
service_yaml = "@com_google_googleapis//google/cloud/redis/v1:redis_v1.yaml",
96-
test_deps = [
97-
"@com_google_googleapis//google/cloud/redis/v1:redis_java_grpc",
98-
],
90+
java_gapic_assembly_gradle_pkg(
91+
name = "google-cloud-redis-v1-java",
9992
deps = [
93+
":redis_java_gapic",
94+
"@com_google_googleapis//google/cloud/redis/v1:redis_java_grpc",
10095
"@com_google_googleapis//google/cloud/redis/v1:redis_java_proto",
96+
"@com_google_googleapis//google/cloud/redis/v1:redis_proto",
10197
],
10298
)
10399

0 commit comments

Comments
 (0)