@Test public void testRegisterIssue() { assertFalse(sensor.registerIssue("invalid issue")); assertFalse(sensor.registerIssue("filename:invalid issue")); assertFalse(sensor.registerIssue("filename:a:invalid issue")); assertFalse(sensor.registerIssue("filename:12:invalid issue")); assertFalse(sensor.registerIssue("filename:12: invalid issue")); assertFalse(sensor.registerIssue("filename:12:[xxx]invalid issue")); assertFalse(sensor.registerIssue("filename:12: [xxx]invalid issue")); assertFalse(sensor.registerIssue("filename:12: [xxx] invalid issue")); assertFalse(sensor.registerIssue("filename:12: [Exxx]invalid issue")); assertFalse(sensor.registerIssue("filename:12:[Exxx]invalid issue")); assertFalse(sensor.registerIssue("filename:12:[Exxx] invalid issue")); assertFalse(sensor.registerIssue("filename:12: [Exxx invalid issue")); File file1 = new File("/path/to/myfile.yml"); assertTrue(sensor.registerIssue(file1.getPath() + ":2: [Exxx] there is a problem")); assertTrue(sensor.registerIssue(file1.getPath() + ":3: [Eyyy] there is another problem")); File file2 = new File("/path/to/another/file.yml"); assertTrue(sensor.registerIssue(file2.getPath() + ":2: [Exxx] there is a problem")); assertEquals(2, sensor.allIssues.size()); assertEquals(2, sensor.allIssues.get(file1.toURI()).size()); assertTrue(sensor.allIssues.get(file1.toURI()).contains("2: [Exxx] there is a problem")); assertTrue(sensor.allIssues.get(file1.toURI()).contains("3: [Eyyy] there is another problem")); assertEquals(1, sensor.allIssues.get(file2.toURI()).size()); assertTrue(sensor.allIssues.get(file2.toURI()).contains("2: [Exxx] there is a problem")); }
protected boolean registerIssue(String rawIssue) { if (!rawIssue.matches("^.+:[0-9]+: \\[E.+\\] .+$")) { LOGGER.warn("Invalid issue syntax, ignoring: " + rawIssue); return false; } String[] tokens = rawIssue.split(":", 2); URI fileURI = new File(tokens[0]).toURI(); if (!allIssues.containsKey(fileURI)) { allIssues.put(fileURI, new HashSet<>()); } allIssues.get(fileURI).add(tokens[1]); return true; }
AbstractAnsibleSensor implements Sensor { protected boolean registerIssue(String rawIssue) { if (!rawIssue.matches("^.+:[0-9]+: \\[E.+\\] .+$")) { LOGGER.warn("Invalid issue syntax, ignoring: " + rawIssue); return false; } String[] tokens = rawIssue.split(":", 2); URI fileURI = new File(tokens[0]).toURI(); if (!allIssues.containsKey(fileURI)) { allIssues.put(fileURI, new HashSet<>()); } allIssues.get(fileURI).add(tokens[1]); return true; } }
AbstractAnsibleSensor implements Sensor { protected boolean registerIssue(String rawIssue) { if (!rawIssue.matches("^.+:[0-9]+: \\[E.+\\] .+$")) { LOGGER.warn("Invalid issue syntax, ignoring: " + rawIssue); return false; } String[] tokens = rawIssue.split(":", 2); URI fileURI = new File(tokens[0]).toURI(); if (!allIssues.containsKey(fileURI)) { allIssues.put(fileURI, new HashSet<>()); } allIssues.get(fileURI).add(tokens[1]); return true; } protected  AbstractAnsibleSensor(FileSystem fileSystem); }
AbstractAnsibleSensor implements Sensor { protected boolean registerIssue(String rawIssue) { if (!rawIssue.matches("^.+:[0-9]+: \\[E.+\\] .+$")) { LOGGER.warn("Invalid issue syntax, ignoring: " + rawIssue); return false; } String[] tokens = rawIssue.split(":", 2); URI fileURI = new File(tokens[0]).toURI(); if (!allIssues.containsKey(fileURI)) { allIssues.put(fileURI, new HashSet<>()); } allIssues.get(fileURI).add(tokens[1]); return true; } protected  AbstractAnsibleSensor(FileSystem fileSystem);  }
AbstractAnsibleSensor implements Sensor { protected boolean registerIssue(String rawIssue) { if (!rawIssue.matches("^.+:[0-9]+: \\[E.+\\] .+$")) { LOGGER.warn("Invalid issue syntax, ignoring: " + rawIssue); return false; } String[] tokens = rawIssue.split(":", 2); URI fileURI = new File(tokens[0]).toURI(); if (!allIssues.containsKey(fileURI)) { allIssues.put(fileURI, new HashSet<>()); } allIssues.get(fileURI).add(tokens[1]); return true; } protected  AbstractAnsibleSensor(FileSystem fileSystem);   }