aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core/src
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-11-24 17:12:25 +0100
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-11-24 18:16:12 +0100
commitf7598fbe9b8df747b525e9642fba3e7a3ae9da77 (patch)
tree5c5ad441b037a5b55f892c55ed496016c3f452fd /sonar-core/src
parente880a603c9b0931ca62de16810560355af3e0024 (diff)
downloadsonarqube-f7598fbe9b8df747b525e9642fba3e7a3ae9da77.tar.gz
sonarqube-f7598fbe9b8df747b525e9642fba3e7a3ae9da77.zip
SONAR-5826 Use (big) integer column instead of DB timestamp for file_sources
Diffstat (limited to 'sonar-core/src')
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/FileSourceDto.java13
-rw-r--r--sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl4
-rw-r--r--sonar-core/src/test/java/org/sonar/core/source/db/FileSourceDaoTest.java12
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/insert-result.xml4
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/shared.xml2
-rw-r--r--sonar-core/src/test/resources/org/sonar/core/source/db/FileSourceDaoTest/update-result.xml2
6 files changed, 19 insertions, 18 deletions
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
index 3659ff20569..e992ee4a648 100644
--- 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
@@ -21,14 +21,13 @@ package org.sonar.core.source.db;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import java.util.Date;
public class FileSourceDto {
private Long id;
private String projectUuid;
private String fileUuid;
- private Date createdAt;
- private Date updatedAt;
+ private long createdAt;
+ private long updatedAt;
private String data;
private String dataHash;
@@ -78,20 +77,20 @@ public class FileSourceDto {
return this;
}
- public Date getCreatedAt() {
+ public long getCreatedAt() {
return createdAt;
}
- public FileSourceDto setCreatedAt(Date createdAt) {
+ public FileSourceDto setCreatedAt(long createdAt) {
this.createdAt = createdAt;
return this;
}
- public Date getUpdatedAt() {
+ public long getUpdatedAt() {
return updatedAt;
}
- public FileSourceDto setUpdatedAt(Date updatedAt) {
+ public FileSourceDto setUpdatedAt(long updatedAt) {
this.updatedAt = updatedAt;
return this;
}
diff --git a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
index 5842e9f4400..7de7f8d46c2 100644
--- a/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
+++ b/sonar-core/src/main/resources/org/sonar/core/persistence/schema-h2.ddl
@@ -572,8 +572,8 @@ CREATE TABLE "FILE_SOURCES" (
"FILE_UUID" VARCHAR(50) NOT NULL,
"DATA" CLOB(2147483647),
"DATA_HASH" VARCHAR(50) NOT NULL,
- "CREATED_AT" TIMESTAMP NOT NULL,
- "UPDATED_AT" TIMESTAMP NOT NULL
+ "CREATED_AT" BIGINT NOT NULL,
+ "UPDATED_AT" BIGINT NOT NULL
);
-- ----------------------------------------------
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
index 04c3ec923b5..ddd45cedfa5 100644
--- 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
@@ -25,6 +25,8 @@ import org.junit.Test;
import org.sonar.api.utils.DateUtils;
import org.sonar.core.persistence.AbstractDaoTestCase;
+import java.util.Date;
+
import static org.fest.assertions.Assertions.assertThat;
public class FileSourceDaoTest extends AbstractDaoTestCase {
@@ -45,15 +47,15 @@ public class FileSourceDaoTest extends AbstractDaoTestCase {
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"));
+ assertThat(new Date(fileSourceDto.getCreatedAt())).isEqualTo(DateUtils.parseDateTime("2014-10-29T16:44:02+0100"));
+ assertThat(new Date(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")));
+ .setCreatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100").getTime())
+ .setUpdatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100").getTime()));
checkTable("insert", "file_sources");
}
@@ -61,7 +63,7 @@ public class FileSourceDaoTest extends AbstractDaoTestCase {
@Test
public void update() throws Exception {
dao.update(new FileSourceDto().setId(101L).setProjectUuid("prj").setFileUuid("file").setData("updated data").setDataHash("hash2")
- .setUpdatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100")));
+ .setUpdatedAt(DateUtils.parseDateTime("2014-10-31T16:44:02+0100").getTime()));
checkTable("update", "file_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
index caa220868f4..c5d483b7e55 100644
--- 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
@@ -2,11 +2,11 @@
<file_sources id="101" project_uuid="abcd" file_uuid="ab12"
data="aef12a,alice,2014-04-25T12:34:56+0100,,class Foo" data_hash="hash"
- created_at="2014-10-29 16:44:02.000" updated_at="2014-10-30 16:44:02.000" />
+ created_at="1414597442000" updated_at="1414683842000" />
<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" />
+ created_at="1414770242000" updated_at="1414770242000" />
</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
index 080676c67f2..fb3c258ddc0 100644
--- 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
@@ -2,6 +2,6 @@
<file_sources id="101" project_uuid="abcd" file_uuid="ab12"
data="aef12a,alice,2014-04-25T12:34:56+0100,,class Foo" data_hash="hash"
- created_at="2014-10-29 16:44:02.000" updated_at="2014-10-30 16:44:02.000" />
+ created_at="1414597442000" updated_at="1414683842000" />
</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
index aee5ffcf405..465b2e52cb8 100644
--- 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
@@ -2,7 +2,7 @@
<file_sources id="101" project_uuid="abcd" file_uuid="ab12"
data="updated data" data_hash="hash2"
- created_at="2014-10-29 16:44:02.000" updated_at="2014-10-31 16:44:02.000" />
+ created_at="1414597442000" updated_at="1414770242000" />
</dataset>