RM-263: Issue when we set disposition schedule based on Publication Date

* refactored the way disposition properties work
  * now additional disposition date properties are sprung in and registered in the disposition service
  * each disposition property bean looks after updating the disposition asof date when the date property changes
  * defaults to null date if can not be calculated
  * unit test for new method and this issue
  * also updated build scripts to successfully run unit test .. will gradually add in other unit tests as their reliability is improved



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@36222 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2012-05-09 23:35:37 +00:00
parent 0e5c86e86c
commit 3498ea59a1
13 changed files with 708 additions and 120 deletions

View File

@@ -22,6 +22,7 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -32,6 +33,7 @@ import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty;
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
import org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor;
import org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutorRegistry;
@@ -54,6 +56,28 @@ public class DispositionServiceImplTest extends BaseRMTestCase
return true;
}
public void testGetDispositionProperties() throws Exception
{
doTestInTransaction(new Test<Void>()
{
public Void run()
{
Collection<DispositionProperty> properties = dispositionService.getDispositionProperties();
assertNotNull(properties);
assertEquals(4, properties.size());
for (DispositionProperty property : properties)
{
assertNotNull(property.getQName());
assertNotNull(property.getPropertyDefinition());
}
return null;
}
});
}
/**
* @see DispositionService#getDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef)
*/
@@ -797,5 +821,81 @@ public class DispositionServiceImplTest extends BaseRMTestCase
// TODO DispositionAction getLastCompletedDispostionAction(NodeRef nodeRef);
// TODO List<QName> getDispositionPeriodProperties();
/* === Issues === */
private NodeRef testRM263RecordCategory;
private DispositionSchedule testRM263DispositionSchedule;
private NodeRef testRM263Record;
/**
* https://issues.alfresco.com/jira/browse/RM-263
*/
public void testRM_263() throws Exception
{
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
testRM263RecordCategory = rmService.createRecordCategory(rmContainer, "rm263");
testRM263DispositionSchedule = utils.createBasicDispositionSchedule(
testRM263RecordCategory,
"test",
"test",
true,
false);
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, "cutoff");
adParams.put(PROP_DISPOSITION_DESCRIPTION, "test");
adParams.put(PROP_DISPOSITION_PERIOD, "week|1");
adParams.put(PROP_DISPOSITION_PERIOD_PROPERTY, PROP_PUBLICATION_DATE.toString());
dispositionService.addDispositionActionDefinition(testRM263DispositionSchedule, adParams);
NodeRef recordFolder = rmService.createRecordFolder(testRM263RecordCategory, "testRM263RecordFolder");
testRM263Record = utils.createRecord(recordFolder, "testRM263Record", "testRM263Record");
return null;
}
});
doTestInTransaction(new Test<Void>()
{
private final QName PROP_SEARCH_ASOF = QName.createQName(RM_URI, "recordSearchDispositionActionAsOf");
@Override
public Void run() throws Exception
{
Date pubDate = (Date)nodeService.getProperty(testRM263Record, PROP_PUBLICATION_DATE);
assertNull(pubDate);
Date asOfDate = (Date)nodeService.getProperty(testRM263Record, PROP_SEARCH_ASOF);
assertNull(asOfDate);
DispositionAction da = dispositionService.getNextDispositionAction(testRM263Record);
assertNotNull(da);
assertNull(da.getAsOfDate());
//rma:recordSearchDispositionActionAsOf"
nodeService.setProperty(testRM263Record, PROP_PUBLICATION_DATE, new Date());
return null;
}
@Override
public void test(Void result) throws Exception
{
Date pubDate = (Date)nodeService.getProperty(testRM263Record, PROP_PUBLICATION_DATE);
assertNotNull(pubDate);
Date asOfDate = (Date)nodeService.getProperty(testRM263Record, PROP_SEARCH_ASOF);
assertNotNull(asOfDate);
DispositionAction da = dispositionService.getNextDispositionAction(testRM263Record);
assertNotNull(da);
assertNotNull(da.getAsOfDate());
}
});
}
}