Search in sources :

Example 21 with MethodContext

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();
}
Also used : MethodModel(com.google.api.codegen.config.MethodModel) StaticLangApiMethodView(com.google.api.codegen.viewmodel.StaticLangApiMethodView) SmokeTestClassView(com.google.api.codegen.viewmodel.testing.SmokeTestClassView) GapicMethodContext(com.google.api.codegen.config.GapicMethodContext) MethodContext(com.google.api.codegen.config.MethodContext) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) FileHeaderView(com.google.api.codegen.viewmodel.FileHeaderView)

Aggregations

MethodContext (com.google.api.codegen.config.MethodContext)21 ArrayList (java.util.ArrayList)14 MethodConfig (com.google.api.codegen.config.MethodConfig)13 MethodModel (com.google.api.codegen.config.MethodModel)12 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)9 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)8 InterfaceContext (com.google.api.codegen.config.InterfaceContext)7 InitCodeOutputType (com.google.api.codegen.metacode.InitCodeContext.InitCodeOutputType)7 ImmutableList (com.google.common.collect.ImmutableList)7 List (java.util.List)7 HashMap (java.util.HashMap)6 FieldConfig (com.google.api.codegen.config.FieldConfig)5 GapicMethodContext (com.google.api.codegen.config.GapicMethodContext)5 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)5 CallingForm (com.google.api.codegen.viewmodel.CallingForm)5 GapicInterfaceContext (com.google.api.codegen.config.GapicInterfaceContext)4 SampleConfig (com.google.api.codegen.config.SampleConfig)4 SampleContext (com.google.api.codegen.config.SampleContext)4 Name (com.google.api.codegen.util.Name)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)4