Skip to content

Commit 1f5be4b

Browse files
committed
fix merging mistake and lint.
1 parent 4a75bfd commit 1f5be4b

File tree

4 files changed

+59
-12
lines changed

4 files changed

+59
-12
lines changed

gapic-generator-java/src/test/java/com/google/api/generator/gapic/composer/grpc/GrpcServiceStubClassComposerTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ void generateGrpcServiceStubClass_autopopulateField() {
9393
Assert.assertEmptySamples(clazz.samples());
9494
}
9595

96+
@Test
97+
void generateGrpcServiceStubClass_callableNameType() {
98+
GapicContext context = GrpcTestProtoLoader.instance().parseCallabeNameType();
99+
Service service = context.services().get(0);
100+
GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, service);
101+
Assert.assertGoldenClass(this.getClass(), clazz, "GrpcCallableNameTypeStub.golden");
102+
Assert.assertEmptySamples(clazz.samples());
103+
}
104+
96105
@Test
97106
void generateGrpcServiceStubClass_selectiveGeneration() {
98107
GapicContext context = GrpcTestProtoLoader.instance().parseSelectiveGenerationTesting();

gapic-generator-java/src/test/java/com/google/api/generator/gapic/protoparser/ParserTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,14 @@
2222
import static org.junit.jupiter.api.Assertions.assertTrue;
2323
import static org.mockito.Mockito.when;
2424

25-
import com.google.api.*;
25+
import com.google.api.ClientLibrarySettings;
26+
import com.google.api.CommonLanguageSettings;
27+
import com.google.api.CppSettings;
2628
import com.google.api.FieldInfo.Format;
29+
import com.google.api.MethodSettings;
30+
import com.google.api.Publishing;
31+
import com.google.api.SelectiveGapicGeneration;
32+
import com.google.api.Service;
2733
import com.google.api.generator.engine.ast.ConcreteReference;
2834
import com.google.api.generator.engine.ast.Reference;
2935
import com.google.api.generator.engine.ast.TypeNode;

gapic-generator-java/src/test/java/com/google/api/generator/test/protoloader/TestProtoLoader.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@
4444
import com.google.showcase.v1beta1.IdentityOuterClass;
4545
import com.google.showcase.v1beta1.MessagingOuterClass;
4646
import com.google.showcase.v1beta1.TestingOuterClass;
47+
import com.google.test.callablenamingtype.CallableNameType;
4748
import com.google.testdata.v1.DeprecatedServiceOuterClass;
4849
import com.google.testgapic.v1beta1.NestedMessageProto;
4950
import com.google.types.testing.TypesTestingProto;
5051
import google.cloud.CommonResources;
5152
import java.nio.file.Path;
5253
import java.nio.file.Paths;
5354
import java.util.Arrays;
55+
import java.util.Collections;
5456
import java.util.HashMap;
5557
import java.util.HashSet;
5658
import java.util.List;
@@ -501,6 +503,42 @@ public GapicContext parseLogging() {
501503
.build();
502504
}
503505

506+
public GapicContext parseCallabeNameType() {
507+
FileDescriptor serviceFileDescriptor = CallableNameType.getDescriptor();
508+
ServiceDescriptor serviceDescriptor = serviceFileDescriptor.getServices().get(0);
509+
assertEquals(serviceDescriptor.getName(), "CallableNameTypeService");
510+
511+
List<FileDescriptor> protoFiles = Collections.singletonList(serviceFileDescriptor);
512+
513+
Map<String, ResourceName> resourceNames = new HashMap<>();
514+
Map<String, Message> messageTypes = new HashMap<>();
515+
for (FileDescriptor fileDescriptor : protoFiles) {
516+
resourceNames.putAll(Parser.parseResourceNames(fileDescriptor));
517+
messageTypes.putAll(Parser.parseMessages(fileDescriptor));
518+
}
519+
520+
// Additional resource names.
521+
FileDescriptor commonResourcesFileDescriptor = CommonResources.getDescriptor();
522+
resourceNames.putAll(Parser.parseResourceNames(commonResourcesFileDescriptor));
523+
524+
Set<ResourceName> outputResourceNames = new HashSet<>();
525+
List<Service> services =
526+
Parser.parseService(
527+
serviceFileDescriptor,
528+
messageTypes,
529+
resourceNames,
530+
Optional.empty(),
531+
outputResourceNames);
532+
533+
return GapicContext.builder()
534+
.setMessages(messageTypes)
535+
.setResourceNames(resourceNames)
536+
.setServices(services)
537+
.setHelperResourceNames(outputResourceNames)
538+
.setTransport(transport)
539+
.build();
540+
}
541+
504542
public String getTestFilesDirectory() {
505543
return testFilesDirectory;
506544
}

gapic-generator-java/src/test/proto/selective_api_generation.proto

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ option (google.api.resource_definition) = {
3939
// This proto is used to test selective api generation
4040
// covered scenarios:
4141
// - A service with several rpcs, part of them should be generated
42-
// - A service with several rpcs, non of them should be generated
42+
// - A service with several rpcs, none of them should be generated
4343
// This proto should be tested side-by-side with yaml file:
4444
// - selective_api_generation_v1beta1.yaml
4545

@@ -51,10 +51,7 @@ service EchoServiceShouldGeneratePartial {
5151
post: "/v1beta1/echo:echo"
5252
body: "*"
5353
};
54-
option (google.api.method_signature) = "content";
55-
option (google.api.method_signature) = "error";
5654
option (google.api.method_signature) = "name";
57-
option (google.api.method_signature) = "parent";
5855
option (google.api.method_signature) = "";
5956
}
6057

@@ -71,13 +68,10 @@ service EchoServiceShouldGeneratePartial {
7168
}
7269

7370
service EchoServiceShouldGenerateNone {
74-
// This service is meant to only run locally on the port 7469 (keypad digits
75-
// for "show").
7671
option (google.api.default_host) = "localhost:7469";
7772
option (google.api.oauth_scopes) =
7873
"https://www.googleapis.com/auth/cloud-platform";
7974

80-
// This method simply echos the request. This method is showcases unary rpcs.
8175
rpc Echo(EchoRequest) returns (EchoResponse) {
8276
option (google.api.method_signature) = "content";
8377
}
@@ -110,7 +104,7 @@ message Foobarbaz {
110104
string info = 2;
111105
}
112106

113-
// The request message used both RPCs in inclusion list and not.
107+
// RPCs in inclusion list and not in the list both relies on this request message.
114108
message EchoRequest {
115109
string name = 5 [
116110
(google.api.resource_reference).type = "showcase.googleapis.com/Foobar",
@@ -134,10 +128,10 @@ message EchoRequest {
134128
Foobar foobar = 4;
135129
}
136130

137-
// The request message used for ShouldNotGenerateChat method.
138-
// To demonstrate that if ShouldNotGenerateChat is not included in generation,
131+
// This request message is used by AnExcludedMethod rpc.
132+
// To demonstrate that if AnExcludedMethod is not included in generation,
139133
// then the resource name Foobarbaz, which is only used by this method,
140-
// should also not be generated.
134+
// should not be generated.
141135
message EchoRequestWithFoobarbaz {
142136
string name = 5 [
143137
(google.api.resource_reference).type = "showcase.googleapis.com/Foobarbaz",

0 commit comments

Comments
 (0)