Skip to content

[ggj][codegen] feat: add GrpcPublisherStub test to exercise HTTP subfields #403

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 8 commits into from
Oct 24, 2020
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
import com.google.api.generator.test.framework.Utils;
import com.google.protobuf.Descriptors.FileDescriptor;
import com.google.protobuf.Descriptors.ServiceDescriptor;
import com.google.pubsub.v1.PubsubProto;
import com.google.showcase.v1beta1.EchoOuterClass;
import com.google.showcase.v1beta1.TestingOuterClass;
import google.cloud.CommonResources;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -82,4 +85,33 @@ public void generateGrpcServiceStubClass_httpBindings() {
Paths.get(ComposerConstants.GOLDENFILES_DIRECTORY, "GrpcTestingStub.golden");
Assert.assertCodeEquals(goldenFilePath, visitor.write());
}

@Test
public void generateGrpcServiceStubClass_httpBindingsWithSubMessageFields() {
FileDescriptor serviceFileDescriptor = PubsubProto.getDescriptor();
FileDescriptor commonResourcesFileDescriptor = CommonResources.getDescriptor();
ServiceDescriptor serviceDescriptor = serviceFileDescriptor.getServices().get(0);
assertEquals("Publisher", serviceDescriptor.getName());

Map<String, ResourceName> resourceNames = new HashMap<>();
resourceNames.putAll(Parser.parseResourceNames(serviceFileDescriptor));
resourceNames.putAll(Parser.parseResourceNames(commonResourcesFileDescriptor));

Map<String, Message> messageTypes = Parser.parseMessages(serviceFileDescriptor);

Set<ResourceName> outputResourceNames = new HashSet<>();
List<Service> services =
Parser.parseService(
serviceFileDescriptor, messageTypes, resourceNames, outputResourceNames);

Service service = services.get(0);
GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(service, messageTypes);

JavaWriterVisitor visitor = new JavaWriterVisitor();
clazz.classDefinition().accept(visitor);
Utils.saveCodegenToFile(this.getClass(), "GrpcPublisherStub.golden", visitor.write());
Path goldenFilePath =
Paths.get(ComposerConstants.GOLDENFILES_DIRECTORY, "GrpcPublisherStub.golden");
Assert.assertCodeEquals(goldenFilePath, visitor.write());
}
}
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy