aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java4
-rw-r--r--sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java12
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_issues.xml24
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_unresolved_issues.xml69
4 files changed, 83 insertions, 26 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java b/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java
index b6cd161d28f..0111aa19950 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/DryRunDatabaseFactory.java
@@ -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");
}
}
diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java b/sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java
index 11b35e77c97..3e0e4bc69ff 100644
--- a/sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/persistence/DryRunDatabaseFactoryTest.java
@@ -98,6 +98,18 @@ public class DryRunDatabaseFactoryTest extends AbstractDaoTestCase {
}
@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");
diff --git a/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_issues.xml b/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_issues.xml
index d25ce652ec8..04e17ab8f0d 100644
--- a/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_issues.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_issues.xml
@@ -42,28 +42,4 @@
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
index 00000000000..d25ce652ec8
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/persistence/DryRunDatabaseFactoryTest/should_create_database_with_unresolved_issues.xml
@@ -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