aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-11-03 11:07:31 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2014-11-03 11:55:30 +0100
commit89eede7717dd056d314a214afb64a17be98fbc0e (patch)
tree3c9ed05a9749ea9a9557a2bb9a88b988f6ab26b1 /sonar-core/src
parent19a6905ce6c877f1497b2ce47b7aeb478591b036 (diff)
downloadsonarqube-89eede7717dd056d314a214afb64a17be98fbc0e.tar.gz
sonarqube-89eede7717dd056d314a214afb64a17be98fbc0e.zip
SONAR-5815 Store last update time on source data
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDto.java12
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/source/db/SnapshotSourceMapper.xml3
-rw-r--r--sonar-core/src/test/java/org/sonar/core/source/db/SnapshotSourceDaoTest.java3
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/insert-result.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/shared.xml2
5 files changed, 19 insertions, 5 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDto.java b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDto.java
index 012b0803843..2c99551f63a 100644
--- a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDto.java
@@ -19,10 +19,13 @@
*/
package org.sonar.core.source.db;
+import java.util.Date;
+
public class SnapshotSourceDto {
private Long id;
private Long snapshotId;
private String data;
+ private Date updatedAt;
public Long getId() {
return id;
@@ -50,4 +53,13 @@ public class SnapshotSourceDto {
this.data = data;
return this;
}
+
+ public Date getUpdatedAt() {
+ return updatedAt;
+ }
+
+ public SnapshotSourceDto setUpdatedAt(Date updatedAt) {
+ this.updatedAt = updatedAt;
+ return this;
+ }
}
diff --git a/sonar-core/src/main/resources/org/sonar/core/source/db/SnapshotSourceMapper.xml b/sonar-core/src/main/resources/org/sonar/core/source/db/SnapshotSourceMapper.xml
index 85d08e05d9f..a6c30aa35a6 100644
--- a/sonar-core/src/main/resources/org/sonar/core/source/db/SnapshotSourceMapper.xml
+++ b/sonar-core/src/main/resources/org/sonar/core/source/db/SnapshotSourceMapper.xml
@@ -19,7 +19,8 @@
</select>
<insert id="insert" parameterType="org.sonar.core.source.db.SnapshotSourceDto" useGeneratedKeys="false">
- insert into snapshot_sources (snapshot_id, data) values (#{snapshotId}, #{data})
+ insert into snapshot_sources (snapshot_id, data, updated_at)
+ values (#{snapshotId}, #{data}, #{updatedAt})
</insert>
</mapper>
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 743edcb679e..e30ddd604dd 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
@@ -22,6 +22,7 @@ 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;
@@ -52,7 +53,7 @@ public class SnapshotSourceDaoTest extends AbstractDaoTestCase {
@Test
public void insert() throws Exception {
- dao.insert(new SnapshotSourceDto().setId(102L).setData("bar").setSnapshotId(11L));
+ dao.insert(new SnapshotSourceDto().setId(102L).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/SnapshotSourceDaoTest/insert-result.xml b/sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/insert-result.xml
index 13f1e235793..75c9e826be3 100644
--- a/sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/insert-result.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/insert-result.xml
@@ -5,8 +5,8 @@
<snapshots id="10" project_id="1" islast="[false]"/>
<snapshots id="11" project_id="1" islast="[true]"/>
- <snapshot_sources id="101" snapshot_id="11" data="public class Foo {public Foo(){}}" updated_at="[null]"/>
+ <snapshot_sources id="101" snapshot_id="11" data="public class Foo {public Foo(){}}" updated_at="2014-10-30 16:44:02.000"/>
- <snapshot_sources id="102" snapshot_id="11" data="bar" updated_at="[null]"/>
+ <snapshot_sources id="102" snapshot_id="11" data="bar" updated_at="2014-10-31 16:44:02.000"/>
</dataset>
diff --git a/sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/shared.xml b/sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/shared.xml
index decc3cc7748..850127d7cfb 100644
--- a/sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/shared.xml
+++ b/sonar-core/src/test/resources/org/sonar/core/source/db/SnapshotSourceDaoTest/shared.xml
@@ -5,6 +5,6 @@
<snapshots id="10" project_id="1" islast="[false]" />
<snapshots id="11" project_id="1" islast="[true]" />
- <snapshot_sources id="101" snapshot_id="11" data="public class Foo {public Foo(){}}" />
+ <snapshot_sources id="101" snapshot_id="11" data="public class Foo {public Foo(){}}" updated_at="2014-10-30 16:44:02.000" />
</dataset>