Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

feat: [REGAPIC] Add support for additional bindings #1680

Merged
merged 8 commits into from
May 18, 2022

Conversation

vam-google
Copy link
Contributor

@vam-google vam-google commented May 12, 2022

Additional bindings are currently relevant only for generated unit tests

[edit] Also update IAM dependency in dependencies.properties (it is used in generated build gralde files for self-service)

Additional bindings are currently relevant only for generated unit tests
@vam-google vam-google requested review from a team as code owners May 12, 2022 22:47
@vam-google vam-google requested review from blakeli0 and eaball35 May 12, 2022 22:48
@@ -136,7 +156,8 @@ public ProtoMessageRequestFormatter<RequestT> build() {
queryParamsExtractor,
rawPath,
PathTemplate.create(rawPath),
pathVarsExtractor);
pathVarsExtractor,
rawAdditionalPaths.stream().map(PathTemplate::create).collect(Collectors.toList()));
Copy link
Contributor

@blakeli0 blakeli0 May 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it an ImmutableList? Collectors.toList() is not guaranteed to be immutable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ImmutableList collectors are not part of a more lightweight versions of guava (androind one does not have them), so to keep better portability I believe it is better to stick to standard library collectors.

@blakeli0
Copy link
Contributor

Additional bindings are currently relevant only for generated unit tests

If they are only for generated unit tests, do we really need this change? Can you provide an example usage of this additional bindings?

vam-google added a commit to vam-google/gapic-generator-java that referenced this pull request May 13, 2022
This PR depends on the corresponding one in gax: googleapis/gax-java#1680
@vam-google
Copy link
Contributor Author

@blakeli0 It will affect execution of the generated tests, but not their code directly. Currently additional bindings are validated only as part of MockService (which is part of this repo). As for the generated output it will affect the generated HttpJsonStub class only: https://github.com/googleapis/gapic-generator-java/pull/993/files#diff-61b6037b6806f14c0997d861055d58981a65244e905df133923b53defaafe8f4

@vam-google
Copy link
Contributor Author

@blakeli0 PTAL

/* {@inheritDoc} */
@Override
public PathTemplate getPathTemplate() {
return pathTemplate;
}

@Override
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to override hashcode() and equals() methods for this class? I think if you don't compare them or put them in a collection, then you don't have to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is toBuilder() semantics in this class, so I added equals()/hashCode() to do testing of that logic, but seems like adding equals/hashcode added it own problems of branch coverage. I guess I'll just remove those as they cause more trouble than they should.

@blakeli0
Copy link
Contributor

It will affect execution of the generated tests, but not their code directly. Currently additional bindings are validated only as part of MockService (which is part of this repo).

Does it mean that these new fields are populated but not really used by any features yet? Do we populate them just in case or there are features plan to use them?
I know HttpRule already has these additionalBindings in the proto but not sure how they are used currently or are they relevant to REGAPIC or not.

@vam-google
Copy link
Contributor Author

@blakeli0 they are used in MockService validation logic https://github.com/googleapis/gax-java/pull/1680/files#diff-4910ec43f3337af2793083d9c8c1f0864769deac8c2d7b9b87778e47a5504471R215. MockService needs additional bindings, because they are essential to match a url to a mocked API method. This kind of matching is happening only in the mock service, as in production the matching is happening on the server side.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

90.0% 90.0% Coverage
0.0% 0.0% Duplication

@vam-google vam-google merged commit 59b3699 into googleapis:main May 18, 2022
vam-google added a commit to googleapis/sdk-platform-java that referenced this pull request May 19, 2022
This PR depends on the corresponding one in gax: googleapis/gax-java#1680
suztomo pushed a commit to googleapis/sdk-platform-java that referenced this pull request Dec 16, 2022
This PR depends on the corresponding one in gax: googleapis/gax-java#1680
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants