use of com.google.api.codegen.transformer.SurfaceNamer 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.transformer.SurfaceNamer in project toolkit by googleapis.
the class PhpGapicSurfaceTestTransformer method createSmokeTestClassViewBuilder.
private SmokeTestClassView.Builder createSmokeTestClassViewBuilder(GapicInterfaceContext context) {
addSmokeTestImports(context.getImportTypeTable());
SurfaceNamer namer = context.getNamer();
MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod();
GapicMethodContext defaultMethodContext = context.asRequestMethodContext(method);
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method));
GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(defaultMethodContext, flatteningGroup);
SmokeTestClassView.Builder testClass = SmokeTestClassView.newBuilder();
OptionalArrayMethodView apiMethod = createSmokeTestCaseApiMethodView(flattenedMethodContext);
testClass.apiSettingsClassName(context.getNamer().getApiSettingsClassName(context.getInterfaceConfig()));
testClass.apiClassName(context.getNamer().getApiWrapperClassName(context.getInterfaceConfig()));
testClass.apiName(getApiName(context.getProductConfig().getPackageName()));
testClass.templateFileName(SMOKE_TEST_TEMPLATE_FILE);
testClass.apiMethod(apiMethod);
testClass.requireProjectId(testCaseTransformer.requireProjectIdInSmokeTest(apiMethod.initCode(), context.getNamer()));
testClass.methodName(namer.getTestCaseName(new SymbolTable(), method));
ImportSectionView importSection = importSectionTransformer.generateImportSection(context.getImportTypeTable().getImports());
SurfaceNamer testPackageNamer = namer.cloneWithPackageName(namer.getTestPackageName(SurfaceNamer.TestKind.SYSTEM));
FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context.getProductConfig(), importSection, testPackageNamer);
testClass.fileHeader(fileHeader);
return testClass;
}
use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.
the class RubyImportSectionTransformer method generateTestAppImports.
private List<ImportFileView> generateTestAppImports(GapicInterfaceContext context) {
ImmutableList.Builder<ImportFileView> imports = ImmutableList.builder();
SurfaceNamer namer = context.getNamer();
if (RubyUtil.hasMajorVersion(context.getProductConfig().getPackageName())) {
imports.add(createImport(namer.getTopLevelIndexFileImportName()));
} else {
imports.add(createImport(namer.getVersionIndexFileImportName()));
}
// Import the client class directly so the client class is in scope for the static class methods
// used in the in the init code such as the path methods. This is not necessary for method
// samples since the client is initialized before the init code, and the initialization
// requires the client class file.
imports.add(createImport(namer.getServiceFileName(context.getInterfaceConfig())));
for (String filename : generateImportFilenames(context)) {
imports.add(createImport(namer.getServiceFileImportName(filename)));
}
if (context.getInterfaceConfig().hasLongRunningOperations()) {
imports.add(createImport("google/longrunning/operations_pb"));
}
return imports.build();
}
use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.
the class CSharpGapicClientTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
List<ViewModel> surfaceDocs = new ArrayList<>();
SurfaceNamer namer = new CSharpSurfaceNamer(productConfig.getPackageName());
CSharpFeatureConfig featureConfig = new CSharpFeatureConfig();
InterfaceModel lastApiInterface = null;
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = GapicInterfaceContext.create(apiInterface, productConfig, createTypeTable(productConfig.getPackageName()), namer, featureConfig);
surfaceDocs.add(generateApiAndSettingsView(context));
lastApiInterface = apiInterface;
}
GapicInterfaceContext context = GapicInterfaceContext.create(lastApiInterface, productConfig, createTypeTable(productConfig.getPackageName()), namer, featureConfig);
surfaceDocs.add(generateResourceNamesView(context));
surfaceDocs.add(generateCsProjView(context));
return surfaceDocs;
}
use of com.google.api.codegen.transformer.SurfaceNamer in project toolkit by googleapis.
the class JavaSurfaceTestTransformer method transform.
@Override
public List<ViewModel> transform(ApiModel model, GapicProductConfig productConfig) {
SurfaceNamer namer = surfaceTransformer.createSurfaceNamer(productConfig);
boolean enableStringFormatFunctions = productConfig.getResourceNameMessageConfigs().isEmpty();
List<ViewModel> views = new ArrayList<>();
for (InterfaceModel apiInterface : model.getInterfaces()) {
ImportTypeTable typeTable = surfaceTransformer.createTypeTable(productConfig.getPackageName());
InterfaceContext context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable, enableStringFormatFunctions);
views.add(createUnitTestFileView(context));
if (context.getInterfaceConfig().getSmokeTestConfig() != null) {
context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable.cloneEmpty(), enableStringFormatFunctions);
views.add(createSmokeTestClassView(context));
}
}
for (InterfaceModel apiInterface : mockServiceTransformer.getGrpcInterfacesToMock(model, productConfig)) {
ImportTypeTable typeTable = surfaceTransformer.createTypeTable(productConfig.getPackageName());
InterfaceContext context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable, enableStringFormatFunctions);
views.add(createMockServiceImplFileView(context));
context = surfaceTransformer.createInterfaceContext(apiInterface, productConfig, namer, typeTable.cloneEmpty(), enableStringFormatFunctions);
views.add(createMockServiceView(context));
}
return views;
}
Aggregations