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;
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");
}
}
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");
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
--- /dev/null
+<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