aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-batch/src')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java13
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/index/SourcePersisterTest.java12
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/file_sources.xml2
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/testPersistDontTouchUnchanged-result.xml2
-rw-r--r--sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/testPersistEmptyFile-result.xml4
5 files changed, 14 insertions, 19 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java
index b0f1199117e..6e42a07c18e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/SourcePersister.java
@@ -56,12 +56,7 @@ import javax.annotation.Nullable;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static com.google.common.base.Charsets.UTF_8;
@@ -154,13 +149,13 @@ public class SourcePersister implements ScanPersister {
if (previous == null) {
FileSourceDto newFileSource = new FileSourceDto().setProjectUuid(projectTree.getRootProject().getUuid()).setFileUuid(fileUuid).setData(newData)
.setDataHash(newDataHash)
- .setCreatedAt(now)
- .setUpdatedAt(now);
+ .setCreatedAt(now.getTime())
+ .setUpdatedAt(now.getTime());
mapper.insert(newFileSource);
session.commit();
} else {
if (!newDataHash.equals(previous.getDataHash())) {
- previous.setData(newData).setDataHash(newDataHash).setUpdatedAt(now);
+ previous.setData(newData).setDataHash(newDataHash).setUpdatedAt(now.getTime());
mapper.update(previous);
session.commit();
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/SourcePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/SourcePersisterTest.java
index 17226a69a4c..8cb3ec22724 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/index/SourcePersisterTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/index/SourcePersisterTest.java
@@ -138,8 +138,8 @@ public class SourcePersisterTest extends AbstractDaoTestCase {
sourcePersister.persist();
FileSourceDto fileSourceDto = new FileSourceDao(getMyBatis()).select("uuidsame");
- assertThat(fileSourceDto.getCreatedAt()).isEqualTo(DateUtils.parseDateTime("2014-10-10T16:44:02+0200"));
- assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(now);
+ assertThat(fileSourceDto.getCreatedAt()).isEqualTo(DateUtils.parseDateTime("2014-10-10T16:44:02+0200").getTime());
+ assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(now.getTime());
assertThat(fileSourceDto.getData()).isEqualTo(
",,,,changed\r\n,,,,content\r\n");
assertThat(fileSourceDto.getDataHash()).isEqualTo("e41cca9c51ff853c748f708f39dfc035");
@@ -176,8 +176,8 @@ public class SourcePersisterTest extends AbstractDaoTestCase {
sourcePersister.persist();
FileSourceDto fileSourceDto = new FileSourceDao(getMyBatis()).select("uuidnew");
- assertThat(fileSourceDto.getCreatedAt()).isEqualTo(now);
- assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(now);
+ assertThat(fileSourceDto.getCreatedAt()).isEqualTo(now.getTime());
+ assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(now.getTime());
assertThat(fileSourceDto.getData()).isEqualTo(
",,,,foo\r\n,,,,bar\r\n,,,,biz\r\n");
assertThat(fileSourceDto.getDataHash()).isEqualTo("0c43ed6418d690ee0ffc3e43e6660967");
@@ -219,8 +219,8 @@ public class SourcePersisterTest extends AbstractDaoTestCase {
sourcePersister.persist();
FileSourceDto fileSourceDto = new FileSourceDao(getMyBatis()).select("uuidnew");
- assertThat(fileSourceDto.getCreatedAt()).isEqualTo(now);
- assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(now);
+ assertThat(fileSourceDto.getCreatedAt()).isEqualTo(now.getTime());
+ assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(now.getTime());
assertThat(fileSourceDto.getData()).isEqualTo(
"123,julien,2014-10-11T16:44:02+0100,\"0,3,a\",foo\r\n"
+ "234,simon,2014-10-12T16:44:02+0100,\"0,1,cd\",bar\r\n"
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/file_sources.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/file_sources.xml
index 972ba28b50f..fae5b462879 100644
--- a/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/file_sources.xml
+++ b/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/file_sources.xml
@@ -1,5 +1,5 @@
<dataset>
- <file_sources id="101" project_uuid="projectUuid" file_uuid="uuidsame" data=",,,,unchanged&#13;&#10;,,,,content&#13;&#10;" data_hash="ee716d4ed9faae16eb9167714442a3bc" created_at="2014-10-10 16:44:02.000" updated_at="2014-10-10 16:44:02.000" />
+ <file_sources id="101" project_uuid="projectUuid" file_uuid="uuidsame" data=",,,,unchanged&#13;&#10;,,,,content&#13;&#10;" data_hash="ee716d4ed9faae16eb9167714442a3bc" created_at="1412952242000" updated_at="1412952242000" />
</dataset>
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/testPersistDontTouchUnchanged-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/testPersistDontTouchUnchanged-result.xml
index 972ba28b50f..fae5b462879 100644
--- a/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/testPersistDontTouchUnchanged-result.xml
+++ b/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/testPersistDontTouchUnchanged-result.xml
@@ -1,5 +1,5 @@
<dataset>
- <file_sources id="101" project_uuid="projectUuid" file_uuid="uuidsame" data=",,,,unchanged&#13;&#10;,,,,content&#13;&#10;" data_hash="ee716d4ed9faae16eb9167714442a3bc" created_at="2014-10-10 16:44:02.000" updated_at="2014-10-10 16:44:02.000" />
+ <file_sources id="101" project_uuid="projectUuid" file_uuid="uuidsame" data=",,,,unchanged&#13;&#10;,,,,content&#13;&#10;" data_hash="ee716d4ed9faae16eb9167714442a3bc" created_at="1412952242000" updated_at="1412952242000" />
</dataset>
diff --git a/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/testPersistEmptyFile-result.xml b/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/testPersistEmptyFile-result.xml
index 77bf6e4d0c7..ac3c16563af 100644
--- a/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/testPersistEmptyFile-result.xml
+++ b/sonar-batch/src/test/resources/org/sonar/batch/index/SourcePersisterTest/testPersistEmptyFile-result.xml
@@ -1,6 +1,6 @@
<dataset>
- <file_sources id="101" project_uuid="projectUuid" file_uuid="uuidsame" data=",,,,unchanged&#13;&#10;,,,,content&#13;&#10;" data_hash="ee716d4ed9faae16eb9167714442a3bc" created_at="2014-10-10 16:44:02.000" updated_at="2014-10-10 16:44:02.000" />
- <file_sources id="102" project_uuid="projectUuid" file_uuid="uuidempty" data="[null]" data_hash="0" created_at="2014-10-29 16:44:02.000" updated_at="2014-10-29 16:44:02.000" />
+ <file_sources id="101" project_uuid="projectUuid" file_uuid="uuidsame" data=",,,,unchanged&#13;&#10;,,,,content&#13;&#10;" data_hash="ee716d4ed9faae16eb9167714442a3bc" created_at="1412952242000" updated_at="1412952242000" />
+ <file_sources id="102" project_uuid="projectUuid" file_uuid="uuidempty" data="[null]" data_hash="0" created_at="1414597442000" updated_at="1414597442000" />
</dataset>