use of com.google.api.codegen.config.MethodContext in project toolkit by googleapis.
the class GoGapicSurfaceTestTransformer method createSmokeTestClassView.
private SmokeTestClassView createSmokeTestClassView(InterfaceContext context) {
SurfaceNamer namer = context.getNamer();
MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod();
MethodContext methodContext = context.asRequestMethodContext(method);
SmokeTestClassView.Builder testClass = SmokeTestClassView.newBuilder();
StaticLangApiMethodView apiMethodView = createSmokeTestCaseApiMethodView(methodContext);
testClass.apiSettingsClassName(namer.getApiSettingsClassName(context.getInterfaceConfig()));
testClass.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
testClass.name(namer.getSmokeTestClassName(context.getInterfaceConfig()));
testClass.outputPath(context.getProductConfig().getPackageName() + File.separator + method.getSimpleName() + "_smoke_test.go");
testClass.templateFileName(SMOKE_TEST_TEMPLATE_FILE);
testClass.apiMethod(apiMethodView);
testClass.requireProjectId(testCaseTransformer.requireProjectIdInSmokeTest(apiMethodView.initCode(), context.getNamer()));
// The shared code above add imports both for input and output.
// Since we use short decls, we don't need to import anything for output.
context.getImportTypeTable().getImports().clear();
method.getAndSaveRequestTypeName(methodContext.getTypeTable(), methodContext.getNamer());
FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context);
testClass.fileHeader(fileHeader);
return testClass.build();
}
Aggregations