@Test public void get_report_paths_with_wildcards() { SensorContextTester context = SensorContextTester.create(COVERAGE_DIR); context.setSettings(new MapSettings()); context.settings().setProperty("sonar.go.coverage.reportPaths", "*.absolute.out,glob" + File.separator +"*.out, test*" + File.separator +"*.out, coverage?.out"); Stream<Path> reportPaths = GoCoverSensor.getReportPaths(context); assertThat(reportPaths).containsExactlyInAnyOrder( Paths.get("src", "test", "resources", "coverage", "coverage.linux.absolute.out"), Paths.get("src", "test", "resources", "coverage", "coverage.win.absolute.out"), Paths.get("src", "test", "resources", "coverage", "glob", "coverage.glob.out"), Paths.get("src", "test", "resources", "coverage", "test1", "coverage.out"), Paths.get("src", "test", "resources", "coverage", "coverage1.out")); context.settings().setProperty("sonar.go.coverage.reportPaths", "**" + File.separator +"coverage.glob.out"); Stream<Path> reportPaths2 = GoCoverSensor.getReportPaths(context); assertThat(reportPaths2).containsExactlyInAnyOrder( Paths.get("src", "test", "resources", "coverage", "glob", "coverage.glob.out")); }
static Stream<Path> getReportPaths(SensorContext sensorContext) { Configuration config = sensorContext.config(); Path baseDir = sensorContext.fileSystem().baseDir().toPath(); String[] reportPaths = config.getStringArray(REPORT_PATH_KEY); return Arrays.stream(reportPaths).flatMap(reportPath -> isWildcard(reportPath) ? getPatternPaths(baseDir, reportPath) : getRegularPath(baseDir, reportPath)); }
GoCoverSensor implements Sensor { static Stream<Path> getReportPaths(SensorContext sensorContext) { Configuration config = sensorContext.config(); Path baseDir = sensorContext.fileSystem().baseDir().toPath(); String[] reportPaths = config.getStringArray(REPORT_PATH_KEY); return Arrays.stream(reportPaths).flatMap(reportPath -> isWildcard(reportPath) ? getPatternPaths(baseDir, reportPath) : getRegularPath(baseDir, reportPath)); } }
GoCoverSensor implements Sensor { static Stream<Path> getReportPaths(SensorContext sensorContext) { Configuration config = sensorContext.config(); Path baseDir = sensorContext.fileSystem().baseDir().toPath(); String[] reportPaths = config.getStringArray(REPORT_PATH_KEY); return Arrays.stream(reportPaths).flatMap(reportPath -> isWildcard(reportPath) ? getPatternPaths(baseDir, reportPath) : getRegularPath(baseDir, reportPath)); }  }
GoCoverSensor implements Sensor { static Stream<Path> getReportPaths(SensorContext sensorContext) { Configuration config = sensorContext.config(); Path baseDir = sensorContext.fileSystem().baseDir().toPath(); String[] reportPaths = config.getStringArray(REPORT_PATH_KEY); return Arrays.stream(reportPaths).flatMap(reportPath -> isWildcard(reportPath) ? getPatternPaths(baseDir, reportPath) : getRegularPath(baseDir, reportPath)); }  @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); }
GoCoverSensor implements Sensor { static Stream<Path> getReportPaths(SensorContext sensorContext) { Configuration config = sensorContext.config(); Path baseDir = sensorContext.fileSystem().baseDir().toPath(); String[] reportPaths = config.getStringArray(REPORT_PATH_KEY); return Arrays.stream(reportPaths).flatMap(reportPath -> isWildcard(reportPath) ? getPatternPaths(baseDir, reportPath) : getRegularPath(baseDir, reportPath)); }  @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); static final String REPORT_PATH_KEY; }