use of com.google.api.codegen.config.SmokeTestConfig in project toolkit by googleapis.
the class TestCaseTransformer method createSmokeTestInitContext.
public InitCodeContext createSmokeTestInitContext(MethodContext context) {
SmokeTestConfig testConfig = context.getInterfaceConfig().getSmokeTestConfig();
InitCodeContext.InitCodeOutputType outputType;
ImmutableMap<String, FieldConfig> fieldConfigMap;
if (context.isFlattenedMethodContext()) {
outputType = InitCodeContext.InitCodeOutputType.FieldList;
fieldConfigMap = FieldConfig.toFieldConfigMap(context.getFlatteningConfig().getFlattenedFieldConfigs().values());
} else {
outputType = InitCodeContext.InitCodeOutputType.SingleObject;
fieldConfigMap = FieldConfig.toFieldConfigMap(context.getMethodConfig().getRequiredFieldConfigs());
}
// Store project ID variable name into the symbol table since it is used
// by the execute method as a parameter.
SymbolTable table = new SymbolTable();
table.getNewSymbol(Name.from(InitFieldConfig.PROJECT_ID_VARIABLE_NAME));
InitCodeContext.Builder contextBuilder = InitCodeContext.newBuilder().initObjectType(testConfig.getMethod().getInputType()).suggestedName(Name.from("request")).outputType(outputType).initValueConfigMap(InitCodeTransformer.createCollectionMap(context)).initFieldConfigStrings(testConfig.getInitFieldConfigStrings()).symbolTable(table).fieldConfigMap(fieldConfigMap);
if (context.isFlattenedMethodContext()) {
contextBuilder.initFields(context.getFlatteningConfig().getFlattenedFields());
}
return contextBuilder.build();
}
use of com.google.api.codegen.config.SmokeTestConfig in project toolkit by googleapis.
the class CSharpGapicSmokeTestTransformer method generateSmokeTestViewBuilder.
private SmokeTestClassView.Builder generateSmokeTestViewBuilder(GapicInterfaceContext context) {
SurfaceNamer namer = context.getNamer();
String name = namer.getSmokeTestClassName(context.getInterfaceConfig());
SmokeTestClassView.Builder smokeTestBuilder = SmokeTestClassView.newBuilder();
SmokeTestConfig smokeTestConfig = context.getInterfaceConfig().getSmokeTestConfig();
if (smokeTestConfig == null) {
return null;
}
MethodModel method = smokeTestConfig.getMethod();
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig());
GapicMethodContext methodContext = context.asFlattenedMethodContext(method, flatteningGroup);
smokeTestBuilder.name(name);
smokeTestBuilder.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
smokeTestBuilder.apiSettingsClassName(namer.getApiSettingsClassName(context.getInterfaceConfig()));
StaticLangApiMethodView apiMethodView = createSmokeTestCaseApiMethodView(context, methodContext);
smokeTestBuilder.apiMethod(apiMethodView);
smokeTestBuilder.requireProjectId(testCaseTransformer.requireProjectIdInSmokeTest(apiMethodView.initCode(), namer));
// must be done as the last step to catch all imports
smokeTestBuilder.fileHeader(fileHeaderTransformer.generateFileHeader(context));
return smokeTestBuilder;
}
Aggregations