I've tweaked the tests a bit to handle daylight savings.

This commit is contained in:
roxana
2016-10-24 15:30:37 +03:00
parent 4abeb19938
commit cb3357080d
2 changed files with 14 additions and 9 deletions

View File

@@ -280,7 +280,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
{ {
DispositionSchedule originDispositionSchedule = getOriginDispositionSchedule(nodeRef); DispositionSchedule originDispositionSchedule = getOriginDispositionSchedule(nodeRef);
// if the initial disposition schedule of the record is folder based // if the initial disposition schedule of the record is folder based
if (originDispositionSchedule!= null && if (originDispositionSchedule == null ||
isNotTrue(originDispositionSchedule.isRecordLevelDisposition())) isNotTrue(originDispositionSchedule.isRecordLevelDisposition()))
{ {
return null; return null;

View File

@@ -3,11 +3,10 @@ package org.alfresco.module.org_alfresco_module_rm.test.integration.disposition;
import static org.alfresco.module.org_alfresco_module_rm.test.util.bdt.BehaviourTest.test; import static org.alfresco.module.org_alfresco_module_rm.test.util.bdt.BehaviourTest.test;
import java.io.Serializable; import java.io.Serializable;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import com.google.common.collect.ImmutableMap;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction; import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction;
@@ -21,6 +20,8 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.springframework.extensions.webscripts.GUID; import org.springframework.extensions.webscripts.GUID;
import com.google.common.collect.ImmutableMap;
public class MultipleSchedulesTest extends BaseRMTestCase public class MultipleSchedulesTest extends BaseRMTestCase
{ {
/** A unique prefix for the constants in this test. */ /** A unique prefix for the constants in this test. */
@@ -118,6 +119,7 @@ public class MultipleSchedulesTest extends BaseRMTestCase
*/ */
public void testLinkedToLongerSchedule() public void testLinkedToLongerSchedule()
{ {
Calendar calendar = Calendar.getInstance();
test() test()
.given(() -> { .given(() -> {
setUpFilePlan(); setUpFilePlan();
@@ -130,11 +132,12 @@ public class MultipleSchedulesTest extends BaseRMTestCase
dispositionService.cutoffDisposableItem(record); dispositionService.cutoffDisposableItem(record);
// Ensure the update has been applied to the record. // Ensure the update has been applied to the record.
internalDispositionService.updateNextDispositionAction(record); internalDispositionService.updateNextDispositionAction(record);
calendar.setTime((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE));
calendar.add(Calendar.WEEK_OF_YEAR, 1);
}) })
.then() .then()
.expect(7 * 24 * 60 * 60 * 1000L) .expect(calendar.getTime())
.from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate().getTime() .from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
- ((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE)).getTime())
.because("Record should follow largest rentention schedule period, which is one week."); .because("Record should follow largest rentention schedule period, which is one week.");
} }
@@ -149,6 +152,7 @@ public class MultipleSchedulesTest extends BaseRMTestCase
*/ */
public void testLinkedToShorterSchedule() public void testLinkedToShorterSchedule()
{ {
Calendar calendar = Calendar.getInstance();
test() test()
.given(() -> { .given(() -> {
setUpFilePlan(); setUpFilePlan();
@@ -161,11 +165,12 @@ public class MultipleSchedulesTest extends BaseRMTestCase
dispositionService.cutoffDisposableItem(record); dispositionService.cutoffDisposableItem(record);
// Ensure the update has been applied to the record. // Ensure the update has been applied to the record.
internalDispositionService.updateNextDispositionAction(record); internalDispositionService.updateNextDispositionAction(record);
calendar.setTime((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE));
calendar.add(Calendar.WEEK_OF_YEAR, 1);
}) })
.then() .then()
.expect(7 * 24 * 60 * 60 * 1000L) .expect(calendar.getTime())
.from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate().getTime() .from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
- ((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE)).getTime())
.because("Record should follow largest rentention schedule period, which is one week."); .because("Record should follow largest rentention schedule period, which is one week.");
} }
} }