From 128fde16c9d1d42e7f2c841daa792f55f5ffe36c Mon Sep 17 00:00:00 2001 From: rkv Date: Thu, 11 Apr 2013 05:01:20 +0000 Subject: [PATCH] Check modification dates in the unit test of a document replacing. --- .../src/test/splat/service/TestPublicationService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Workspace/Siman-Common/src/test/splat/service/TestPublicationService.java b/Workspace/Siman-Common/src/test/splat/service/TestPublicationService.java index ccd8566..98c5620 100644 --- a/Workspace/Siman-Common/src/test/splat/service/TestPublicationService.java +++ b/Workspace/Siman-Common/src/test/splat/service/TestPublicationService.java @@ -21,6 +21,7 @@ import java.text.DecimalFormat; import java.text.ParseException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -716,7 +717,7 @@ public class TestPublicationService extends BaseTest { Assert.assertTrue(ht.find("from File").size() >= 2, "Files were not created in the database."); - Date modifTime = new Date(); + Date modifTime = Calendar.getInstance().getTime(); // TEST CALL: Replace a file in the study step aStudy = _studyService.selectStudy(studyId); @@ -735,18 +736,22 @@ public class TestPublicationService extends BaseTest { ht.flush(); ht.clear(); + // Remove milliseconds because they are lost after saving in the database + modifTime.setTime((modifTime.getTime() / 1000) * 1000); Document doc = ht.get(Document.class, id1); String txt = readFile(doc.getFile().asFile()); Assert.assertTrue(doc.getFile().getName().contains("_document1")); Assert.assertEquals(doc.getFile().getFormat(), format1); Assert.assertTrue(txt.contains("replaced1.ddd")); + Assert.assertEquals(doc.getLastModificationDate(), modifTime); doc = ht.get(Document.class, id2); txt = readFile(doc.getFile().asFile()); Assert.assertTrue(doc.getFile().getName().contains("_sdocument1")); - Assert.assertEquals(doc.getFile().getFormat(), format1); + Assert.assertEquals(doc.getFile().getFormat(), format2); Assert.assertTrue(txt.contains("replaced2.ddd")); + Assert.assertEquals(doc.getLastModificationDate(), modifTime); rollbackNestedTransaction(); LOG.debug(">>>>> END testReplace()"); -- 2.39.2