-
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: Numeric enums in routing headers #2328
Conversation
After commit d63e854, the local testing shows this O/P. Getting "getFKingdomValue" in the method name. |
Code changes description: In first case (routingHeaderRule() == null, createRequestParamsExtractorBodyForHttpBindings() is called), createRequestFieldGetterExpr() is modified to accept an extra boolean parameter, isFieldEnum(). And if the field is enum, I am adding an extra “Value” to the fieldMethod name (https://github.com/googleapis/sdk-platform-java/pull/2328/files#diff-13cc1d69966fca5c433b2c243aa4e8414520cf05e295f02ed52f2fe5097cac21R1474) during the last iteration of the descendant fields. In the 2nd case when routingHeaderRule()!=null, I am sending false in isFieldEnum() because |
gapic-generator-java/src/test/proto/explicit_dynamic_routing_header_testing.proto
Outdated
Show resolved
Hide resolved
...om/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java
Outdated
Show resolved
Hide resolved
gapic-generator-java/src/main/java/com/google/api/generator/gapic/model/GapicContext.java
Outdated
Show resolved
Hide resolved
gapic-generator-java/src/test/proto/explicit_dynamic_routing_header_testing.proto
Show resolved
Hide resolved
...om/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java
Show resolved
Hide resolved
...om/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java
Show resolved
Hide resolved
...om/google/api/generator/gapic/composer/common/AbstractTransportServiceStubClassComposer.java
Outdated
Show resolved
Hide resolved
FYI @ddixit14, we have Showcase ITs for Dynamic Routing Headers at https://github.com/googleapis/sdk-platform-java/blob/762c125abadb5e56682224c9f1587c71e5c6e653/showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITDynamicRoutingHeaders.java I think the compliance.proto has a enum field that you can possibly test against. It may be possible to add a test to intercept the the enum value is sent as an int value in the headers. |
...ase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITDynamicRoutingHeaders.java
Outdated
Show resolved
Hide resolved
...ase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITDynamicRoutingHeaders.java
Show resolved
Hide resolved
@@ -175,6 +189,24 @@ public void testGrpc_matchesHeaderName() { | |||
assertThat(requestHeaders).containsExactlyElementsIn(expectedHeaders); | |||
} | |||
|
|||
@Test | |||
public void testGrpc_implicitHeadersEnum() { |
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.
nit: Rename this to be a bit more descriptive. Something like testGrpc_implicitHeaders_enumsEncodedasInt()
to describe that this test covers specifically enums -> int.
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.
Also, can you add an httpjson test case as well. I think it affects both transports. Ignore this comment if it only affects gRPC.
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.
nit: Rename this to be a bit more descriptive. Something like
testGrpc_implicitHeaders_enumsEncodedasInt()
to describe that this test covers specifically enums -> int.
+1000 to this. See unit tests naming for details.
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.
renamed the tests and added httpjson case as well. thank you.
Also, we talked earlier about possibly enhancing echo.proto to also test for some explicit + implicit dynamic routing enum use cases. I took another look into echo.proto and I think it makes sense since a bulk of the routing header test cases are there: https://github.com/googleapis/gapic-showcase/blob/330a3a25eb8c4d0948860f1898fe7dcc05dc4ea5/schema/google/showcase/v1beta1/echo.proto#L48-L86 I think you can create an issue in the gapic-showcase repo and someone can pick it up in the future. |
...ase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITDynamicRoutingHeaders.java
Outdated
Show resolved
Hide resolved
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.
I added a few more nits but overall LGTM to me. Please resolve the nits and let @blakeli0 to take another look before merging. Thanks for the PR!
If we already have a test case in |
For now, it's mainly for the latter reason. Agreed that ideally we would have a separate showcase proto for routing headers, but it looks like the explicit headers are mostly contained in the echo proto. It's not urgent to add an enum to the echo proto, but a smaller task to enable showcase tests for more routing headers use cases is to add it there (especially for any future explicit enhancements/ improvements). In the future/whenever someone has the time, we can create a new proto specifically for routing headers. |
Quality Gate passed for 'gapic-generator-java-root'Kudos, no new issues were introduced! 0 New issues |
Quality Gate passed for 'java_showcase_integration_tests'Kudos, no new issues were introduced! 0 New issues |
* chore: Numeric enums in routing headers
Solves - #2368 (Numeric enums in implicit routing headers)
FYI, only implicit routing headers can be fixed currently because explicit routing headers are implemented as strings by design. See this doc for more details.