From e0556fea48459c0a46f99cbc2d03771628669885 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 16 Jan 2013 09:05:45 +0100 Subject: [PATCH] SONAR-2501 Do nothing when adding a test cover if test does not exist --- .../org/sonar/api/tests/ProjectTestsImpl.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/tests/ProjectTestsImpl.java b/sonar-plugin-api/src/main/java/org/sonar/api/tests/ProjectTestsImpl.java index 44324b46be8..24c14fa9dba 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/tests/ProjectTestsImpl.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/tests/ProjectTestsImpl.java @@ -46,16 +46,18 @@ public class ProjectTestsImpl implements ProjectTests, BatchExtension { FileTest fileTest = getFileTest(fileTestKey); fileTest.addTest(test); - LOG.debug("Added a new test : " + toString()); + LOG.info("Added a new test : " + toString()); } - public List getFileTests() { - return fileTests; + public void cover(String fileTestKey, String test, String mainFile, Collection lines) { + FileTest fileTest = find(fileTestKey); + if (fileTest != null) { + LOG.info("Covering - File test : " + fileTestKey + ", test : " + test + ", file : " + mainFile + ", lines : " + Iterables.toString(lines)); + } } - public void cover(String fileTestKey, String test, String mainFile, Collection lines){ - FileTest fileTest = find(fileTestKey); - LOG.debug("Covering - File test :" + toString() + ", test:" + test + ", file:" + mainFile+ ", lines:"+ Iterables.toString(lines)); + public List getFileTests() { + return fileTests; } private FileTest getFileTest(final String key) { @@ -67,7 +69,7 @@ public class ProjectTestsImpl implements ProjectTests, BatchExtension { return fileTest; } - private FileTest find(final String key){ + private FileTest find(final String key) { return Iterables.find(fileTests, new Predicate() { public boolean apply(FileTest fileTest) { return fileTest.getKey().equals(key); -- 2.39.5