use of com.google.api.codegen.transformer.TestCaseTransformer in project toolkit by googleapis.
the class RubyGapicSurfaceTestTransformer method createSmokeTestClassView.
private SmokeTestClassView createSmokeTestClassView(GapicInterfaceContext context) {
boolean packageHasMultipleServices = context.getApiModel().hasMultipleServices();
String outputPath = smokeTestPathMapper.getOutputPath(context.getInterfaceModel().getFullName(), context.getProductConfig());
SurfaceNamer namer = context.getNamer();
RubyPackageMetadataNamer metadataNamer = new RubyPackageMetadataNamer(context.getNamer().getPackageName());
String name = namer.getSmokeTestClassName(context.getInterfaceConfig());
MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod();
MethodContext methodContext = context.asRequestMethodContext(method);
TestCaseTransformer testCaseTransformer = new TestCaseTransformer(valueProducer, packageHasMultipleServices);
FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(methodContext.getMethodConfig());
GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(methodContext, 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(outputPath, name));
testClass.templateFileName(SMOKE_TEST_TEMPLATE_FILE);
testClass.apiMethod(apiMethodView);
testClass.requireProjectId(testCaseTransformer.requireProjectIdInSmokeTest(apiMethodView.initCode(), context.getNamer()));
testClass.projectIdVariableName(metadataNamer.getProjectVariable(true));
testClass.apiVersion(packageConfig.apiVersion());
FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context.getProductConfig(), importSectionTransformer.generateSmokeTestImportSection(context), namer);
testClass.fileHeader(fileHeader);
return testClass.build();
}
use of com.google.api.codegen.transformer.TestCaseTransformer in project toolkit by googleapis.
the class RubyGapicSurfaceTestTransformer method createUnitTestCaseViews.
private List<TestCaseView> createUnitTestCaseViews(GapicInterfaceContext context, boolean packageHasMultipleServices) {
ImmutableList.Builder<TestCaseView> testCases = ImmutableList.builder();
for (MethodModel method : context.getSupportedMethods()) {
GapicMethodContext requestMethodContext = context.withNewTypeTable().asRequestMethodContext(method);
TestCaseTransformer testCaseTransformer = new TestCaseTransformer(valueProducer, packageHasMultipleServices);
TestCaseView testCase = testCaseTransformer.createTestCaseView(requestMethodContext, new SymbolTable(), createUnitTestCaseInitCodeContext(context, method), getMethodType(requestMethodContext));
testCases.add(testCase);
}
return testCases.build();
}
use of com.google.api.codegen.transformer.TestCaseTransformer in project toolkit by googleapis.
the class RubyGapicSurfaceTestTransformer method createSmokeTestCaseApiMethodView.
private OptionalArrayMethodView createSmokeTestCaseApiMethodView(GapicMethodContext context, boolean packageHasMultipleServices) {
OptionalArrayMethodView initialApiMethodView = new DynamicLangApiMethodTransformer(new RubyApiMethodParamTransformer()).generateApiMethod(context);
OptionalArrayMethodView.Builder apiMethodView = initialApiMethodView.toBuilder();
TestCaseTransformer testCaseTransformer = new TestCaseTransformer(valueProducer, packageHasMultipleServices);
InitCodeTransformer initCodeTransformer = new InitCodeTransformer(false);
InitCodeView initCodeView = initCodeTransformer.generateInitCode(context, testCaseTransformer.createSmokeTestInitContext(context));
apiMethodView.initCode(initCodeView);
return apiMethodView.build();
}
Aggregations