]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2501 Do nothing when adding a test cover if test does not exist
authorJulien Lancelot <julien.lancelot@gmail.com>
Wed, 16 Jan 2013 08:05:45 +0000 (09:05 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Wed, 16 Jan 2013 08:06:18 +0000 (09:06 +0100)
sonar-plugin-api/src/main/java/org/sonar/api/tests/ProjectTestsImpl.java

index 44324b46be8e67fbbf7e9971069d2d2938b0cc59..24c14fa9dba46ae93b200d7a2df206f2fc1647b9 100644 (file)
@@ -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<FileTest> getFileTests() {
-    return fileTests;
+  public void cover(String fileTestKey, String test, String mainFile, Collection<Integer> 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<Integer> lines){
-    FileTest fileTest = find(fileTestKey);
-    LOG.debug("Covering - File test :" + toString() + ", test:" + test + ", file:" + mainFile+ ", lines:"+ Iterables.toString(lines));
+  public List<FileTest> 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<FileTest>() {
       public boolean apply(FileTest fileTest) {
         return fileTest.getKey().equals(key);