protected GenericToolDriverBase(ToolOptions options) { this(options, new SimpleDiagCollector()); }
@Override public boolean hasErrors() { return getErrorCount() > 0; }
private void assertParsingSuccess(String path, int configVersion, PathSegment... expected) { SimpleDiagCollector diag = new SimpleDiagCollector(); List<PathSegment> segments = new HttpTemplateParser(diag, TEST_LOCATION, path, configVersion).parse(); Assert.assertEquals("Path template " + path + " has unexpected errors\n" + diag, 0, diag.getErrorCount()); Assert.assertEquals(PathSegment.toSyntax(Arrays.asList(expected)), PathSegment.toSyntax(segments)); }
private void assertParsingFailure(final String path, int configVersion, String... expectedErrors) { SimpleDiagCollector diag = new SimpleDiagCollector(); new HttpTemplateParser(diag, TEST_LOCATION, path, configVersion).parse(); List<Diag> expectedDiagErrors = FluentIterable.from(Arrays.asList(expectedErrors)) .transform(new Function<String, Diag>() { @Override public Diag apply(String input) { return Diag.error(TEST_LOCATION, "In path template '" + path + "': " + input); }}).toList(); List<Diag> actualErrors = diag.getErrors(); Assert.assertEquals(expectedDiagErrors, actualErrors); } }
protected GenericToolDriverBase(ToolOptions options) { this(options, new SimpleDiagCollector()); }
@Override public boolean hasErrors() { return getErrorCount() > 0; }
public static DiagReporter createForTest() { return createForTest(new SimpleDiagCollector()); }
private static ConfigProto loadConfigFromFiles(List<String> configFileNames) throws MalformedURLException { DiagCollector diagCollector = new SimpleDiagCollector(); ConfigYamlReader yamlReader = new ConfigYamlReader(); MessageGenerator messageGenerator = new MessageGenerator(ConfigProto.newBuilder()); for (File file : pathsToFiles(configFileNames)) { ConfigHelper helper = new ConfigHelper(diagCollector, file.getName()); ConfigNode configNode = yamlReader.generateConfigNode(file.toURI().toURL(), helper); if (configNode == null) { continue; } messageGenerator.visit(configNode.getChild()); } ConfigProto configProto = (ConfigProto) messageGenerator.getValue(); if (configProto == null || configProto.equals(ConfigProto.getDefaultInstance())) { return null; } return configProto; } }
private ConfigSource testFromInputString(String inputName, String content) { SimpleDiagCollector diag = new SimpleDiagCollector(); ConfigSource config = YamlReader.readConfig(diag, inputName, content, supportedConfigTypes); if (config == null) { testOutput().println("errors!!"); testOutput().println(diag); } else { testOutput().println(TextFormatForTest.INSTANCE.printToString(config.getConfig())); } return config; }
protected void setupDiscovery() { for (String fileName : gapicConfigFileNames) { this.gapicConfigFilePaths.add(getTestDataLocator().findTestData(fileName).getFile()); } try { discoGapicGenerators = DiscoGapicGeneratorApp.getGenerators( getTestDataLocator().findTestData(discoveryDocFileName).getPath(), gapicConfigFilePaths, getTestDataLocator().findTestData(packageConfigFileName).getPath(), getTestDataLocator() .findTestData("com/google/api/codegen/testsrc/common/frozen_dependencies.yaml") .getPath(), language.toString().toLowerCase(), Collections.emptyList(), ArtifactType.LEGACY_DISCOGAPIC_AND_PACKAGE); } catch (IOException e) { throw new IllegalArgumentException("Problem creating DiscoGapic generator.", e); } config = CodegenTestUtil.readConfig( new SimpleDiagCollector(), getTestDataLocator(), gapicConfigFileNames); if (config == null) { throw new IllegalArgumentException("Problem fetching or parsing Gapic config files."); } }