use of com.google.api.codegen.viewmodel.testing.SmokeTestClassView in project toolkit by googleapis.
the class CSharpGapicSmokeTestTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = new CSharpSurfaceNamer(productConfig.getPackageName());
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, csharpCommonTransformer.createTypeTable(namer.getPackageName()), namer, new CSharpFeatureConfig());
csharpCommonTransformer.addCommonImports(context);
SmokeTestClassView smokeTests = generateSmokeTest(context);
if (smokeTests != null) {
surfaceDocs.add(smokeTests);
surfaceDocs.add(generateSmokeTestCsproj(context));
}
}
return surfaceDocs;
}
use of com.google.api.codegen.viewmodel.testing.SmokeTestClassView in project toolkit by googleapis.
the class CSharpGapicSmokeTestTransformer method generateSmokeTest.
private SmokeTestClassView generateSmokeTest(GapicInterfaceContext context) {
SmokeTestClassView.Builder builder = generateSmokeTestViewBuilder(context);
if (builder == null) {
return null;
}
builder.templateFileName(SMOKETEST_SNIPPETS_TEMPLATE_FILENAME);
SurfaceNamer namer = context.getNamer();
String name = namer.getSmokeTestClassName(context.getInterfaceConfig());
String outputPath = pathMapper.getOutputPath(context.getInterface().getFullName(), context.getProductConfig());
builder.outputPath(outputPath + File.separator + name + ".g.cs");
return builder.build();
}
use of com.google.api.codegen.viewmodel.testing.SmokeTestClassView in project toolkit by googleapis.
the class NodeJSGapicSurfaceTestTransformer method createSmokeTestClassView.
private SmokeTestClassView createSmokeTestClassView(GapicInterfaceContext context, boolean packageHasMultipleServices) {
SurfaceNamer namer = context.getNamer();
String name = namer.getSmokeTestClassName(context.getInterfaceConfig());
MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod();
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig());
GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup);
SmokeTestClassView.Builder testClass = SmokeTestClassView.newBuilder();
OptionalArrayMethodView apiMethodView = createSmokeTestCaseApiMethodView(flattenedMethodContext, packageHasMultipleServices);
testClass.apiSettingsClassName(namer.getApiSettingsClassName(context.getInterfaceConfig()));
testClass.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
testClass.name(name);
testClass.outputPath(namer.getSourceFilePath(SMOKE_TEST_OUTPUT_BASE_PATH, name));
testClass.templateFileName(SMOKE_TEST_TEMPLATE_FILE);
testClass.apiMethod(apiMethodView);
testClass.requireProjectId(testCaseTransformer.requireProjectIdInSmokeTest(apiMethodView.initCode(), context.getNamer()));
FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context);
testClass.fileHeader(fileHeader);
return testClass.build();
}
use of com.google.api.codegen.viewmodel.testing.SmokeTestClassView in project toolkit by googleapis.
the class PhpGapicSurfaceTestTransformer method createSmokeTestClassView.
private SmokeTestClassView createSmokeTestClassView(GapicInterfaceContext context) {
String outputPath = PhpGapicCodePathMapper.newBuilder().setPrefix("tests/system").build().getOutputPath(context.getInterfaceModel().getFullName(), context.getProductConfig());
SurfaceNamer namer = context.getNamer();
String name = namer.getSmokeTestClassName(context.getInterfaceConfig());
SmokeTestClassView.Builder testClass = createSmokeTestClassViewBuilder(context);
testClass.name(name);
testClass.outputPath(namer.getSourceFilePath(outputPath, name));
return testClass.build();
}
use of com.google.api.codegen.viewmodel.testing.SmokeTestClassView in project toolkit by googleapis.
the class RubyGapicSurfaceTestTransformer method createSmokeTestClassView.
private SmokeTestClassView createSmokeTestClassView(GapicInterfaceContext context) {
boolean packageHasMultipleServices = context.getApiModel().hasMultipleServices();
String outputPath = smokeTestPathMapper.getOutputPath(context.getInterfaceModel().getFullName(), context.getProductConfig());
SurfaceNamer namer = context.getNamer();
RubyPackageMetadataNamer metadataNamer = new RubyPackageMetadataNamer(context.getNamer().getPackageName());
String name = namer.getSmokeTestClassName(context.getInterfaceConfig());
MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod();
TestCaseTransformer testCaseTransformer = new TestCaseTransformer(valueProducer, packageHasMultipleServices);
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig());
GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup);
SmokeTestClassView.Builder testClass = SmokeTestClassView.newBuilder();
OptionalArrayMethodView apiMethodView = createSmokeTestCaseApiMethodView(flattenedMethodContext, packageHasMultipleServices);
testClass.apiSettingsClassName(namer.getApiSettingsClassName(context.getInterfaceConfig()));
testClass.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
testClass.name(name);
testClass.outputPath(namer.getSourceFilePath(outputPath, name));
testClass.templateFileName(SMOKE_TEST_TEMPLATE_FILE);
testClass.apiMethod(apiMethodView);
testClass.requireProjectId(testCaseTransformer.requireProjectIdInSmokeTest(apiMethodView.initCode(), context.getNamer()));
testClass.projectIdVariableName(metadataNamer.getProjectVariable(true));
testClass.apiVersion(packageConfig.apiVersion());
FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context.getProductConfig(), importSectionTransformer.generateSmokeTestImportSection(context), namer);
testClass.fileHeader(fileHeader);
return testClass.build();
}
Aggregations