use of com.google.api.generator.gapic.model.GapicServiceConfig in project gapic-generator-java by googleapis.
the class RetrySettingsComposerTest method batchingSettings_minimalFlowControlSettings.
@Test
public void batchingSettings_minimalFlowControlSettings() {
String filename = "pubsub_gapic.yaml";
Path path = Paths.get(TestProtoLoader.instance().getTestFilesDirectory(), filename);
Optional<List<GapicBatchingSettings>> batchingSettingsOpt = BatchingSettingsConfigParser.parse(Optional.of(path.toString()));
assertTrue(batchingSettingsOpt.isPresent());
String jsonFilename = "pubsub_grpc_service_config.json";
Path jsonPath = Paths.get(TestProtoLoader.instance().getTestFilesDirectory(), jsonFilename);
Optional<GapicServiceConfig> configOpt = ServiceConfigParser.parse(jsonPath.toString());
assertTrue(configOpt.isPresent());
GapicServiceConfig config = configOpt.get();
config.setBatchingSettings(batchingSettingsOpt);
GapicContext context = TestProtoLoader.instance().parsePubSubPublisher();
Service service = context.services().get(0);
assertEquals("Publisher", service.name());
VariableExpr builderVarExpr = createBuilderVarExpr(service);
String methodSettingsName = "publishSettings";
GapicBatchingSettings batchingSettings = GapicBatchingSettings.builder().setProtoPakkage("com.google.pubsub.v1").setServiceName("Publishing").setMethodName("Publish").setElementCountThreshold(100).setRequestByteThreshold(1048576).setDelayThresholdMillis(10).setBatchedFieldName("messages").setDiscriminatorFieldNames(Arrays.asList("topic")).setSubresponseFieldName("message_ids").build();
Expr builderExpr = RetrySettingsComposer.createBatchingBuilderSettingsExpr(methodSettingsName, batchingSettings, builderVarExpr);
builderExpr.accept(writerVisitor);
String expected = "builder" + ".publishSettings()" + ".setBatchingSettings(" + "BatchingSettings.newBuilder()" + ".setElementCountThreshold(100L)" + ".setRequestByteThreshold(1048576L)" + ".setDelayThreshold(Duration.ofMillis(10L))" + ".setFlowControlSettings(" + "FlowControlSettings.newBuilder()" + ".setLimitExceededBehavior(FlowController.LimitExceededBehavior.Ignore)" + ".build())" + ".build())";
assertEquals(expected, writerVisitor.write());
}
use of com.google.api.generator.gapic.model.GapicServiceConfig in project gapic-generator-java by googleapis.
the class RestTestProtoLoader method parseCompliance.
public GapicContext parseCompliance() {
FileDescriptor echoFileDescriptor = ComplianceOuterClass.getDescriptor();
ServiceDescriptor echoServiceDescriptor = echoFileDescriptor.getServices().get(0);
assertEquals(echoServiceDescriptor.getName(), "Compliance");
Map<String, Message> messageTypes = Parser.parseMessages(echoFileDescriptor);
Map<String, ResourceName> resourceNames = Parser.parseResourceNames(echoFileDescriptor);
Set<ResourceName> outputResourceNames = new HashSet<>();
List<Service> services = Parser.parseService(echoFileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames);
String jsonFilename = "showcase_grpc_service_config.json";
Path jsonPath = Paths.get(getTestFilesDirectory(), 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(getTransport()).build();
}
use of com.google.api.generator.gapic.model.GapicServiceConfig 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();
}
Aggregations