private static Predicate<GapicInterfaceContext> shouldGenSmokeTestPackage() { return parameter -> parameter.getInterfaceConfig().getSmokeTestConfig() != null; }
@Override public List<ViewModel> transform(ProtoApiModel model, GapicProductConfig productConfig) { List<ViewModel> views = new ArrayList<>(); for (InterfaceModel apiInterface : model.getInterfaces()) { if (!productConfig.hasInterfaceConfig(apiInterface)) { continue; } GapicInterfaceContext context = createContext(apiInterface, productConfig, PhpSurfaceNamer.TestKind.UNIT); views.add(createUnitTestFileView(context)); if (context.getInterfaceConfig().getSmokeTestConfig() != null) { context = createContext(apiInterface, productConfig, PhpSurfaceNamer.TestKind.SYSTEM); views.add(createSmokeTestClassView(context)); } } return views; }
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; }
Joiner.on(File.separator).join("tests", "system", "gapic", version, filename); MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod(); FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup( context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig()); GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup);
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( context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig()); GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup);
String name = namer.getSmokeTestClassName(context.getInterfaceConfig()); MethodModel method = context.getInterfaceConfig().getSmokeTestConfig().getMethod(); TestCaseTransformer testCaseTransformer = new TestCaseTransformer(valueProducer, packageHasMultipleServices); FlatteningConfig flatteningGroup = testCaseTransformer.getSmokeTestFlatteningGroup( context.getMethodConfig(method), context.getInterfaceConfig().getSmokeTestConfig()); GapicMethodContext flattenedMethodContext = context.asFlattenedMethodContext(method, flatteningGroup);