Search in sources :

Example 36 with GapicClass

use of com.google.api.generator.gapic.model.GapicClass 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());
}
Also used : Path(java.nio.file.Path) GapicClass(com.google.api.generator.gapic.model.GapicClass) Service(com.google.api.generator.gapic.model.Service) JavaWriterVisitor(com.google.api.generator.engine.writer.JavaWriterVisitor) GapicContext(com.google.api.generator.gapic.model.GapicContext) Test(org.junit.Test)

Example 37 with GapicClass

use of com.google.api.generator.gapic.model.GapicClass 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());
}
Also used : Path(java.nio.file.Path) GapicClass(com.google.api.generator.gapic.model.GapicClass) Service(com.google.api.generator.gapic.model.Service) JavaWriterVisitor(com.google.api.generator.engine.writer.JavaWriterVisitor) GapicContext(com.google.api.generator.gapic.model.GapicContext) Test(org.junit.Test)

Example 38 with GapicClass

use of com.google.api.generator.gapic.model.GapicClass 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());
}
Also used : Path(java.nio.file.Path) GapicClass(com.google.api.generator.gapic.model.GapicClass) Service(com.google.api.generator.gapic.model.Service) JavaWriterVisitor(com.google.api.generator.engine.writer.JavaWriterVisitor) GapicContext(com.google.api.generator.gapic.model.GapicContext) Test(org.junit.Test)

Example 39 with GapicClass

use of com.google.api.generator.gapic.model.GapicClass 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());
}
Also used : Path(java.nio.file.Path) GapicClass(com.google.api.generator.gapic.model.GapicClass) Service(com.google.api.generator.gapic.model.Service) JavaWriterVisitor(com.google.api.generator.engine.writer.JavaWriterVisitor) GapicContext(com.google.api.generator.gapic.model.GapicContext) Test(org.junit.Test)

Example 40 with GapicClass

use of com.google.api.generator.gapic.model.GapicClass in project gapic-generator-java by googleapis.

the class GrpcServiceCallableFactoryClassComposerTest method generateServiceClasses.

@Test
public void generateServiceClasses() {
    GapicContext context = GrpcTestProtoLoader.instance().parseShowcaseEcho();
    Service echoProtoService = context.services().get(0);
    GapicClass clazz = GrpcServiceCallableFactoryClassComposer.instance().generate(context, echoProtoService);
    Assert.assertGoldenClass(this.getClass(), clazz, "GrpcEchoCallableFactory.golden");
    Assert.assertEmptySamples(clazz.samples());
}
Also used : GapicClass(com.google.api.generator.gapic.model.GapicClass) Service(com.google.api.generator.gapic.model.Service) GapicContext(com.google.api.generator.gapic.model.GapicContext) Test(org.junit.Test)

Aggregations

GapicClass (com.google.api.generator.gapic.model.GapicClass)45 Test (org.junit.Test)35 Service (com.google.api.generator.gapic.model.Service)29 GapicContext (com.google.api.generator.gapic.model.GapicContext)24 JavaWriterVisitor (com.google.api.generator.engine.writer.JavaWriterVisitor)21 Path (java.nio.file.Path)20 ClassDefinition (com.google.api.generator.engine.ast.ClassDefinition)9 TypeStore (com.google.api.generator.gapic.composer.store.TypeStore)8 Kind (com.google.api.generator.gapic.model.GapicClass.Kind)8 Message (com.google.api.generator.gapic.model.Message)7 ResourceName (com.google.api.generator.gapic.model.ResourceName)7 HashSet (java.util.HashSet)4 FileDescriptor (com.google.protobuf.Descriptors.FileDescriptor)3 ServiceDescriptor (com.google.protobuf.Descriptors.ServiceDescriptor)3 CommentStatement (com.google.api.generator.engine.ast.CommentStatement)2 VariableExpr (com.google.api.generator.engine.ast.VariableExpr)2 StubCommentComposer (com.google.api.generator.gapic.composer.comment.StubCommentComposer)2 Sample (com.google.api.generator.gapic.model.Sample)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2