private List<ApiMethodView> generateExampleMethods( ApiModel model, GapicProductConfig productConfig) { ImmutableList.Builder<ApiMethodView> exampleMethods = ImmutableList.builder(); for (InterfaceModel apiInterface : model.getInterfaces()) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) { continue; } GapicInterfaceContext context = createContext(apiInterface, productConfig); MethodModel method = interfaceConfig.getSmokeTestConfig().getMethod(); FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup( context.getMethodConfig(method), interfaceConfig.getSmokeTestConfig()); GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup); exampleMethods.add(createExampleApiMethodView(flattenedMethodContext)); } return exampleMethods.build(); }
private List<ApiMethodView> generateExampleMethods( ApiModel model, GapicProductConfig productConfig) { ImmutableList.Builder<ApiMethodView> exampleMethods = ImmutableList.builder(); for (InterfaceModel apiInterface : model.getInterfaces()) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) { continue; } GapicInterfaceContext context = createContext(apiInterface, productConfig); MethodModel method = interfaceConfig.getSmokeTestConfig().getMethod(); FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup( context.getMethodConfig(method), interfaceConfig.getSmokeTestConfig()); GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup); exampleMethods.add( createExampleApiMethodView(flattenedMethodContext, model.hasMultipleServices())); } return exampleMethods.build(); }
private List<ApiMethodView> generateExampleMethods( ApiModel model, GapicProductConfig productConfig) { ImmutableList.Builder<ApiMethodView> exampleMethods = ImmutableList.builder(); for (InterfaceModel apiInterface : model.getInterfaces()) { InterfaceConfig interfaceConfig = productConfig.getInterfaceConfig(apiInterface); if (interfaceConfig == null || interfaceConfig.getSmokeTestConfig() == null) { continue; } GapicInterfaceContext context = createContext(apiInterface, productConfig); MethodModel method = interfaceConfig.getSmokeTestConfig().getMethod(); FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup( context.getMethodConfig(method), interfaceConfig.getSmokeTestConfig()); GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup); exampleMethods.add( createExampleApiMethodView(flattenedMethodContext, model.hasMultipleServices())); } return exampleMethods.build(); }
Joiner.on(File.separator).join("tests", "system", "gapic", version, filename); MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod(); FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(
.initObjectType(testConfig.getMethod().getInputType()) .suggestedName(Name.from("request")) .outputType(outputType)
private SmokeTestClassView createSmokeTestClassView(InterfaceContext context) { SurfaceNamer namer = context.getNamer(); MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod(); MethodContext methodContext = context.asRequestMethodContext(method); SmokeTestClassView.Builder testClass = SmokeTestClassView.newBuilder(); StaticLangApiMethodView apiMethodView = createSmokeTestCaseApiMethodView(methodContext); testClass.apiSettingsClassName(namer.getApiSettingsClassName(context.getInterfaceConfig())); testClass.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig())); testClass.name(namer.getSmokeTestClassName(context.getInterfaceConfig())); testClass.outputPath( context.getProductConfig().getPackageName() + File.separator + method.getSimpleName() + "_smoke_test.go"); testClass.templateFileName(SMOKE_TEST_TEMPLATE_FILE); testClass.apiMethod(apiMethodView); testClass.requireProjectId( testCaseTransformer.requireProjectIdInSmokeTest( apiMethodView.initCode(), context.getNamer())); // The shared code above add imports both for input and output. // Since we use short decls, we don't need to import anything for output. context.getImportTypeTable().getImports().clear(); method.getAndSaveRequestTypeName(methodContext.getTypeTable(), methodContext.getNamer()); FileHeaderView fileHeader = fileHeaderTransformer.generateFileHeader(context); testClass.fileHeader(fileHeader); return testClass.build(); }
private SmokeTestClassView.Builder generateSmokeTestViewBuilder(GapicInterfaceContext context) { SurfaceNamer namer = context.getNamer(); String name = namer.getSmokeTestClassName(context.getInterfaceConfig()); SmokeTestClassView.Builder smokeTestBuilder = SmokeTestClassView.newBuilder(); SmokeTestConfig smokeTestConfig = context.getInterfaceConfig().getSmokeTestConfig(); if (smokeTestConfig == null) { return null; } MethodModel method = smokeTestConfig.getMethod(); FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup( context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig()); GapicMethodContext methodContext = context.asFlattenedMethodContext(method, flatteningGroup); smokeTestBuilder.name(name); smokeTestBuilder.apiClassName(namer.getApiWrapperClassName(context.getInterfaceConfig())); smokeTestBuilder.apiSettingsClassName( namer.getApiSettingsClassName(context.getInterfaceConfig())); StaticLangApiMethodView apiMethodView = createSmokeTestCaseApiMethodView(context, methodContext); smokeTestBuilder.apiMethod(apiMethodView); smokeTestBuilder.requireProjectId( testCaseTransformer.requireProjectIdInSmokeTest(apiMethodView.initCode(), namer)); // must be done as the last step to catch all imports smokeTestBuilder.fileHeader(fileHeaderTransformer.generateFileHeader(context)); return smokeTestBuilder; }
addSmokeTestImports(context); MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod(); SurfaceNamer namer = context.getNamer();
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(); }
MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod(); FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup(
String name = namer.getSmokeTestClassName(context.getInterfaceConfig()); MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod(); TestCaseTransformer testCaseTransformer = new TestCaseTransformer(valueProducer, packageHasMultipleServices);