aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-11-06 09:41:02 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2014-11-19 22:23:00 +0100
commit2c0723fd73baf8826cd9f804d9f604ee12e778f9 (patch)
tree8d8fa22c72787e735fbe940dacade568c62f3a33 /sonar-core/src
parent80734db88f7df715536e781655cddac86b03ef05 (diff)
downloadsonarqube-2c0723fd73baf8826cd9f804d9f604ee12e778f9.tar.gz
sonarqube-2c0723fd73baf8826cd9f804d9f604ee12e778f9.zip
SONAR-5827 Feed the new "file_sources" table
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java79
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java69
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java95
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java33
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml27
-rw-r--r--sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java5
-rw-r--r--sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java69
-rw-r--r--sonar-core/src/test/java/org/sonar/core/source/db/SnapshotSourceDaoTest.java2
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml7
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml5
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml5
11 files changed, 382 insertions, 14 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
index 2d0c0d97428..cc81d7d2ccc 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
@@ -24,7 +24,11 @@ import com.google.common.io.Closeables;
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
import org.apache.ibatis.logging.LogFactory;
import org.apache.ibatis.mapping.Environment;
-import org.apache.ibatis.session.*;
+import org.apache.ibatis.session.Configuration;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.apache.ibatis.type.JdbcType;
import org.slf4j.LoggerFactory;
@@ -41,7 +45,14 @@ import org.sonar.core.component.db.SnapshotMapper;
import org.sonar.core.computation.db.AnalysisReportDto;
import org.sonar.core.computation.db.AnalysisReportMapper;
import org.sonar.core.config.Logback;
-import org.sonar.core.dashboard.*;
+import org.sonar.core.dashboard.ActiveDashboardDto;
+import org.sonar.core.dashboard.ActiveDashboardMapper;
+import org.sonar.core.dashboard.DashboardDto;
+import org.sonar.core.dashboard.DashboardMapper;
+import org.sonar.core.dashboard.WidgetDto;
+import org.sonar.core.dashboard.WidgetMapper;
+import org.sonar.core.dashboard.WidgetPropertyDto;
+import org.sonar.core.dashboard.WidgetPropertyMapper;
import org.sonar.core.dependency.DependencyDto;
import org.sonar.core.dependency.DependencyMapper;
import org.sonar.core.dependency.ResourceSnapshotDto;
@@ -50,11 +61,34 @@ import org.sonar.core.duplication.DuplicationMapper;
import org.sonar.core.duplication.DuplicationUnitDto;
import org.sonar.core.graph.jdbc.GraphDto;
import org.sonar.core.graph.jdbc.GraphDtoMapper;
-import org.sonar.core.issue.db.*;
-import org.sonar.core.measure.db.*;
+import org.sonar.core.issue.db.ActionPlanDto;
+import org.sonar.core.issue.db.ActionPlanMapper;
+import org.sonar.core.issue.db.ActionPlanStatsDto;
+import org.sonar.core.issue.db.ActionPlanStatsMapper;
+import org.sonar.core.issue.db.IssueAuthorizationDto;
+import org.sonar.core.issue.db.IssueAuthorizationMapper;
+import org.sonar.core.issue.db.IssueChangeDto;
+import org.sonar.core.issue.db.IssueChangeMapper;
+import org.sonar.core.issue.db.IssueDto;
+import org.sonar.core.issue.db.IssueFilterDto;
+import org.sonar.core.issue.db.IssueFilterFavouriteDto;
+import org.sonar.core.issue.db.IssueFilterFavouriteMapper;
+import org.sonar.core.issue.db.IssueFilterMapper;
+import org.sonar.core.issue.db.IssueMapper;
+import org.sonar.core.measure.db.MeasureDto;
+import org.sonar.core.measure.db.MeasureFilterDto;
+import org.sonar.core.measure.db.MeasureFilterMapper;
+import org.sonar.core.measure.db.MeasureMapper;
+import org.sonar.core.measure.db.MetricDto;
+import org.sonar.core.measure.db.MetricMapper;
import org.sonar.core.notification.db.NotificationQueueDto;
import org.sonar.core.notification.db.NotificationQueueMapper;
-import org.sonar.core.permission.*;
+import org.sonar.core.permission.GroupWithPermissionDto;
+import org.sonar.core.permission.PermissionTemplateDto;
+import org.sonar.core.permission.PermissionTemplateGroupDto;
+import org.sonar.core.permission.PermissionTemplateMapper;
+import org.sonar.core.permission.PermissionTemplateUserDto;
+import org.sonar.core.permission.UserWithPermissionDto;
import org.sonar.core.persistence.dialect.Dialect;
import org.sonar.core.persistence.migration.v44.Migration44Mapper;
import org.sonar.core.persistence.migration.v45.Migration45Mapper;
@@ -63,12 +97,26 @@ import org.sonar.core.properties.PropertiesMapper;
import org.sonar.core.properties.PropertyDto;
import org.sonar.core.purge.PurgeMapper;
import org.sonar.core.purge.PurgeableSnapshotDto;
-import org.sonar.core.qualitygate.db.*;
-import org.sonar.core.qualityprofile.db.*;
-import org.sonar.core.resource.*;
+import org.sonar.core.qualitygate.db.ProjectQgateAssociationDto;
+import org.sonar.core.qualitygate.db.ProjectQgateAssociationMapper;
+import org.sonar.core.qualitygate.db.QualityGateConditionDto;
+import org.sonar.core.qualitygate.db.QualityGateConditionMapper;
+import org.sonar.core.qualitygate.db.QualityGateDto;
+import org.sonar.core.qualitygate.db.QualityGateMapper;
+import org.sonar.core.qualityprofile.db.ActiveRuleDto;
+import org.sonar.core.qualityprofile.db.ActiveRuleMapper;
+import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
+import org.sonar.core.qualityprofile.db.QualityProfileDto;
+import org.sonar.core.qualityprofile.db.QualityProfileMapper;
+import org.sonar.core.resource.ResourceDto;
+import org.sonar.core.resource.ResourceIndexDto;
+import org.sonar.core.resource.ResourceIndexerMapper;
+import org.sonar.core.resource.ResourceKeyUpdaterMapper;
+import org.sonar.core.resource.ResourceMapper;
import org.sonar.core.rule.RuleDto;
import org.sonar.core.rule.RuleMapper;
import org.sonar.core.rule.RuleParamDto;
+import org.sonar.core.source.db.FileSourceMapper;
import org.sonar.core.source.db.SnapshotDataDto;
import org.sonar.core.source.db.SnapshotDataMapper;
import org.sonar.core.source.db.SnapshotSourceMapper;
@@ -77,7 +125,17 @@ import org.sonar.core.technicaldebt.db.CharacteristicMapper;
import org.sonar.core.technicaldebt.db.RequirementMigrationDto;
import org.sonar.core.template.LoadedTemplateDto;
import org.sonar.core.template.LoadedTemplateMapper;
-import org.sonar.core.user.*;
+import org.sonar.core.user.AuthorDto;
+import org.sonar.core.user.AuthorMapper;
+import org.sonar.core.user.GroupDto;
+import org.sonar.core.user.GroupMapper;
+import org.sonar.core.user.GroupMembershipDto;
+import org.sonar.core.user.GroupMembershipMapper;
+import org.sonar.core.user.GroupRoleDto;
+import org.sonar.core.user.RoleMapper;
+import org.sonar.core.user.UserDto;
+import org.sonar.core.user.UserMapper;
+import org.sonar.core.user.UserRoleDto;
import java.io.InputStream;
@@ -176,7 +234,8 @@ public class MyBatis implements BatchComponent, ServerComponent {
LoadedTemplateMapper.class, MeasureFilterMapper.class, Migration44Mapper.class, PermissionTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class,
ResourceKeyUpdaterMapper.class, ResourceIndexerMapper.class, ResourceSnapshotMapper.class, RoleMapper.class, RuleMapper.class,
SchemaMigrationMapper.class, SemaphoreMapper.class, UserMapper.class, GroupMapper.class, WidgetMapper.class, WidgetPropertyMapper.class,
- org.sonar.api.database.model.MeasureMapper.class, SnapshotDataMapper.class, SnapshotSourceMapper.class, ActionPlanMapper.class, ActionPlanStatsMapper.class,
+ org.sonar.api.database.model.MeasureMapper.class, SnapshotDataMapper.class, SnapshotSourceMapper.class, FileSourceMapper.class, ActionPlanMapper.class,
+ ActionPlanStatsMapper.class,
NotificationQueueMapper.class, CharacteristicMapper.class,
GroupMembershipMapper.class, QualityProfileMapper.class, ActiveRuleMapper.class,
MeasureMapper.class, MetricMapper.class, QualityGateMapper.class, QualityGateConditionMapper.class, ComponentMapper.class, SnapshotMapper.class,
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java
new file mode 100644
index 00000000000..63dcf2631d3
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDao.java
@@ -0,0 +1,69 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.core.source.db;
+
+import org.sonar.api.BatchComponent;
+import org.sonar.api.ServerComponent;
+import org.sonar.core.persistence.DbSession;
+import org.sonar.core.persistence.MyBatis;
+
+import javax.annotation.CheckForNull;
+
+public class FileSourceDao implements BatchComponent, ServerComponent {
+
+ private final MyBatis mybatis;
+
+ public FileSourceDao(MyBatis myBatis) {
+ this.mybatis = myBatis;
+ }
+
+ @CheckForNull
+ public FileSourceDto select(String fileUuid) {
+ DbSession session = mybatis.openSession(false);
+ try {
+ FileSourceMapper mapper = session.getMapper(FileSourceMapper.class);
+ return mapper.select(fileUuid);
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ }
+
+ public void insert(FileSourceDto dto) {
+ DbSession session = mybatis.openSession(false);
+ try {
+ session.getMapper(FileSourceMapper.class).insert(dto);
+ session.commit();
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ }
+
+ public void update(FileSourceDto dto) {
+ DbSession session = mybatis.openSession(false);
+ try {
+ session.getMapper(FileSourceMapper.class).update(dto);
+ session.commit();
+ } finally {
+ MyBatis.closeQuietly(session);
+ }
+ }
+
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java
new file mode 100644
index 00000000000..b089d7b117d
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java
@@ -0,0 +1,95 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.core.source.db;
+
+import java.util.Date;
+
+public class FileSourceDto {
+ private Long id;
+ private String projectUuid;
+ private String fileUuid;
+ private Date createdAt;
+ private Date updatedAt;
+ private String data;
+ private String dataHash;
+
+ public Long getId() {
+ return id;
+ }
+
+ public FileSourceDto setId(Long id) {
+ this.id = id;
+ return this;
+ }
+
+ public String getProjectUuid() {
+ return projectUuid;
+ }
+
+ public FileSourceDto setProjectUuid(String projectUuid) {
+ this.projectUuid = projectUuid;
+ return this;
+ }
+
+ public String getFileUuid() {
+ return fileUuid;
+ }
+
+ public FileSourceDto setFileUuid(String fileUuid) {
+ this.fileUuid = fileUuid;
+ return this;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public FileSourceDto setData(String data) {
+ this.data = data;
+ return this;
+ }
+
+ public String getDataHash() {
+ return dataHash;
+ }
+
+ public FileSourceDto setDataHash(String dataHash) {
+ this.dataHash = dataHash;
+ return this;
+ }
+
+ public Date getCreatedAt() {
+ return createdAt;
+ }
+
+ public FileSourceDto setCreatedAt(Date createdAt) {
+ this.createdAt = createdAt;
+ return this;
+ }
+
+ public Date getUpdatedAt() {
+ return updatedAt;
+ }
+
+ public FileSourceDto setUpdatedAt(Date updatedAt) {
+ this.updatedAt = updatedAt;
+ return this;
+ }
+}
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java
new file mode 100644
index 00000000000..302f727e369
--- /dev/null
+++ b/sonar-core/src/main/java/org/sonar/core/source/db/FileSourceMapper.java
@@ -0,0 +1,33 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.core.source.db;
+
+import javax.annotation.CheckForNull;
+
+public interface FileSourceMapper {
+
+ @CheckForNull
+ FileSourceDto select(String fileUuid);
+
+ void insert(FileSourceDto dto);
+
+ void update(FileSourceDto dto);
+}
diff --git a/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml b/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml
new file mode 100644
index 00000000000..033ab9ed648
--- /dev/null
+++ b/sonar-core/src/main/resources/org/sonar/core/source/db/FileSourceMapper.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="org.sonar.core.source.db.FileSourceMapper">
+
+ <select id="select" parameterType="string" resultType="org.sonar.core.source.db.FileSourceDto">
+ SELECT id, project_uuid as projectUuid, file_uuid as fileUuid, created_at as createdAt, updated_at as updatedAt, data, data_hash as dataHash
+ FROM file_sources
+ WHERE file_uuid = #{fileUuid}
+ </select>
+
+ <insert id="insert" parameterType="org.sonar.core.source.db.FileSourceDto" useGeneratedKeys="false">
+ insert into file_sources (project_uuid, file_uuid, created_at, updated_at, data, data_hash)
+ values (#{projectUuid}, #{fileUuid}, #{createdAt}, #{updatedAt}, #{data}, #{dataHash})
+ </insert>
+
+ <update id="update" parameterType="org.sonar.core.source.db.FileSourceDto" useGeneratedKeys="false">
+ update file_sources set
+ updated_at = #{updatedAt},
+ data = #{data},
+ data_hash = #{dataHash}
+ where id = #{id}
+ </update>
+
+</mapper>
+
diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java b/sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java
index f4a45af0681..cdcf00ddf1a 100644
--- a/sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java
+++ b/sonar-core/src/test/java/org/sonar/core/persistence/AbstractDaoTestCase.java
@@ -265,9 +265,8 @@ public abstract class AbstractDaoTestCase {
private IDataSet getExpectedData(String testName) {
String className = getClass().getName();
- className = String.format("/%s/%s-result.xml", className.replace('.', '/'), testName);
-
- InputStream in = getClass().getResourceAsStream(className);
+ String fileName = String.format("/%s/%s-result.xml", className.replace('.', '/'), testName);
+ InputStream in = getClass().getResourceAsStream(fileName);
try {
return getData(in);
} finally {
diff --git a/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java b/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java
new file mode 100644
index 00000000000..a2adccdc7d1
--- /dev/null
+++ b/sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java
@@ -0,0 +1,69 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.core.source.db;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.utils.DateUtils;
+import org.sonar.core.persistence.AbstractDaoTestCase;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class FileSourceDaoTest extends AbstractDaoTestCase {
+
+ private FileSourceDao dao;
+
+ @Before
+ public void setUpTestData() {
+ dao = new FileSourceDao(getMyBatis());
+ setupData("shared");
+ }
+
+ @Test
+ public void select() throws Exception {
+ FileSourceDto fileSourceDto = dao.select("ab12");
+
+ assertThat(fileSourceDto.getData()).isEqualTo("public class Foo {public Foo(){}}");
+ assertThat(fileSourceDto.getDataHash()).isEqualTo("hash");
+ assertThat(fileSourceDto.getProjectUuid()).isEqualTo("abcd");
+ assertThat(fileSourceDto.getFileUuid()).isEqualTo("ab12");
+ assertThat(fileSourceDto.getCreatedAt()).isEqualTo(DateUtils.parseDateTime("2014-10-29T16:44:02+0100"));
+ assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(DateUtils.parseDateTime("2014-10-30T16:44:02+0100"));
+ }
+
+ @Test
+ public void insert() throws Exception {
+ dao.insert(new FileSourceDto().setProjectUuid("prj").setFileUuid("file").setData("bla bla").setDataHash("hash2")
+ .setCreatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100"))
+ .setUpdatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100")));
+
+ checkTable("insert", "file_sources");
+ }
+
+ @Test
+ public void update() throws Exception {
+ dao.update(new FileSourceDto().setId(101L).setProjectUuid("prj").setFileUuid("file").setData("bla bla").setDataHash("hash2")
+ .setUpdatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100")));
+
+ checkTable("update", "file_sources");
+ }
+
+}
diff --git a/sonar-core/src/test/java/org/sonar/core/source/db/SnapshotSourceDaoTest.java b/sonar-core/src/test/java/org/sonar/core/source/db/SnapshotSourceDaoTest.java
index e30ddd604dd..2d3dd1c13e9 100644
--- a/sonar-core/src/test/java/org/sonar/core/source/db/SnapshotSourceDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/source/db/SnapshotSourceDaoTest.java
@@ -53,7 +53,7 @@ public class SnapshotSourceDaoTest extends AbstractDaoTestCase {
@Test
public void insert() throws Exception {
- dao.insert(new SnapshotSourceDto().setId(102L).setData("bar").setSnapshotId(11L).setUpdatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100")));
+ dao.insert(new SnapshotSourceDto().setData("bar").setSnapshotId(11L).setUpdatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100")));
checkTable("insert", "snapshot_sources");
}
diff --git a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml
new file mode 100644
index 00000000000..ebe11950e50
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml
@@ -0,0 +1,7 @@
+<dataset>
+
+ <file_sources id="101" project_uuid="abcd" file_uuid="ab12" data="public class Foo {public Foo(){}}" data_hash="hash" created_at="2014-10-29 16:44:02.000" updated_at="2014-10-30 16:44:02.000" />
+
+ <file_sources id="102" project_uuid="prj" file_uuid="file" data="bla bla" data_hash="hash2" created_at="2014-10-31 16:44:02.000" updated_at="2014-10-31 16:44:02.000" />
+
+</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml
new file mode 100644
index 00000000000..8b6fc5cd779
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml
@@ -0,0 +1,5 @@
+<dataset>
+
+ <file_sources id="101" project_uuid="abcd" file_uuid="ab12" data="public class Foo {public Foo(){}}" data_hash="hash" created_at="2014-10-29 16:44:02.000" updated_at="2014-10-30 16:44:02.000" />
+
+</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml
new file mode 100644
index 00000000000..dd3b1626363
--- /dev/null
+++ b/sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml
@@ -0,0 +1,5 @@
+<dataset>
+
+ <file_sources id="101" project_uuid="abcd" file_uuid="ab12" data="bla bla" data_hash="hash2" created_at="2014-10-29 16:44:02.000" updated_at="2014-10-31 16:44:02.000" />
+
+</dataset>