-
Notifications
You must be signed in to change notification settings - Fork 67
feat: gapic-generator-java to perform a no-op when no services are detected #2460
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
Merged
Merged
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
00c1eb1
feat(gapic-generator-java): Cause a noop when no services are found
diegomarquezp d150747
revert NoServicesFoundException
diegomarquezp a79329f
chore: fix owl-bot-staging unpacking
diegomarquezp 96b357b
Merge branch 'fix-owlbot-staging' into gapic-generator-no-service-noop
diegomarquezp 4bc092a
try to use empty GapicPackageInfo
diegomarquezp 0372f9e
Revert "try to use empty GapicPackageInfo"
diegomarquezp 392305a
Revert "chore: fix owl-bot-staging unpacking"
diegomarquezp 97a38ad
Revert "revert NoServicesFoundException"
diegomarquezp 204fff8
remove proto_only
diegomarquezp 4d85490
add a proto only library in integration test
diegomarquezp 7e06287
Merge branch 'main' into gapic-generator-no-service-noop
diegomarquezp 45c1ff5
Merge remote-tracking branch 'origin/main' into gapic-generator-no-se…
diegomarquezp 6c8aa53
add `empty()` methods for no-op involved classes
diegomarquezp c2ca534
remove proto_only unit tests
diegomarquezp f5d595c
fix warning messages
diegomarquezp a58b4ef
fix empty zip check
diegomarquezp 0ff112e
extra handling for empty package info
diegomarquezp 1639b61
add warning for empty package info
diegomarquezp 69fce38
fix integration test
diegomarquezp 799b23e
Merge branch 'main' into gapic-generator-no-service-noop
diegomarquezp 4caa419
use try with resources in Writer
diegomarquezp 71cc3f3
Merge remote-tracking branch 'origin/gapic-generator-no-service-noop'…
diegomarquezp 827e27e
add coverage on parser and composer
diegomarquezp 4eccad0
improve coverage 2
diegomarquezp bfe0d6c
enhance Writer testing
diegomarquezp 9678c7b
improve Writer coverage 2
diegomarquezp dd140d2
fix writer test
diegomarquezp 3fd8bfa
retrigger tests
diegomarquezp 1634112
wip fix Writer
diegomarquezp 3fffa13
format
diegomarquezp 5504d21
Merge remote-tracking branch 'origin/main' into gapic-generator-no-se…
diegomarquezp 95696c0
Merge branch 'main' into gapic-generator-no-service-noop
diegomarquezp e1fe64d
restore outputstream flush() and finish()
diegomarquezp bf5d28f
simplify java package parsing
diegomarquezp f9bbc7f
move library_generation scripts adaptation to a follow up PR
diegomarquezp 31aa98d
fix java package logic
diegomarquezp 0c43cb5
format
diegomarquezp 3e4a2d6
remove redundant exception handling
diegomarquezp cb5c605
format
diegomarquezp 7315c5d
decompose java package logic
diegomarquezp 1931845
add special test for production function
diegomarquezp 7df26e2
use EMPTY instead of empty() in GapicPackageInfo
diegomarquezp 080d8e6
use EMPTY instead of empty() in PackageInfoDefinition
diegomarquezp f5e4342
close jar output stream in a single call
diegomarquezp ab02afa
use EMPTY instead of empty() in GapicContext
diegomarquezp 347b8cd
compute isEmpty() dynamically in GapicContext
diegomarquezp 5b5f13f
compute isEmpty() dynamically in GapicPackageInfo
diegomarquezp 64e8ef3
compute isEmpty() dynamically in PackageInfoDefinition
diegomarquezp c1e7d9e
make addApacheLicense package-private
diegomarquezp c4dff95
rename isEmpty to containsServices in GapicCOntext
diegomarquezp 20ad638
make parseServiceJavaPackage package-private
diegomarquezp 28e6168
remove redundant empty check logic
diegomarquezp b86dd2a
remove redundant warning
diegomarquezp 8d76c06
format
diegomarquezp fd7cc3b
do not generate a srcjar if no services were found
diegomarquezp 3ee8163
modify warning message
diegomarquezp 1e3578d
Merge remote-tracking branch 'origin/main' into gapic-generator-no-se…
diegomarquezp c5286e2
Writer to return null response when no services are found
diegomarquezp 09f3722
remove Composer changes
diegomarquezp 49b139a
revert unnecessary changes involving GapicPackageInfo
diegomarquezp 0e73927
Remove empty lines
diegomarquezp dc542b3
improve coverage
diegomarquezp 0838d76
fix from comments
diegomarquezp 2abdfb5
more test fixes
diegomarquezp 93270e6
Merge branch 'main' into gapic-generator-no-service-noop
diegomarquezp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,10 @@ | |
|
||
package com.google.api.generator.gapic.composer; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import com.google.api.generator.engine.ast.ClassDefinition; | ||
import com.google.api.generator.engine.ast.ScopeNode; | ||
|
@@ -35,6 +37,7 @@ | |
import java.nio.file.Paths; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class ComposerTest { | ||
|
@@ -53,8 +56,13 @@ class ComposerTest { | |
.build(); | ||
private List<Sample> ListofSamples = Arrays.asList(new Sample[] {sample}); | ||
|
||
@BeforeEach | ||
void initialSanityCheck() { | ||
assertTrue(context.containsServices()); | ||
} | ||
|
||
@Test | ||
void gapicClass_addApacheLicense() { | ||
public void gapicClass_addApacheLicense_validInput_succeeds() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
ClassDefinition classDef = | ||
ClassDefinition.builder() | ||
.setPackageString("com.google.showcase.v1beta1.stub") | ||
|
@@ -84,14 +92,14 @@ void composeSamples_showcase() { | |
assertFalse(composedSamples.isEmpty()); | ||
for (Sample sample : composedSamples) { | ||
assertEquals( | ||
"File header should be APACHE", | ||
Arrays.asList(CommentComposer.APACHE_LICENSE_COMMENT), | ||
sample.fileHeader()); | ||
sample.fileHeader(), | ||
"File header should be APACHE"); | ||
assertEquals( | ||
"ApiShortName should be Localhost7469", | ||
"Localhost7469", | ||
sample.regionTag().apiShortName()); | ||
assertEquals("ApiVersion should be V1Beta1", "V1Beta1", sample.regionTag().apiVersion()); | ||
sample.regionTag().apiShortName(), | ||
"ApiShortName should be Localhost7469"); | ||
assertEquals("V1Beta1", sample.regionTag().apiVersion(), "ApiVersion should be V1Beta1"); | ||
} | ||
} | ||
|
||
|
@@ -120,10 +128,10 @@ void composeSamples_parseProtoPackage() { | |
|
||
for (Sample sample : composedSamples) { | ||
assertEquals( | ||
"ApiShortName should be Accessapproval", | ||
"Accessapproval", | ||
sample.regionTag().apiShortName(), | ||
"Accessapproval"); | ||
assertEquals("ApiVersion should be V1", sample.regionTag().apiVersion(), "V1"); | ||
"ApiShortName should be Accessapproval"); | ||
assertEquals("V1", sample.regionTag().apiVersion(), "ApiVersion should be V1"); | ||
} | ||
|
||
protoPack = "google.cloud.vision.v1p1beta1"; | ||
|
@@ -136,8 +144,8 @@ void composeSamples_parseProtoPackage() { | |
assertFalse(composedSamples.isEmpty()); | ||
|
||
for (Sample sample : composedSamples) { | ||
assertEquals("ApiShortName should be Vision", sample.regionTag().apiShortName(), "Vision"); | ||
assertEquals("ApiVersion should be V1P1Beta1", sample.regionTag().apiVersion(), "V1P1Beta1"); | ||
assertEquals("Vision", sample.regionTag().apiShortName(), "ApiShortName should be Vision"); | ||
assertEquals("V1P1Beta1", sample.regionTag().apiVersion(), "ApiVersion should be V1P1Beta1"); | ||
} | ||
|
||
protoPack = "google.cloud.vision"; | ||
|
@@ -149,11 +157,21 @@ void composeSamples_parseProtoPackage() { | |
assertFalse(composedSamples.isEmpty()); | ||
|
||
for (Sample sample : composedSamples) { | ||
assertEquals("ApiShortName should be Vision", sample.regionTag().apiShortName(), "Vision"); | ||
assertEquals("ApiVersion should be empty", sample.regionTag().apiVersion(), ""); | ||
assertEquals("Vision", sample.regionTag().apiShortName(), "ApiShortName should be Vision"); | ||
assertTrue(sample.regionTag().apiVersion().isEmpty(), "ApiVersion should be empty"); | ||
} | ||
} | ||
|
||
@Test | ||
void testEmptyGapicContext_doesNotThrow() { | ||
assertTrue(Composer.composeServiceClasses(GapicContext.EMPTY).isEmpty()); | ||
} | ||
|
||
@Test | ||
void testComposePackageInfo_emptyGapicContext_returnsNull() { | ||
assertNull(Composer.composePackageInfo(GapicContext.EMPTY)); | ||
} | ||
|
||
private List<GapicClass> getTestClassListFromService(Service testService) { | ||
GapicClass testClass = | ||
GrpcServiceCallableFactoryClassComposer.instance() | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.