@Test public void testSaveIssues() throws Exception { InputFile playbook1 = Utils.getInputFile("playbooks/playbook1.yml"); InputFile playbook2 = Utils.getInputFile("playbooks/playbook2.yml"); InputFile playbook3 = Utils.getInputFile("playbooks/playbook3.yml"); sensor.scannedFiles.add(playbook1); sensor.scannedFiles.add(playbook2); sensor.scannedFiles.add(playbook3); sensor.registerIssue("Bla bla"); sensor.registerIssue(playbook1.toString() + ":Bla bla"); sensor.registerIssue(playbook1.toString() + ":2: [EUNKNOWN] Bla bla"); sensor.registerIssue(playbook1.toString() + ":3: [EAnyCheck1] An error"); sensor.registerIssue(playbook1.toString() + ":4: [AnyCheck2] Another error"); sensor.registerIssue(playbook1.toString() + ":5: [EAnyCheck2] Another error"); sensor.registerIssue(playbook2.toString() + ":3: [EAnyCheck2] Another error"); sensor.saveIssues(context); Collection<Issue> issues = context.allIssues(); assertEquals(3, issues.size()); assertTrue(issueExists(issues, ruleKey2, playbook1, 3, "An error")); assertTrue(issueExists(issues, ruleKey3, playbook1, 5, "Another error")); assertTrue(issueExists(issues, ruleKey3, playbook2, 3, "Another error")); }
protected void saveIssues(SensorContext context) { for (InputFile inputFile : scannedFiles) { LOGGER.debug("Saving issues for {}", inputFile.uri()); Set<String> issues = allIssues.getOrDefault(inputFile.uri(), new HashSet<>()); for (String issue : issues) { String[] tokens = issue.split(":", 2); LOGGER.debug(" Saving issue: {}", issue); String[] ruleTokens = tokens[1].trim().split("\\] ", 2); saveIssue(context, inputFile, Integer.parseInt(tokens[0]), ruleTokens[0].replace("[E", ""), ruleTokens[1]); } } }
AbstractAnsibleSensor implements Sensor { protected void saveIssues(SensorContext context) { for (InputFile inputFile : scannedFiles) { LOGGER.debug("Saving issues for {}", inputFile.uri()); Set<String> issues = allIssues.getOrDefault(inputFile.uri(), new HashSet<>()); for (String issue : issues) { String[] tokens = issue.split(":", 2); LOGGER.debug(" Saving issue: {}", issue); String[] ruleTokens = tokens[1].trim().split("\\] ", 2); saveIssue(context, inputFile, Integer.parseInt(tokens[0]), ruleTokens[0].replace("[E", ""), ruleTokens[1]); } } } }
AbstractAnsibleSensor implements Sensor { protected void saveIssues(SensorContext context) { for (InputFile inputFile : scannedFiles) { LOGGER.debug("Saving issues for {}", inputFile.uri()); Set<String> issues = allIssues.getOrDefault(inputFile.uri(), new HashSet<>()); for (String issue : issues) { String[] tokens = issue.split(":", 2); LOGGER.debug(" Saving issue: {}", issue); String[] ruleTokens = tokens[1].trim().split("\\] ", 2); saveIssue(context, inputFile, Integer.parseInt(tokens[0]), ruleTokens[0].replace("[E", ""), ruleTokens[1]); } } } protected  AbstractAnsibleSensor(FileSystem fileSystem); }
AbstractAnsibleSensor implements Sensor { protected void saveIssues(SensorContext context) { for (InputFile inputFile : scannedFiles) { LOGGER.debug("Saving issues for {}", inputFile.uri()); Set<String> issues = allIssues.getOrDefault(inputFile.uri(), new HashSet<>()); for (String issue : issues) { String[] tokens = issue.split(":", 2); LOGGER.debug(" Saving issue: {}", issue); String[] ruleTokens = tokens[1].trim().split("\\] ", 2); saveIssue(context, inputFile, Integer.parseInt(tokens[0]), ruleTokens[0].replace("[E", ""), ruleTokens[1]); } } } protected  AbstractAnsibleSensor(FileSystem fileSystem);  }
AbstractAnsibleSensor implements Sensor { protected void saveIssues(SensorContext context) { for (InputFile inputFile : scannedFiles) { LOGGER.debug("Saving issues for {}", inputFile.uri()); Set<String> issues = allIssues.getOrDefault(inputFile.uri(), new HashSet<>()); for (String issue : issues) { String[] tokens = issue.split(":", 2); LOGGER.debug(" Saving issue: {}", issue); String[] ruleTokens = tokens[1].trim().split("\\] ", 2); saveIssue(context, inputFile, Integer.parseInt(tokens[0]), ruleTokens[0].replace("[E", ""), ruleTokens[1]); } } } protected  AbstractAnsibleSensor(FileSystem fileSystem);   }