use of com.google.api.generator.engine.writer.JavaWriterVisitor in project gapic-generator-java by googleapis.
the class ResourceNameHelperClassComposerTest method generateResourceNameClass_testingBlueprintPatternWithNonSlashSeparator.
@Test
public void generateResourceNameClass_testingBlueprintPatternWithNonSlashSeparator() {
FileDescriptor testingFileDescriptor = TestingOuterClass.getDescriptor();
ServiceDescriptor testingService = testingFileDescriptor.getServices().get(0);
assertEquals(testingService.getName(), "Testing");
Map<String, Message> messageTypes = Parser.parseMessages(testingFileDescriptor);
Map<String, ResourceName> resourceNames = Parser.parseResourceNames(testingFileDescriptor);
Set<ResourceName> outputResourceNames = new HashSet<>();
Parser.parseService(testingFileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames);
ResourceName testResname = resourceNames.get("showcase.googleapis.com/Test");
assertThat(outputResourceNames).contains(testResname);
GapicClass clazz = ResourceNameHelperClassComposer.instance().generate(testResname, TestProtoLoader.instance().parseShowcaseTesting());
JavaWriterVisitor visitor = new JavaWriterVisitor();
clazz.classDefinition().accept(visitor);
Utils.saveCodegenToFile(this.getClass(), "TestName.golden", visitor.write());
Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "TestName.golden");
Assert.assertCodeEquals(goldenFilePath, visitor.write());
}
use of com.google.api.generator.engine.writer.JavaWriterVisitor in project gapic-generator-java by googleapis.
the class HttpJsonServiceCallableFactoryClassComposerTest method generateServiceClasses.
@Test
public void generateServiceClasses() {
GapicContext context = RestTestProtoLoader.instance().parseCompliance();
Service echoProtoService = context.services().get(0);
GapicClass clazz = HttpJsonServiceCallableFactoryClassComposer.instance().generate(context, echoProtoService);
JavaWriterVisitor visitor = new JavaWriterVisitor();
clazz.classDefinition().accept(visitor);
Utils.saveCodegenToFile(this.getClass(), "HttpJsonComplianceCallableFactory.golden", visitor.write());
Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "HttpJsonComplianceCallableFactory.golden");
Assert.assertCodeEquals(goldenFilePath, visitor.write());
}
use of com.google.api.generator.engine.writer.JavaWriterVisitor in project gapic-generator-java by googleapis.
the class HttpJsonServiceStubClassComposerTest method generateServiceClasses.
@Test
public void generateServiceClasses() {
GapicContext context = RestTestProtoLoader.instance().parseCompliance();
Service echoProtoService = context.services().get(0);
GapicClass clazz = HttpJsonServiceStubClassComposer.instance().generate(context, echoProtoService);
JavaWriterVisitor visitor = new JavaWriterVisitor();
clazz.classDefinition().accept(visitor);
Utils.saveCodegenToFile(this.getClass(), "HttpJsonComplianceStub.golden", visitor.write());
Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "HttpJsonComplianceStub.golden");
Assert.assertCodeEquals(goldenFilePath, visitor.write());
}
use of com.google.api.generator.engine.writer.JavaWriterVisitor in project gapic-generator-java by googleapis.
the class ServiceClientTestClassComposerTest method generateServiceClasses.
@Test
public void generateServiceClasses() {
GapicContext context = RestTestProtoLoader.instance().parseCompliance();
Service echoProtoService = context.services().get(0);
GapicClass clazz = ServiceClientTestClassComposer.instance().generate(context, echoProtoService);
JavaWriterVisitor visitor = new JavaWriterVisitor();
clazz.classDefinition().accept(visitor);
Utils.saveCodegenToFile(this.getClass(), "ComplianceClientTest.golden", visitor.write());
Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "ComplianceClientTest.golden");
assertCodeEquals(goldenFilePath, visitor.write());
}
use of com.google.api.generator.engine.writer.JavaWriterVisitor in project gapic-generator-java by googleapis.
the class GrpcServiceStubClassComposerTest method generateServiceClasses.
@Test
public void generateServiceClasses() {
GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho();
Service echoProtoService = context.services().get(0);
GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, echoProtoService);
JavaWriterVisitor visitor = new JavaWriterVisitor();
clazz.classDefinition().accept(visitor);
Utils.saveCodegenToFile(this.getClass(), "GrpcEchoStub.golden", visitor.write());
Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "GrpcEchoStub.golden");
Assert.assertCodeEquals(goldenFilePath, visitor.write());
}
Aggregations