-
Couldn't load subscription status.
- Fork 71
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
Changes from all commits
00c1eb1
d150747
a79329f
96b357b
4bc092a
0372f9e
392305a
97a38ad
204fff8
4d85490
7e06287
45c1ff5
6c8aa53
c2ca534
f5d595c
a58b4ef
0ff112e
1639b61
69fce38
799b23e
4caa419
71cc3f3
827e27e
4eccad0
bfe0d6c
9678c7b
dd140d2
3fd8bfa
1634112
3fffa13
5504d21
95696c0
e1fe64d
bf5d28f
f9bbc7f
31aa98d
0c43cb5
3e4a2d6
cb5c605
7315c5d
1931845
7df26e2
080d8e6
f5e4342
ab02afa
347b8cd
5b5f13f
64e8ef3
c1e7d9e
c4dff95
20ad638
28e6168
b86dd2a
8d76c06
fd7cc3b
3ee8163
1e3578d
c5286e2
09f3722
49b139a
0e73927
dc542b3
0838d76
2abdfb5
93270e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.