use of com.google.api.generator.gapic.model.Method in project gapic-generator-java by googleapis.
the class ServiceClientMethodSampleComposerTest method valid_composeDefaultSample_isPagedMethod.
@Test
public void valid_composeDefaultSample_isPagedMethod() {
FileDescriptor echoFileDescriptor = EchoOuterClass.getDescriptor();
Map<String, ResourceName> resourceNames = Parser.parseResourceNames(echoFileDescriptor);
Map<String, Message> messageTypes = Parser.parseMessages(echoFileDescriptor);
TypeNode clientType = TypeNode.withReference(VaporReference.builder().setName("EchoClient").setPakkage(SHOWCASE_PACKAGE_NAME).build());
TypeNode inputType = TypeNode.withReference(VaporReference.builder().setName("PagedExpandRequest").setPakkage(SHOWCASE_PACKAGE_NAME).build());
TypeNode outputType = TypeNode.withReference(VaporReference.builder().setName("PagedExpandResponse").setPakkage(SHOWCASE_PACKAGE_NAME).build());
Method method = Method.builder().setName("PagedExpand").setInputType(inputType).setOutputType(outputType).setMethodSignatures(Collections.emptyList()).setPageSizeFieldName(PAGINATED_FIELD_NAME).build();
String results = writeStatements(ServiceClientMethodSampleComposer.composeCanonicalSample(method, clientType, resourceNames, messageTypes));
String expected = LineFormatter.lines("try (EchoClient echoClient = EchoClient.create()) {\n", " PagedExpandRequest request =\n", " PagedExpandRequest.newBuilder()\n", " .setContent(\"content951530617\")\n", " .setPageSize(883849137)\n", " .setPageToken(\"pageToken873572522\")\n", " .build();\n", " for (EchoResponse element : echoClient.pagedExpand(request).iterateAll()) {\n", " // doThingsWith(element);\n", " }\n", "}");
Assert.assertEquals(results, expected);
}
Aggregations