]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3755 fix JSON report when directly analyzing module (like in Eclipse plugin)
authorSimon Brandhof <simon.brandhof@gmail.com>
Fri, 31 May 2013 11:11:25 +0000 (13:11 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Fri, 31 May 2013 11:11:25 +0000 (13:11 +0200)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/InitialOpenIssuesSensor.java
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/InitialOpenIssuesSensorTest.java
sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java

index a5677fb18946da4f6d4c02bed96cca03a97e20f8..a0b9f41e94f744adbeef1b01cfd6e96cd229dfc9 100644 (file)
@@ -53,4 +53,8 @@ public class InitialOpenIssuesSensor implements Sensor {
     initialOpenIssuesStack.setIssues(dtos, loadingDate);
   }
 
+  @Override
+  public String toString() {
+    return getClass().getSimpleName();
+  }
 }
index ba380daaec4d3c835474f002a886bc5523b68143..8a91e329f3cf03180e3c1e1b1b3dd8e5bcb61bdf 100644 (file)
@@ -27,6 +27,7 @@ import org.sonar.core.issue.db.IssueDto;
 
 import java.util.Date;
 
+import static org.fest.assertions.Assertions.assertThat;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyListOf;
 import static org.mockito.Mockito.mock;
@@ -49,4 +50,10 @@ public class InitialOpenIssuesSensorTest {
     verify(issueDao).selectNonClosedIssuesByModule(1);
     verify(stack).setIssues(anyListOf(IssueDto.class), any(Date.class));
   }
+
+  @Test
+  public void test_toString() throws Exception {
+    assertThat(sensor.toString()).isEqualTo("InitialOpenIssuesSensor");
+
+  }
 }
index 0ecfc403f79e9bc0fec35b4c9b53da606607cd28..dcf0231c742e65095303f49cf7b95b419ea580b2 100644 (file)
@@ -77,7 +77,7 @@ public class DryRunDatabaseFactory implements ServerComponent {
       .copyTable(source, dest, "rules_profiles");
     if (projectId != null) {
       String snapshotCondition = "islast=" + database.getDialect().getTrueSqlValue() + " and (project_id=" + projectId + " or root_project_id=" + projectId + ")";
-      template.copyTable(source, dest, "projects", "(id=" + projectId + " or root_id=" + projectId + ")");
+      template.copyTable(source, dest, "projects", "id in (select project_id from snapshots where " + snapshotCondition + ") or (id=" + projectId + " or root_id=" + projectId + ")");
       template.copyTable(source, dest, "snapshots", snapshotCondition);
 
       String forRootModule = "(root_component_id in (select id from projects where id=" + projectId + " and qualifier='TRK'))";