Search in sources :

Example 1 with FileHeaderView

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();
}
Also used : MockServiceImplFileView(com.google.api.codegen.viewmodel.testing.MockServiceImplFileView) SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) FileHeaderView(com.google.api.codegen.viewmodel.FileHeaderView)

Example 2 with FileHeaderView

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

Example 3 with FileHeaderView

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();
}
Also used : SurfaceNamer(com.google.api.codegen.transformer.SurfaceNamer) MockServiceView(com.google.api.codegen.viewmodel.testing.MockServiceView) FileHeaderView(com.google.api.codegen.viewmodel.FileHeaderView)

Example 4 with FileHeaderView

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

Example 5 with FileHeaderView

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

Aggregations

FileHeaderView (com.google.api.codegen.viewmodel.FileHeaderView)11 SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)10 MethodModel (com.google.api.codegen.config.MethodModel)5 SmokeTestClassView (com.google.api.codegen.viewmodel.testing.SmokeTestClassView)5 FlatteningConfig (com.google.api.codegen.config.FlatteningConfig)4 GapicMethodContext (com.google.api.codegen.transformer.GapicMethodContext)4 OptionalArrayMethodView (com.google.api.codegen.viewmodel.OptionalArrayMethodView)3 ClientTestClassView (com.google.api.codegen.viewmodel.testing.ClientTestClassView)3 ClientTestFileView (com.google.api.codegen.viewmodel.testing.ClientTestFileView)3 MethodContext (com.google.api.codegen.transformer.MethodContext)2 ImportSectionView (com.google.api.codegen.viewmodel.ImportSectionView)2 StaticLangApiMethodView (com.google.api.codegen.viewmodel.StaticLangApiMethodView)2 InterfaceModel (com.google.api.codegen.config.InterfaceModel)1 TestCaseTransformer (com.google.api.codegen.transformer.TestCaseTransformer)1 SymbolTable (com.google.api.codegen.util.SymbolTable)1 ViewModel (com.google.api.codegen.viewmodel.ViewModel)1 MockServiceImplFileView (com.google.api.codegen.viewmodel.testing.MockServiceImplFileView)1 MockServiceView (com.google.api.codegen.viewmodel.testing.MockServiceView)1 ArrayList (java.util.ArrayList)1