use of com.google.api.codegen.viewmodel.testing.ClientTestFileView in project toolkit by googleapis.
the class CSharpGapicUnitTestTransformer method generateUnitTestCsproj.
private ClientTestFileView generateUnitTestCsproj(GapicInterfaceContext context) {
ClientTestFileView.Builder builder = generateUnitTestBuilder(context);
GapicProductConfig productConfig = context.getProductConfig();
String outputPath = pathMapper.getOutputPath(context.getInterface().getFullName(), productConfig);
builder.outputPath(outputPath + File.separator + productConfig.getPackageName() + ".Tests.csproj");
builder.templateFileName(UNITTEST_CSPROJ_TEMPLATE_FILENAME);
return builder.build();
}
use of com.google.api.codegen.viewmodel.testing.ClientTestFileView in project toolkit by googleapis.
the class CSharpGapicUnitTestTransformer method generateUnitTest.
private ClientTestFileView generateUnitTest(GapicInterfaceContext context) {
ClientTestFileView.Builder builder = generateUnitTestBuilder(context);
SurfaceNamer namer = context.getNamer();
String name = namer.getUnitTestClassName(context.getInterfaceConfig());
String outputPath = pathMapper.getOutputPath(context.getInterface().getFullName(), context.getProductConfig());
builder.outputPath(outputPath + File.separator + name + ".g.cs");
builder.templateFileName(UNITTEST_SNIPPETS_TEMPLATE_FILENAME);
return builder.build();
}
use of com.google.api.codegen.viewmodel.testing.ClientTestFileView in project toolkit by googleapis.
the class JavaSurfaceTestTransformer method createUnitTestFileView.
// /////////////////////////////////// Unit Test /////////////////////////////////////////
private ClientTestFileView createUnitTestFileView(InterfaceContext context) {
addUnitTestImports(context);
String outputPath = pathMapper.getOutputPath(context.getInterfaceModel().getFullName(), context.getProductConfig());
SurfaceNamer namer = context.getNamer();
String name = namer.getUnitTestClassName(context.getInterfaceConfig());
ClientTestClassView.Builder testClass = ClientTestClassView.newBuilder();
testClass.apiSettingsClassName(namer.getApiSettingsClassName(context.getInterfaceConfig()));
testClass.apiStubSettingsClassName(namer.getApiStubSettingsClassName(context.getInterfaceConfig()));
testClass.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
testClass.name(name);
testClass.testCases(createTestCaseViews(context));
testClass.apiHasLongRunningMethods(context.getInterfaceConfig().hasLongRunningOperations());
testClass.mockServices(mockServiceTransformer.createMockServices(context.getNamer(), context.getApiModel(), context.getProductConfig()));
testClass.missingDefaultServiceAddress(!context.getInterfaceConfig().hasDefaultServiceAddress());
testClass.missingDefaultServiceScopes(!context.getInterfaceConfig().hasDefaultServiceScopes());
ClientTestFileView.Builder testFile = ClientTestFileView.newBuilder();
testFile.testClass(testClass.build());
testFile.outputPath(namer.getSourceFilePath(outputPath, name));
testFile.templateFileName(unitTestTemplateFile);
// Imports must be done as the last step to catch all imports.
FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context);
testFile.fileHeader(fileHeader);
return testFile.build();
}
use of com.google.api.codegen.viewmodel.testing.ClientTestFileView in project toolkit by googleapis.
the class PhpGapicSurfaceTestTransformer method createUnitTestFileView.
private ClientTestFileView createUnitTestFileView(GapicInterfaceContext context) {
addUnitTestImports(context.getImportTypeTable());
String outputPath = PhpGapicCodePathMapper.newBuilder().setPrefix("tests/unit").build().getOutputPath(context.getInterfaceModel().getFullName(), context.getProductConfig());
SurfaceNamer namer = context.getNamer();
String name = namer.getUnitTestClassName(context.getInterfaceConfig());
ClientTestClassView.Builder testClass = ClientTestClassView.newBuilder();
testClass.apiSettingsClassName(namer.getNotImplementedString("PhpGapicSurfaceTestTransformer.generateTestView - apiSettingsClassName"));
testClass.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig()));
testClass.name(name);
testClass.apiName(PhpPackageMetadataNamer.getApiNameFromPackageName(namer.getPackageName()).toLowerUnderscore());
testClass.testCases(createTestCaseViews(context));
testClass.apiHasLongRunningMethods(context.getInterfaceConfig().hasLongRunningOperations());
// Add gRPC client imports.
for (InterfaceModel grpcInterface : mockServiceTransformer.getGrpcInterfacesForService(context.getApiModel(), context.getProductConfig(), context.getInterfaceModel()).values()) {
context.getImportTypeTable().getAndSaveNicknameFor(namer.getGrpcClientTypeName(grpcInterface));
}
testClass.mockServices(mockServiceTransformer.createMockServices(context.getNamer(), context.getApiModel(), context.getProductConfig()));
testClass.missingDefaultServiceAddress(!context.getInterfaceConfig().hasDefaultServiceAddress());
testClass.missingDefaultServiceScopes(!context.getInterfaceConfig().hasDefaultServiceScopes());
ClientTestFileView.Builder testFile = ClientTestFileView.newBuilder();
testFile.testClass(testClass.build());
testFile.outputPath(namer.getSourceFilePath(outputPath, name));
testFile.templateFileName(UNIT_TEST_TEMPLATE_FILE);
ImportSectionView importSection = importSectionTransformer.generateImportSection(context.getImportTypeTable().getImports());
SurfaceNamer testPackageNamer = namer.cloneWithPackageName(namer.getTestPackageName(SurfaceNamer.TestKind.UNIT));
FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context.getProductConfig(), importSection, testPackageNamer);
testFile.fileHeader(fileHeader);
return testFile.build();
}
use of com.google.api.codegen.viewmodel.testing.ClientTestFileView in project toolkit by googleapis.
the class RubyGapicSurfaceTestTransformer method createUnitTestViews.
// /////////////////////////////////// Unit Test ///////////////////////////////////////
private List<ClientTestFileView> createUnitTestViews(ApiModel model, GapicProductConfig productConfig) {
ImmutableList.Builder<ClientTestFileView> views = ImmutableList.builder();
SurfaceNamer namer = new RubySurfaceNamer(productConfig.getPackageName());
for (InterfaceModel apiInterface : model.getInterfaces()) {
GapicInterfaceContext context = createContext(apiInterface, productConfig);
String testClassName = namer.getUnitTestClassName(context.getInterfaceConfig());
String outputPath = unitTestPathMapper.getOutputPath(context.getInterfaceModel().getFullName(), productConfig);
ImportSectionView importSection = importSectionTransformer.generateTestImportSection(context);
views.add(ClientTestFileView.newBuilder().templateFileName(UNIT_TEST_TEMPLATE_FILE).outputPath(namer.getSourceFilePath(outputPath, testClassName)).testClass(createUnitTestClassView(context, model.hasMultipleServices())).fileHeader(fileHeaderTransformer.generateFileHeader(productConfig, importSection, namer)).apiVersion(packageConfig.apiVersion()).build());
}
return views.build();
}
Aggregations