use of com.google.api.codegen.viewmodel.FileHeaderView 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();
}
Aggregations