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 = GrpcRestTestProtoLoader.instance().parseShowcaseEcho();
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(), "HttpJsonEchoCallableFactory.golden", visitor.write());
Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "HttpJsonEchoCallableFactory.golden");
Assert.assertCodeEquals(goldenFilePath, visitor.write());
}
use of com.google.api.generator.engine.writer.JavaWriterVisitor in project gapic-generator-java by googleapis.
the class HttpJsonServiceClientTestClassComposerTest method generateServiceClasses.
@Test
public void generateServiceClasses() {
GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho();
Service echoProtoService = context.services().get(0);
GapicClass clazz = HttpJsonServiceClientTestClassComposer.instance().generate(context, echoProtoService);
JavaWriterVisitor visitor = new JavaWriterVisitor();
clazz.classDefinition().accept(visitor);
Utils.saveCodegenToFile(this.getClass(), "EchoClientHttpJsonTest.golden", visitor.write());
Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "EchoClientHttpJsonTest.golden");
assertCodeEquals(goldenFilePath, visitor.write());
}
use of com.google.api.generator.engine.writer.JavaWriterVisitor in project gapic-generator-java by googleapis.
the class ServiceClientClassComposerTest method generateServiceClassesEmpty.
@Test
public void generateServiceClassesEmpty() {
GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho();
Service echoProtoService = context.services().get(1);
GapicClass clazz = ServiceClientClassComposer.instance().generate(context, echoProtoService);
JavaWriterVisitor visitor = new JavaWriterVisitor();
clazz.classDefinition().accept(visitor);
Utils.saveCodegenToFile(this.getClass(), "EchoEmpty.golden", visitor.write());
Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "EchoEmpty.golden");
Assert.assertCodeEquals(goldenFilePath, visitor.write());
}
use of com.google.api.generator.engine.writer.JavaWriterVisitor in project gapic-generator-java by googleapis.
the class ServiceClientClassComposerTest method generateServiceClasses.
@Test
public void generateServiceClasses() {
GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho();
Service echoProtoService = context.services().get(0);
GapicClass clazz = ServiceClientClassComposer.instance().generate(context, echoProtoService);
JavaWriterVisitor visitor = new JavaWriterVisitor();
clazz.classDefinition().accept(visitor);
Utils.saveCodegenToFile(this.getClass(), "EchoClient.golden", visitor.write());
Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "EchoClient.golden");
Assert.assertCodeEquals(goldenFilePath, visitor.write());
}
use of com.google.api.generator.engine.writer.JavaWriterVisitor in project gapic-generator-java by googleapis.
the class Assert method assertGoldenClass.
public static void assertGoldenClass(Class<?> clazz, GapicClass gapicClass, String fileName) {
JavaWriterVisitor visitor = new JavaWriterVisitor();
gapicClass.classDefinition().accept(visitor);
Utils.saveCodegenToFile(clazz, fileName, visitor.write());
Path goldenFilePath = Paths.get(Utils.getGoldenDir(clazz), fileName);
Assert.assertCodeEquals(goldenFilePath, visitor.write());
}
Aggregations