@Test void testDoNothingIfNoXmlFile() throws Exception { CheckFactory checkFactory = new CheckFactory(activeRules()); XmlFileSensor sensor = new XmlFileSensor(checkFactory); addFileWithIssue("foo"); sensor.execute(context); assertThat(context.allIssues()).isEmpty(); }
@Override public void execute(SensorContext context) { FileSystem fs = context.fileSystem(); FilePredicate xmlFilesPredicate = fs.predicates().matchesPathPattern("**/*.xml"); List<InputFile> inputFiles = new ArrayList<>(); fs.inputFiles(xmlFilesPredicate).forEach(inputFile1 -> { context.markForPublishing(inputFile1); inputFiles.add(inputFile1); }); if (inputFiles.isEmpty()) { return; } ProgressReport progressReport = new ProgressReport("Report about progress of Java XML analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(inputFiles.stream().map(InputFile::toString).collect(Collectors.toList())); boolean successfullyCompleted = false; boolean cancelled = false; try { for (InputFile inputFile : inputFiles) { if (context.isCancelled()) { cancelled = true; break; } scanFile(context, inputFile); progressReport.nextFile(); } successfullyCompleted = !cancelled; } finally { if (successfullyCompleted) { progressReport.stop(); } else { progressReport.cancel(); } } }
XmlFileSensor implements Sensor { @Override public void execute(SensorContext context) { FileSystem fs = context.fileSystem(); FilePredicate xmlFilesPredicate = fs.predicates().matchesPathPattern("**/*.xml"); List<InputFile> inputFiles = new ArrayList<>(); fs.inputFiles(xmlFilesPredicate).forEach(inputFile1 -> { context.markForPublishing(inputFile1); inputFiles.add(inputFile1); }); if (inputFiles.isEmpty()) { return; } ProgressReport progressReport = new ProgressReport("Report about progress of Java XML analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(inputFiles.stream().map(InputFile::toString).collect(Collectors.toList())); boolean successfullyCompleted = false; boolean cancelled = false; try { for (InputFile inputFile : inputFiles) { if (context.isCancelled()) { cancelled = true; break; } scanFile(context, inputFile); progressReport.nextFile(); } successfullyCompleted = !cancelled; } finally { if (successfullyCompleted) { progressReport.stop(); } else { progressReport.cancel(); } } } }
XmlFileSensor implements Sensor { @Override public void execute(SensorContext context) { FileSystem fs = context.fileSystem(); FilePredicate xmlFilesPredicate = fs.predicates().matchesPathPattern("**/*.xml"); List<InputFile> inputFiles = new ArrayList<>(); fs.inputFiles(xmlFilesPredicate).forEach(inputFile1 -> { context.markForPublishing(inputFile1); inputFiles.add(inputFile1); }); if (inputFiles.isEmpty()) { return; } ProgressReport progressReport = new ProgressReport("Report about progress of Java XML analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(inputFiles.stream().map(InputFile::toString).collect(Collectors.toList())); boolean successfullyCompleted = false; boolean cancelled = false; try { for (InputFile inputFile : inputFiles) { if (context.isCancelled()) { cancelled = true; break; } scanFile(context, inputFile); progressReport.nextFile(); } successfullyCompleted = !cancelled; } finally { if (successfullyCompleted) { progressReport.stop(); } else { progressReport.cancel(); } } } XmlFileSensor(CheckFactory checkFactory); }
XmlFileSensor implements Sensor { @Override public void execute(SensorContext context) { FileSystem fs = context.fileSystem(); FilePredicate xmlFilesPredicate = fs.predicates().matchesPathPattern("**/*.xml"); List<InputFile> inputFiles = new ArrayList<>(); fs.inputFiles(xmlFilesPredicate).forEach(inputFile1 -> { context.markForPublishing(inputFile1); inputFiles.add(inputFile1); }); if (inputFiles.isEmpty()) { return; } ProgressReport progressReport = new ProgressReport("Report about progress of Java XML analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(inputFiles.stream().map(InputFile::toString).collect(Collectors.toList())); boolean successfullyCompleted = false; boolean cancelled = false; try { for (InputFile inputFile : inputFiles) { if (context.isCancelled()) { cancelled = true; break; } scanFile(context, inputFile); progressReport.nextFile(); } successfullyCompleted = !cancelled; } finally { if (successfullyCompleted) { progressReport.stop(); } else { progressReport.cancel(); } } } XmlFileSensor(CheckFactory checkFactory); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context); }
XmlFileSensor implements Sensor { @Override public void execute(SensorContext context) { FileSystem fs = context.fileSystem(); FilePredicate xmlFilesPredicate = fs.predicates().matchesPathPattern("**/*.xml"); List<InputFile> inputFiles = new ArrayList<>(); fs.inputFiles(xmlFilesPredicate).forEach(inputFile1 -> { context.markForPublishing(inputFile1); inputFiles.add(inputFile1); }); if (inputFiles.isEmpty()) { return; } ProgressReport progressReport = new ProgressReport("Report about progress of Java XML analyzer", TimeUnit.SECONDS.toMillis(10)); progressReport.start(inputFiles.stream().map(InputFile::toString).collect(Collectors.toList())); boolean successfullyCompleted = false; boolean cancelled = false; try { for (InputFile inputFile : inputFiles) { if (context.isCancelled()) { cancelled = true; break; } scanFile(context, inputFile); progressReport.nextFile(); } successfullyCompleted = !cancelled; } finally { if (successfullyCompleted) { progressReport.stop(); } else { progressReport.cancel(); } } } XmlFileSensor(CheckFactory checkFactory); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context);  }