Search in sources :

Example 81 with Service

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

the class TestProtoLoader method parseDeprecatedService.

public GapicContext parseDeprecatedService() {
    FileDescriptor fileDescriptor = DeprecatedServiceOuterClass.getDescriptor();
    ServiceDescriptor serviceDescriptor = fileDescriptor.getServices().get(0);
    assertEquals(serviceDescriptor.getName(), "DeprecatedService");
    Map<String, Message> messageTypes = Parser.parseMessages(fileDescriptor);
    Map<String, ResourceName> resourceNames = new HashMap<>();
    Set<ResourceName> outputResourceNames = new HashSet<>();
    List<Service> services = Parser.parseService(fileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames);
    String jsonFilename = "deprecated_service_grpc_service_config.json";
    Path jsonPath = Paths.get(testFilesDirectory, jsonFilename);
    Optional<GapicServiceConfig> configOpt = ServiceConfigParser.parse(jsonPath.toString());
    assertTrue(configOpt.isPresent());
    GapicServiceConfig config = configOpt.get();
    return GapicContext.builder().setMessages(messageTypes).setResourceNames(resourceNames).setServices(services).setServiceConfig(config).setHelperResourceNames(outputResourceNames).setTransport(transport).build();
}
Also used : Path(java.nio.file.Path) Message(com.google.api.generator.gapic.model.Message) HashMap(java.util.HashMap) ResourceName(com.google.api.generator.gapic.model.ResourceName) Service(com.google.api.generator.gapic.model.Service) GapicServiceConfig(com.google.api.generator.gapic.model.GapicServiceConfig) FileDescriptor(com.google.protobuf.Descriptors.FileDescriptor) ServiceDescriptor(com.google.protobuf.Descriptors.ServiceDescriptor) HashSet(java.util.HashSet)

Example 82 with Service

use of com.google.api.generator.gapic.model.Service 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)

Example 83 with Service

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

the class GrpcServiceCallableFactoryClassComposerTest method generateServiceClasses_deprecated.

@Test
public void generateServiceClasses_deprecated() {
    GapicContext context = GrpcTestProtoLoader.instance().parseDeprecatedService();
    Service protoService = context.services().get(0);
    GapicClass clazz = GrpcServiceCallableFactoryClassComposer.instance().generate(context, protoService);
    Assert.assertGoldenClass(this.getClass(), clazz, "GrpcDeprecatedServiceCallableFactory.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)

Example 84 with Service

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

the class GrpcServiceStubClassComposerTest method generateGrpcServiceStubClass_routingHeaders.

@Test
public void generateGrpcServiceStubClass_routingHeaders() {
    GapicContext context = GrpcTestProtoLoader.instance().parseExplicitDynamicRoutingHeaderTesting();
    Service service = context.services().get(0);
    GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, service);
    Assert.assertGoldenClass(this.getClass(), clazz, "GrpcRoutingHeadersStub.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)

Example 85 with Service

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

the class GrpcServiceStubClassComposerTest method generateGrpcServiceStubClass_simple.

@Test
public void generateGrpcServiceStubClass_simple() {
    GapicContext context = GrpcTestProtoLoader.instance().parseShowcaseEcho();
    Service echoProtoService = context.services().get(0);
    GapicClass clazz = GrpcServiceStubClassComposer.instance().generate(context, echoProtoService);
    Assert.assertGoldenClass(this.getClass(), clazz, "GrpcEchoStub.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

Service (com.google.api.generator.gapic.model.Service)87 GapicContext (com.google.api.generator.gapic.model.GapicContext)54 GapicClass (com.google.api.generator.gapic.model.GapicClass)48 Message (com.google.api.generator.gapic.model.Message)45 Test (org.junit.Test)45 Method (com.google.api.generator.gapic.model.Method)39 List (java.util.List)39 TypeNode (com.google.api.generator.engine.ast.TypeNode)37 ResourceName (com.google.api.generator.gapic.model.ResourceName)35 Expr (com.google.api.generator.engine.ast.Expr)34 VariableExpr (com.google.api.generator.engine.ast.VariableExpr)32 GapicServiceConfig (com.google.api.generator.gapic.model.GapicServiceConfig)32 ArrayList (java.util.ArrayList)32 Arrays (java.util.Arrays)32 Collectors (java.util.stream.Collectors)32 Path (java.nio.file.Path)31 HashSet (java.util.HashSet)31 Function (java.util.function.Function)31 ConcreteReference (com.google.api.generator.engine.ast.ConcreteReference)30 Preconditions (com.google.common.base.Preconditions)30