use of com.google.api.generator.gapic.model.ResourceName in project gapic-generator-java by googleapis.
the class TestProtoLoader method parseShowcaseTesting.
public GapicContext parseShowcaseTesting() {
FileDescriptor testingFileDescriptor = TestingOuterClass.getDescriptor();
ServiceDescriptor testingService = testingFileDescriptor.getServices().get(0);
assertEquals(testingService.getName(), "Testing");
Map<String, Message> messageTypes = Parser.parseMessages(testingFileDescriptor);
Map<String, ResourceName> resourceNames = Parser.parseResourceNames(testingFileDescriptor);
Set<ResourceName> outputResourceNames = new HashSet<>();
List<Service> services = Parser.parseService(testingFileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames);
return GapicContext.builder().setMessages(messageTypes).setResourceNames(resourceNames).setServices(services).setHelperResourceNames(outputResourceNames).setTransport(transport).build();
}
use of com.google.api.generator.gapic.model.ResourceName in project gapic-generator-java by googleapis.
the class DefaultValueComposerTest method defaultValue_wildcardResourceNameWithOnlyDeletedTopic.
@Test
public void defaultValue_wildcardResourceNameWithOnlyDeletedTopic() {
// Edge case that should never happen in practice.
// Wildcard, but the resource names map has only other names that contain only the deleted-topic
// constant.
FileDescriptor lockerServiceFileDescriptor = LockerProto.getDescriptor();
Map<String, ResourceName> typeStringsToResourceNames = Parser.parseResourceNames(lockerServiceFileDescriptor);
ResourceName resourceName = typeStringsToResourceNames.get("cloudresourcemanager.googleapis.com/Anything");
ResourceName topicResourceName = typeStringsToResourceNames.get("pubsub.googleapis.com/Topic");
typeStringsToResourceNames.clear();
typeStringsToResourceNames.put(topicResourceName.resourceTypeString(), topicResourceName);
Expr expr = DefaultValueComposer.createResourceHelperValue(resourceName, false, typeStringsToResourceNames.values().stream().collect(Collectors.toList()), "ignored");
expr.accept(writerVisitor);
assertEquals("TopicName.ofDeletedTopic()", writerVisitor.write());
}
use of com.google.api.generator.gapic.model.ResourceName in project gapic-generator-java by googleapis.
the class DefaultValueComposerTest method defaultValue_resourceNameWithOnePattern.
@Test
public void defaultValue_resourceNameWithOnePattern() {
FileDescriptor lockerServiceFileDescriptor = LockerProto.getDescriptor();
Map<String, ResourceName> typeStringsToResourceNames = Parser.parseResourceNames(lockerServiceFileDescriptor);
ResourceName resourceName = typeStringsToResourceNames.get("cloudbilling.googleapis.com/BillingAccount");
Expr expr = DefaultValueComposer.createResourceHelperValue(resourceName, false, typeStringsToResourceNames.values().stream().collect(Collectors.toList()), "ignored");
expr.accept(writerVisitor);
assertEquals("BillingAccountName.of(\"[BILLING_ACCOUNT]\")", writerVisitor.write());
}
use of com.google.api.generator.gapic.model.ResourceName in project gapic-generator-java by googleapis.
the class DefaultValueComposerTest method defaultValue_resourceNameWithMultiplePatterns.
@Test
public void defaultValue_resourceNameWithMultiplePatterns() {
FileDescriptor lockerServiceFileDescriptor = LockerProto.getDescriptor();
Map<String, ResourceName> typeStringsToResourceNames = Parser.parseResourceNames(lockerServiceFileDescriptor);
ResourceName resourceName = typeStringsToResourceNames.get("cloudresourcemanager.googleapis.com/Folder");
Expr expr = DefaultValueComposer.createResourceHelperValue(resourceName, false, typeStringsToResourceNames.values().stream().collect(Collectors.toList()), "ignored");
expr.accept(writerVisitor);
assertEquals("FolderName.ofProjectFolderName(\"[PROJECT]\", \"[FOLDER]\")", writerVisitor.write());
}
use of com.google.api.generator.gapic.model.ResourceName in project gapic-generator-java by googleapis.
the class DefaultValueComposerTest method createSimpleMessage_containsMessagesEnumsAndResourceName.
@Test
public void createSimpleMessage_containsMessagesEnumsAndResourceName() {
FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor();
Map<String, Message> messageTypes = Parser.parseMessages(echoFileDescriptor);
Map<String, ResourceName> typeStringsToResourceNames = Parser.parseResourceNames(echoFileDescriptor);
Message message = messageTypes.get("com.google.showcase.v1beta1.EchoRequest");
Expr expr = DefaultValueComposer.createSimpleMessageBuilderValue(message, typeStringsToResourceNames, messageTypes);
expr.accept(writerVisitor);
assertEquals("EchoRequest.newBuilder().setName(" + "FoobarName.ofProjectFoobarName(\"[PROJECT]\", \"[FOOBAR]\").toString())" + ".setParent(FoobarName.ofProjectFoobarName(\"[PROJECT]\", \"[FOOBAR]\").toString())" + ".setSeverity(Severity.forNumber(0))" + ".setFoobar(Foobar.newBuilder().build()).build()", writerVisitor.write());
}
Aggregations