Search in sources :

Example 6 with GapicContext

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

the class ServiceStubSettingsClassComposerTest method generateServiceClasses.

@Test
public void generateServiceClasses() {
    GapicContext context = RestTestProtoLoader.instance().parseCompliance();
    Service echoProtoService = context.services().get(0);
    GapicClass clazz = ServiceStubSettingsClassComposer.instance().generate(context, echoProtoService);
    JavaWriterVisitor visitor = new JavaWriterVisitor();
    clazz.classDefinition().accept(visitor);
    Utils.saveCodegenToFile(this.getClass(), "ComplianceStubSettings.golden", visitor.write());
    Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "ComplianceStubSettings.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 7 with GapicContext

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

the class ServiceSettingsClassComposerTest method generateServiceClasses.

@Test
public void generateServiceClasses() {
    GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho();
    Service echoProtoService = context.services().get(0);
    GapicClass clazz = ServiceSettingsClassComposer.instance().generate(context, echoProtoService);
    JavaWriterVisitor visitor = new JavaWriterVisitor();
    clazz.classDefinition().accept(visitor);
    Utils.saveCodegenToFile(this.getClass(), "EchoSettings.golden", visitor.write());
    Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "EchoSettings.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 8 with GapicContext

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

the class ResourceNameHelperClassComposerTest method generateResourceNameClass_childSingleton.

@Test
public void generateResourceNameClass_childSingleton() {
    ResourceName agentResname = ResourceName.builder().setVariableName("agent").setPakkage("com.google.cloud.dialogflow.v2beta1").setResourceTypeString("dialogflow.googleapis.com/Agent").setPatterns(Arrays.asList("projects/{project}/locations/{location}/agent", "projects/{project}/agent")).setParentMessageName("Agent").setDescription("This is a description").build();
    GapicContext irrelevantContext = TestProtoLoader.instance().parseShowcaseEcho();
    GapicClass clazz = ResourceNameHelperClassComposer.instance().generate(agentResname, irrelevantContext);
    JavaWriterVisitor visitor = new JavaWriterVisitor();
    clazz.classDefinition().accept(visitor);
    Utils.saveCodegenToFile(this.getClass(), "AgentName.golden", visitor.write());
    Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "AgentName.golden");
    Assert.assertCodeEquals(goldenFilePath, visitor.write());
}
Also used : Path(java.nio.file.Path) ResourceName(com.google.api.generator.gapic.model.ResourceName) GapicClass(com.google.api.generator.gapic.model.GapicClass) JavaWriterVisitor(com.google.api.generator.engine.writer.JavaWriterVisitor) GapicContext(com.google.api.generator.gapic.model.GapicContext) Test(org.junit.Test)

Example 9 with GapicContext

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

the class GrpcServiceCallableFactoryClassComposerTest method generateServiceClasses.

@Test
public void generateServiceClasses() {
    GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho();
    Service echoProtoService = context.services().get(0);
    GapicClass clazz = GrpcServiceCallableFactoryClassComposer.instance().generate(context, echoProtoService);
    JavaWriterVisitor visitor = new JavaWriterVisitor();
    clazz.classDefinition().accept(visitor);
    Utils.saveCodegenToFile(this.getClass(), "GrpcEchoCallableFactory.golden", visitor.write());
    Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "GrpcEchoCallableFactory.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 10 with GapicContext

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

the class HttpJsonServiceStubClassComposerTest method generateServiceClasses.

@Test
public void generateServiceClasses() {
    GapicContext context = GrpcRestTestProtoLoader.instance().parseShowcaseEcho();
    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(), "HttpJsonEchoStub.golden", visitor.write());
    Path goldenFilePath = Paths.get(Utils.getGoldenDir(this.getClass()), "HttpJsonEchoStub.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)

Aggregations

GapicContext (com.google.api.generator.gapic.model.GapicContext)36 Service (com.google.api.generator.gapic.model.Service)34 Test (org.junit.Test)29 GapicClass (com.google.api.generator.gapic.model.GapicClass)27 Path (java.nio.file.Path)19 JavaWriterVisitor (com.google.api.generator.engine.writer.JavaWriterVisitor)15 List (java.util.List)10 Expr (com.google.api.generator.engine.ast.Expr)8 TypeNode (com.google.api.generator.engine.ast.TypeNode)8 VariableExpr (com.google.api.generator.engine.ast.VariableExpr)8 Collectors (java.util.stream.Collectors)8 AnnotationNode (com.google.api.generator.engine.ast.AnnotationNode)7 ConcreteReference (com.google.api.generator.engine.ast.ConcreteReference)7 Message (com.google.api.generator.gapic.model.Message)7 Method (com.google.api.generator.gapic.model.Method)7 ResourceName (com.google.api.generator.gapic.model.ResourceName)7 Preconditions (com.google.common.base.Preconditions)7 ArrayList (java.util.ArrayList)7 Arrays (java.util.Arrays)7 Map (java.util.Map)7