]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4490 When creating the H2 db, selected issues should be the unresolved ones...
authorJulien Lancelot <julien.lancelot@gmail.com>
Thu, 11 Jul 2013 07:49:48 +0000 (09:49 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Thu, 11 Jul 2013 07:49:48 +0000 (09:49 +0200)
sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java
sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java
sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_issues.xml
sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_unresolved_issues.xml [new file with mode: 0644]

index b6cd161d28fde1f19ce0e64ccff129d0b57bd481..0111aa199507f031576e229118232576550b30f3 100644 (file)
@@ -22,12 +22,12 @@ package org.sonar.core.persistence;
 import com.google.common.io.Files;
 import org.apache.commons.dbcp.BasicDataSource;
 import org.sonar.api.ServerComponent;
-import org.sonar.api.issue.Issue;
 import org.sonar.api.platform.ServerFileSystem;
 import org.sonar.api.utils.SonarException;
 
 import javax.annotation.Nullable;
 import javax.sql.DataSource;
+
 import java.io.File;
 import java.io.IOException;
 import java.sql.SQLException;
@@ -83,7 +83,7 @@ public class DryRunDatabaseFactory implements ServerComponent {
 
       String forRootModule = "(root_component_id in (select id from projects where id=" + projectId + " and qualifier='TRK'))";
       String forSubModule = "(component_id in (select id from projects where id=" + projectId + " or root_id=" + projectId + "))";
-      template.copyTable(source, dest, "issues", "(" + forRootModule + ") or( " + forSubModule + ")", "status<>'" + Issue.STATUS_CLOSED + "'");
+      template.copyTable(source, dest, "issues", "(" + forRootModule + ") or( " + forSubModule + ")", "resolution is null");
     }
   }
 
index 11b35e77c97f2d7d6669bf6506a1d73ac3513a00..3e0e4bc69ffe7721a9a1e3f305401c33a8a4d135 100644 (file)
@@ -97,6 +97,18 @@ public class DryRunDatabaseFactoryTest extends AbstractDaoTestCase {
     assertThat(rowCount("issues")).isEqualTo(1);
   }
 
+  @Test
+  public void should_create_database_with_unresolved_issues() throws IOException, SQLException {
+    setupData("should_create_database_with_unresolved_issues");
+
+    when(serverFileSystem.getTempDir()).thenReturn(temporaryFolder.newFolder());
+
+    byte[] database = localDatabaseFactory.createDatabaseForDryRun(399L);
+    dataSource = createDatabase(database);
+
+    assertThat(rowCount("issues")).isEqualTo(1);
+  }
+
   @Test
   public void should_export_issues_of_project_tree() throws IOException, SQLException {
     setupData("multi-modules-with-issues");
index d25ce652ec83d75f464a20ee22497f6dbf14c086..04e17ab8f0d57afc7c98e6e3ba8c60d2ef14e28c 100644 (file)
       updated_at="[null]"
       />
 
-  <issues
-      id="101"
-      kee="101"
-      component_id="401"
-      rule_id="501"
-      severity="MAJOR"
-      manual_severity="[false]"
-      message="[null]"
-      line="120"
-      effort_to_fix="[null]"
-      status="CLOSED"
-      resolution="FIXED"
-      checksum="[null]"
-      reporter="[null]"
-      assignee="user"
-      author_login="[null]"
-      issue_attributes="[null]"
-      issue_creation_date="2013-04-16"
-      issue_update_date="2013-04-16"
-      issue_close_date="2013-04-16"
-      created_at="[null]"
-      updated_at="[null]"
-      />
-
 </dataset>
\ No newline at end of file
diff --git a/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_unresolved_issues.xml b/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_unresolved_issues.xml
new file mode 100644 (file)
index 0000000..d25ce65
--- /dev/null
@@ -0,0 +1,69 @@
+<dataset>
+  <metrics id="1" name="ncloc" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+           enabled="[true]" worst_value="[null]" optimized_best_value="[null]" best_value="[null]" direction="0" hidden="[false]" delete_historical_data="[null]"/>
+  <metrics id="2" name="coverage" VAL_TYPE="INT" DESCRIPTION="[null]" domain="[null]" short_name=""
+           enabled="[true]" worst_value="0" optimized_best_value="[true]" best_value="100" direction="1" hidden="[false]" delete_historical_data="[null]"/>
+
+  <rules_profiles id="1" name="Sonar way with Findbugs" language="java" parent_name="" version="1"
+                  used_profile="[false]"/>
+
+  <projects id="399" kee="struts" root_id="[null]"/>
+  <projects id="400" kee="Action.java" root_id="399"/>
+  <projects id="401" kee="Filter.java" root_id="399"/>
+
+  <snapshots id="100" project_id="399" root_snapshot_id="[null]" path="" islast="[true]"/>
+  <snapshots id="101" project_id="400" root_snapshot_id="100" path="100." islast="[true]"/>
+  <snapshots id="102" project_id="401" root_snapshot_id="100" path="100." islast="[true]"/>
+
+  <rules id="500" plugin_rule_key="AvoidCycle" plugin_name="squid"/>
+  <rules id="501" plugin_rule_key="NullRef" plugin_name="squid"/>
+
+  <issues
+      id="100"
+      kee="100"
+      component_id="400"
+      rule_id="500"
+      severity="BLOCKER"
+      manual_severity="[false]"
+      message="[null]"
+      line="200"
+      effort_to_fix="[null]"
+      status="OPEN"
+      resolution="[null]"
+      checksum="[null]"
+      reporter="user"
+      assignee="user"
+      author_login="[null]"
+      issue_attributes="[null]"
+      issue_creation_date="2013-04-16"
+      issue_update_date="2013-04-16"
+      issue_close_date="2013-04-16"
+      created_at="[null]"
+      updated_at="[null]"
+      />
+
+  <issues
+      id="101"
+      kee="101"
+      component_id="401"
+      rule_id="501"
+      severity="MAJOR"
+      manual_severity="[false]"
+      message="[null]"
+      line="120"
+      effort_to_fix="[null]"
+      status="CLOSED"
+      resolution="FIXED"
+      checksum="[null]"
+      reporter="[null]"
+      assignee="user"
+      author_login="[null]"
+      issue_attributes="[null]"
+      issue_creation_date="2013-04-16"
+      issue_update_date="2013-04-16"
+      issue_close_date="2013-04-16"
+      created_at="[null]"
+      updated_at="[null]"
+      />
+
+</dataset>
\ No newline at end of file