use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class GoGapicSurfaceTransformerTest method testGetImportsNotLro.
@Test
public void testGetImportsNotLro() {
MethodModel method = new ProtoMethodModel(getMethod(context.getInterface(), "NotLroMethod"));
transformer.addXApiImports(context, Collections.singletonList(method));
Truth.assertThat(context.getImportTypeTable().getImports()).doesNotContainKey("cloud.google.com/go/longrunning");
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class GoGapicSurfaceTransformerTest method testGetImportsPlain.
@Test
public void testGetImportsPlain() {
MethodModel method = new ProtoMethodModel(getMethod(context.getInterface(), "SimpleMethod"));
transformer.addXApiImports(context, Collections.singletonList(method));
transformer.generateRetryConfigDefinitions(context, Collections.singletonList(method));
Truth.assertThat(context.getImportTypeTable().getImports()).doesNotContainKey("time");
Truth.assertThat(context.getImportTypeTable().getImports()).doesNotContainKey("cloud.google.com/go/longrunning");
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class GoGapicSurfaceTransformerTest method testGetImportsLro.
@Test
public void testGetImportsLro() {
MethodModel method = new ProtoMethodModel(getMethod(context.getInterface(), "LroMethod"));
transformer.addXApiImports(context, Collections.singletonList(method));
transformer.generateRetryConfigDefinitions(context, Collections.singletonList(method));
Truth.assertThat(context.getImportTypeTable().getImports()).doesNotContainKey("math");
Truth.assertThat(context.getImportTypeTable().getImports()).containsKey("cloud.google.com/go/longrunning");
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class RubySurfaceNamerTest method getApiMethodName.
@Test
public void getApiMethodName() {
RubySurfaceNamer namer = new RubySurfaceNamer("Unused::Package::Name");
MethodModel method = Mockito.mock(MethodModel.class);
Mockito.when(method.getSimpleName()).thenReturn("PrintHTML");
Truth.assertThat(namer.getApiMethodName(method, VisibilityConfig.PUBLIC)).isEqualTo("print_html");
Mockito.when(method.getSimpleName()).thenReturn("AMethod");
Truth.assertThat(namer.getApiMethodName(method, VisibilityConfig.PUBLIC)).isEqualTo("a_method");
Mockito.when(method.getSimpleName()).thenReturn("AnRpc");
Truth.assertThat(namer.getApiMethodName(method, VisibilityConfig.PUBLIC)).isEqualTo("an_rpc");
Mockito.when(method.getSimpleName()).thenReturn("SeeHTMLBooks");
Truth.assertThat(namer.getApiMethodName(method, VisibilityConfig.PUBLIC)).isEqualTo("see_html_books");
}
use of com.google.api.codegen.config.MethodModel in project toolkit by googleapis.
the class ApiCallableTransformer method generateMethodDescriptor.
private MethodDescriptorView generateMethodDescriptor(MethodContext context) {
ImportTypeTable typeTable = context.getTypeTable();
MethodModel method = context.getMethodModel();
MethodConfig methodConfig = context.getMethodConfig();
SurfaceNamer namer = context.getNamer();
MethodDescriptorView.Builder methodDescriptorBuilder = MethodDescriptorView.newBuilder();
if (methodConfig.isGrpcStreaming()) {
methodDescriptorBuilder.grpcStreamingType(methodConfig.getGrpcStreaming().getType());
}
methodDescriptorBuilder.requestTypeName(method.getAndSaveRequestTypeName(typeTable, namer));
methodDescriptorBuilder.responseTypeName(method.getAndSaveResponseTypeName(typeTable, namer));
methodDescriptorBuilder.hasResponse(!method.isOutputTypeEmpty());
methodDescriptorBuilder.name(namer.getMethodDescriptorName(method));
methodDescriptorBuilder.protoMethodName(method.getSimpleName());
methodDescriptorBuilder.fullServiceName(context.getTargetInterface().getFullName());
methodDescriptorBuilder.transportSettingsVar(namer.getTransportSettingsVar(method));
methodDescriptorBuilder.headerRequestParams(headerRequestParamTransformer.generateHeaderRequestParams(context));
methodDescriptorBuilder.httpMethod(generateHttpFields(context));
return methodDescriptorBuilder.build();
}
Aggregations