Search in sources :

Example 1 with MockServiceImplFileView

use of com.google.api.codegen.viewmodel.testing.MockServiceImplFileView 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)

Aggregations

SurfaceNamer (com.google.api.codegen.transformer.SurfaceNamer)1 FileHeaderView (com.google.api.codegen.viewmodel.FileHeaderView)1 MockServiceImplFileView (com.google.api.codegen.viewmodel.testing.MockServiceImplFileView)1