use of com.google.api.codegen.viewmodel.FileHeaderView in project toolkit by googleapis.
the class JavaSurfaceTestTransformer method createMockServiceImplFileView.
private MockServiceImplFileView createMockServiceImplFileView(InterfaceContext context) {
addMockServiceImplImports(context);
SurfaceNamer namer = context.getNamer();
String outputPath = pathMapper.getOutputPath(context.getInterfaceModel().getFullName(), context.getProductConfig());
String name = namer.getMockGrpcServiceImplName(context.getInterfaceModel());
String grpcClassName = context.getImportTypeTable().getAndSaveNicknameFor(namer.getGrpcServiceClassName(context.getInterfaceModel()));
MockServiceImplFileView.Builder mockServiceImplFile = MockServiceImplFileView.newBuilder();
mockServiceImplFile.serviceImpl(MockServiceImplView.newBuilder().name(name).mockGrpcClassName(grpcClassName).grpcMethods(mockServiceTransformer.createMockGrpcMethodViews(context)).build());
mockServiceImplFile.outputPath(namer.getSourceFilePath(outputPath, name));
mockServiceImplFile.templateFileName(MOCK_SERVICE_IMPL_FILE);
// Imports must be done as the last step to catch all imports.
FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context);
mockServiceImplFile.fileHeader(fileHeader);
return mockServiceImplFile.build();
}
use of com.google.api.codegen.viewmodel.FileHeaderView in project toolkit by googleapis.
the class JavaSurfaceTestTransformer method createSmokeTestClassViewBuilder.
/**
* Package-private
*
* <p>A helper method that creates a partially initialized builder that can be customized and
* build the smoke test class view later.
*/
SmokeTestClassView.Builder createSmokeTestClassViewBuilder(InterfaceContext context) {
addSmokeTestImports(context);
MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod();
SurfaceNamer namer = context.getNamer();
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig());
MethodContext methodContext = context.asFlattenedMethodContext(method, flatteningGroup);
SmokeTestClassView.Builder testClass = SmokeTestClassView.newBuilder();
StaticLangApiMethodView apiMethodView = createSmokeTestCaseApiMethodView(methodContext);
testClass.apiSettingsClassName(namer.getApiSettingsClassName(context.getInterfaceConfig()));
testClass.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
testClass.templateFileName(SMOKE_TEST_TEMPLATE_FILE);
testClass.apiMethod(apiMethodView);
testClass.requireProjectId(testCaseTransformer.requireProjectIdInSmokeTest(apiMethodView.initCode(), context.getNamer()));
// Imports must be done as the last step to catch all imports.
FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context);
testClass.fileHeader(fileHeader);
return testClass;
}
use of com.google.api.codegen.viewmodel.FileHeaderView in project toolkit by googleapis.
the class JavaSurfaceTestTransformer method createMockServiceView.
// /////////////////////////////////// Mock Service /////////////////////////////////////////
private MockServiceView createMockServiceView(InterfaceContext context) {
addMockServiceImports(context);
SurfaceNamer namer = context.getNamer();
String outputPath = pathMapper.getOutputPath(context.getInterfaceModel().getFullName(), context.getProductConfig());
String name = namer.getMockServiceClassName(context.getInterfaceModel());
MockServiceView.Builder mockService = MockServiceView.newBuilder();
mockService.name(name);
mockService.serviceImplClassName(namer.getMockGrpcServiceImplName(context.getInterfaceModel()));
mockService.outputPath(namer.getSourceFilePath(outputPath, name));
mockService.templateFileName(MOCK_SERVICE_FILE);
// Imports must be done as the last step to catch all imports.
FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context);
mockService.fileHeader(fileHeader);
return mockService.build();
}
use of com.google.api.codegen.viewmodel.FileHeaderView 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.FileHeaderView 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();
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig());
GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, 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(PhpPackageMetadataNamer.getApiNameFromPackageName(context.getNamer().getPackageName()).toLowerUnderscore());
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;
}
Aggregations