-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make generated test values comply with url path template #903
Conversation
This includes nested messages creation when there are url paths with subfields mentioned (like `/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}`) This is needed for rest transports tests, because unlike grpc, request fields must match path templates for rest logic pass the tests. Main changes are in `DefaultValueComposer` and `HttpRuleParser` classes. The generated pattern-matching samples are in the following format: given the pattern pattern: ``` /v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*} ``` the value will be: ``` field.name=projects/project-1234/databases/database-1234/collectionGroups/collectionGroup-1234/fields/field-1234 ```
Codecov Report
@@ Coverage Diff @@
## main #903 +/- ##
==========================================
+ Coverage 87.84% 87.86% +0.01%
==========================================
Files 153 153
Lines 15966 16024 +58
Branches 1155 1166 +11
==========================================
+ Hits 14025 14079 +54
- Misses 1601 1602 +1
- Partials 340 343 +3
Continue to review full report at Codecov.
|
...a/com/google/api/generator/gapic/composer/common/AbstractServiceClientTestClassComposer.java
Outdated
Show resolved
Hide resolved
...a/com/google/api/generator/gapic/composer/common/AbstractServiceClientTestClassComposer.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/api/generator/gapic/composer/defaultvalue/DefaultValueComposer.java
Show resolved
Hide resolved
src/main/java/com/google/api/generator/gapic/composer/defaultvalue/DefaultValueComposer.java
Show resolved
Hide resolved
src/main/java/com/google/api/generator/gapic/composer/defaultvalue/DefaultValueComposer.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/api/generator/gapic/composer/defaultvalue/DefaultValueComposer.java
Outdated
Show resolved
Hide resolved
src/main/java/com/google/api/generator/gapic/protoparser/HttpRuleParser.java
Show resolved
Hide resolved
@@ -219,7 +220,30 @@ public class ComplianceClientTest { | |||
RepeatRequest request = | |||
RepeatRequest.newBuilder() | |||
.setName("name3373707") | |||
.setInfo(ComplianceData.newBuilder().build()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What has caused this statement to get expanded like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the gist of this change: the fields of the nested object (ComplianceData
) is mentioned in url path template (https://github.com/googleapis/gapic-generator-java/blob/main/src/test/java/com/google/api/generator/gapic/testdata/compliance.proto#L66), thus it has to be properly constructed in the tests for rest logic to pass (it needs to construct url to make a call, and to construct it we need the values from input message to do the substitution).
I'll LGTM once the changes are in. |
@chanseokoh pushed, PTAL |
This includes nested messages creation when there are url paths with subfields mentioned (like `/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}`) This is needed for rest transports tests because, unlike grpc, request fields must match path templates for rest logic pass the tests. Main changes are in `DefaultValueComposer` and `HttpRuleParser` classes. The generated pattern-matching samples are in the following format: given the pattern pattern: `/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}` the value will be: `field.name=projects/project-1234/databases/database-1234/collectionGroups/collectionGroup-1234/fields/field-1234`
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.api:gax-grpc](https://togithub.com/googleapis/gax-java) | `2.19.4` -> `2.19.5` | [![age](https://badges.renovateapi.com/packages/maven/com.google.api:gax-grpc/2.19.5/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.api:gax-grpc/2.19.5/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.api:gax-grpc/2.19.5/compatibility-slim/2.19.4)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.api:gax-grpc/2.19.5/confidence-slim/2.19.4)](https://docs.renovatebot.com/merge-confidence/) | | [com.google.api:gax-bom](https://togithub.com/googleapis/gax-java) | `2.19.4` -> `2.19.5` | [![age](https://badges.renovateapi.com/packages/maven/com.google.api:gax-bom/2.19.5/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.api:gax-bom/2.19.5/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.api:gax-bom/2.19.5/compatibility-slim/2.19.4)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.api:gax-bom/2.19.5/confidence-slim/2.19.4)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>googleapis/gax-java</summary> ### [`v2.19.5`](https://togithub.com/googleapis/gax-java/blob/HEAD/CHANGELOG.md#​2195-httpsgithubcomgoogleapisgax-javacomparev2194v2195-2022-11-07) [Compare Source](https://togithub.com/googleapis/gax-java/compare/v2.19.4...v2.19.5) ##### Bug Fixes - **deps:** Update dependency com.google.cloud:google-cloud-shared-config to v1.5.4 ([#​1840](https://togithub.com/googleapis/gax-java/issues/1840)) ([8f7a38c](https://togithub.com/googleapis/gax-java/commit/8f7a38ca0a9d187af49649adf7d96ef97c9e9915)) - **deps:** Update dependency com.google.code.gson:gson to v2.10 ([#​1845](https://togithub.com/googleapis/gax-java/issues/1845)) ([816e666](https://togithub.com/googleapis/gax-java/commit/816e6665e06bc65cbaf2703617342c8db9780115)) - **deps:** Update dependency com.google.protobuf:protobuf-bom to v3.21.9 ([#​1850](https://togithub.com/googleapis/gax-java/issues/1850)) ([f270ac4](https://togithub.com/googleapis/gax-java/commit/f270ac45b6a21d531eb8bd75157f2784fcad90fc)) - **deps:** Update dependency io.grpc:grpc-bom to v1.50.2 ([#​1842](https://togithub.com/googleapis/gax-java/issues/1842)) ([11c4a7c](https://togithub.com/googleapis/gax-java/commit/11c4a7caf31de256f29678de829f11f9558adcfd)) - **deps:** Update dependency org.mockito:mockito-core to v4.8.1 ([#​1843](https://togithub.com/googleapis/gax-java/issues/1843)) ([bf67fc2](https://togithub.com/googleapis/gax-java/commit/bf67fc26236286d72b9ddcb2e66113fdac74b51a)) - **deps:** Update dependency org.threeten:threetenbp to v1.6.4 ([#​1857](https://togithub.com/googleapis/gax-java/issues/1857)) ([a9e2374](https://togithub.com/googleapis/gax-java/commit/a9e23744a40f6e5484f1834824515f8ae952873c)) ##### Dependencies - update dependency com.google.api:api-common to 2.2.2 ([ad7ad1c](https://togithub.com/googleapis/gax-java/commit/ad7ad1c5b450cd0569ff34d3b553dd1493fa462c)) - update dependency com.google.api.grpc:grpc-google-common-protos to 2.10.0 ([ad7ad1c](https://togithub.com/googleapis/gax-java/commit/ad7ad1c5b450cd0569ff34d3b553dd1493fa462c)) - Update dependency com.google.api.grpc:proto-google-common-protos to 2.10.0 ([ad7ad1c](https://togithub.com/googleapis/gax-java/commit/ad7ad1c5b450cd0569ff34d3b553dd1493fa462c)) - update dependency com.google.auth:google-auth-library-credentials to 1.12.1 ([ad7ad1c](https://togithub.com/googleapis/gax-java/commit/ad7ad1c5b450cd0569ff34d3b553dd1493fa462c)) - update dependency com.google.auth:google-auth-library-oauth2-http to 1.12.1 ([ad7ad1c](https://togithub.com/googleapis/gax-java/commit/ad7ad1c5b450cd0569ff34d3b553dd1493fa462c)) - update dependency com.google.http-client:google-http-client to 1.42.3 ([ad7ad1c](https://togithub.com/googleapis/gax-java/commit/ad7ad1c5b450cd0569ff34d3b553dd1493fa462c)) - update dependency com.google.http-client:google-http-client-gson to 1.42.3 ([ad7ad1c](https://togithub.com/googleapis/gax-java/commit/ad7ad1c5b450cd0569ff34d3b553dd1493fa462c)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-shared-dependencies). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xOS4wIiwidXBkYXRlZEluVmVyIjoiMzQuMTkuMCJ9-->
🤖 I have created a release *beep* *boop* --- ## [3.0.6](https://togithub.com/googleapis/java-shared-dependencies/compare/v3.0.5...v3.0.6) (2022-11-07) ### Dependencies * Update dependency com.fasterxml.jackson:jackson-bom to v2.14.0 ([#901](https://togithub.com/googleapis/java-shared-dependencies/issues/901)) ([4e3d116](https://togithub.com/googleapis/java-shared-dependencies/commit/4e3d1162403a236443c8dbb00cbe23bd6c6c225a)) * Update dependency com.google.api-client:google-api-client-bom to v2.0.1 ([#899](https://togithub.com/googleapis/java-shared-dependencies/issues/899)) ([d2baed5](https://togithub.com/googleapis/java-shared-dependencies/commit/d2baed57f798b7c153678ce87bd486f9808dbc46)) * Update dependency com.google.api:api-common to v2.2.2 ([#892](https://togithub.com/googleapis/java-shared-dependencies/issues/892)) ([292cd39](https://togithub.com/googleapis/java-shared-dependencies/commit/292cd39d3b5fca9be15621b5e483e3b6386ec2ef)) * Update dependency com.google.cloud:grpc-gcp to v1.3.1 ([#884](https://togithub.com/googleapis/java-shared-dependencies/issues/884)) ([f22fce6](https://togithub.com/googleapis/java-shared-dependencies/commit/f22fce69481f0ecec1c5438b9f1a938db074cf4c)) * Update dependency com.google.code.gson:gson to v2.10 ([#887](https://togithub.com/googleapis/java-shared-dependencies/issues/887)) ([cbe8973](https://togithub.com/googleapis/java-shared-dependencies/commit/cbe8973436da3c34be00d0742b3db11af106f585)) * Update dependency com.google.http-client:google-http-client-bom to v1.42.3 ([#893](https://togithub.com/googleapis/java-shared-dependencies/issues/893)) ([21e7515](https://togithub.com/googleapis/java-shared-dependencies/commit/21e7515d351cf8a53cb7590267231930bedfaf88)) * Update dependency com.google.protobuf:protobuf-bom to v3.21.9 ([#889](https://togithub.com/googleapis/java-shared-dependencies/issues/889)) ([30effe6](https://togithub.com/googleapis/java-shared-dependencies/commit/30effe65dc103a694fab5bf9537e96a0def0d4d9)) * Update dependency io.grpc:grpc-bom to v1.50.2 ([#878](https://togithub.com/googleapis/java-shared-dependencies/issues/878)) ([0e155c4](https://togithub.com/googleapis/java-shared-dependencies/commit/0e155c476ee8280921d234286eed8732997dd2a6)) * Update dependency org.checkerframework:checker-qual to v3.27.0 ([#896](https://togithub.com/googleapis/java-shared-dependencies/issues/896)) ([f6c1155](https://togithub.com/googleapis/java-shared-dependencies/commit/f6c1155bbd0a01b6a25948f7c6117a50fd85e9de)) * Update dependency org.threeten:threetenbp to v1.6.4 ([#894](https://togithub.com/googleapis/java-shared-dependencies/issues/894)) ([478ae53](https://togithub.com/googleapis/java-shared-dependencies/commit/478ae530c8140d92f4e083c5e06ecd6f4f228f05)) * Update gax.version to v2.19.5 ([#903](https://togithub.com/googleapis/java-shared-dependencies/issues/903)) ([ba1ae38](https://togithub.com/googleapis/java-shared-dependencies/commit/ba1ae389185f2fffaec10cf69ad6644389af9571)) * Update google.common-protos.version to v2.10.0 ([#900](https://togithub.com/googleapis/java-shared-dependencies/issues/900)) ([46aeddf](https://togithub.com/googleapis/java-shared-dependencies/commit/46aeddfe2ce2325ab8ae9a6654c500f847855acb)) * Update google.core.version to v2.8.23 ([#885](https://togithub.com/googleapis/java-shared-dependencies/issues/885)) ([1092bbe](https://togithub.com/googleapis/java-shared-dependencies/commit/1092bbe5f7a9d84dc1013f8a3c8e62e5c26ab2ab)) * Update google.core.version to v2.8.24 ([#890](https://togithub.com/googleapis/java-shared-dependencies/issues/890)) ([70791a5](https://togithub.com/googleapis/java-shared-dependencies/commit/70791a5ce678c5c7ebbb70e1527cab69587307ec)) * Update google.core.version to v2.8.27 ([#902](https://togithub.com/googleapis/java-shared-dependencies/issues/902)) ([a53f404](https://togithub.com/googleapis/java-shared-dependencies/commit/a53f404799ac6fd4e3005ea781f74a245fd7b7c7)) * Update iam.version to v1.6.6 ([#886](https://togithub.com/googleapis/java-shared-dependencies/issues/886)) ([122cf9d](https://togithub.com/googleapis/java-shared-dependencies/commit/122cf9d01a73d78768544b0638efc8cca995fd87)) * Update iam.version to v1.6.7 ([#895](https://togithub.com/googleapis/java-shared-dependencies/issues/895)) ([feda2e7](https://togithub.com/googleapis/java-shared-dependencies/commit/feda2e7d2d9026dffcdfe71f443199505e5bb215)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
…-plugin to v3.4.1 (#903) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [org.apache.maven.plugins:maven-javadoc-plugin](https://maven.apache.org/plugins/) ([source](https://togithub.com/apache/maven-javadoc-plugin)) | `3.4.0` -> `3.4.1` | [![age](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-javadoc-plugin/3.4.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-javadoc-plugin/3.4.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-javadoc-plugin/3.4.1/compatibility-slim/3.4.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/org.apache.maven.plugins:maven-javadoc-plugin/3.4.1/confidence-slim/3.4.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-core). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xNTguMCIsInVwZGF0ZWRJblZlciI6IjMyLjE2MS4wIn0=-->
This includes nested messages creation when there are url paths with subfields mentioned (like
/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}
)This is needed for rest transports tests because, unlike grpc, request fields must match path templates for rest logic pass the tests.
Main changes are in
DefaultValueComposer
andHttpRuleParser
classes.The generated pattern-matching samples are in the following format:
given the pattern pattern:
/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}
the value will be:
field.name=projects/project-1234/databases/database-1234/collectionGroups/collectionGroup-1234/fields/field-1234