mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-1211: Generate hold report
* FileHoldReport capability added (and patched) * hold report type added to report model * hold template added, bootstraped (and patched) * UI action to file hold report added and sensitive to capability * report actions refactored into a single, general purpose, file report action (can be exposed as rule in future) * refactoring and extending of report generators (including declarative report generator) * unit test for file report action * integration test for hold report generation * added Sprin custom property editor registrar and registered QName property editor, this allows short name string forms of QNames to be specified and converted to QName from bean definitions (perhaps something useful for core) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@68235 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,6 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.test.integration;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.dod.DoD5015TestSuite;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.event.EventTestSuite;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.issue.IssueTestSuite;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.integration.report.ReportTestSuite;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
@@ -37,7 +38,8 @@ import org.junit.runners.Suite.SuiteClasses;
|
||||
{
|
||||
DoD5015TestSuite.class,
|
||||
IssueTestSuite.class,
|
||||
EventTestSuite.class
|
||||
EventTestSuite.class,
|
||||
ReportTestSuite.class
|
||||
})
|
||||
public class IntegrationTestSuite
|
||||
{
|
||||
|
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.report;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.Report;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.ReportModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.GUID;
|
||||
|
||||
/**
|
||||
* Hold report integration tests.
|
||||
* <p>
|
||||
* Relates to:
|
||||
* - https://issues.alfresco.com/jira/browse/RM-1211
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
public class HoldReportTest extends BaseRMTestCase implements ReportModel
|
||||
{
|
||||
@Override
|
||||
protected boolean isRecordTest()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* ensure that 'rmr:holdReport' is in the list of those available
|
||||
*/
|
||||
public void testHoldReportTypeAvailable()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private Set<QName> reportTypes;
|
||||
|
||||
public void when()
|
||||
{
|
||||
reportTypes = reportService.getReportTypes();
|
||||
}
|
||||
|
||||
public void then()
|
||||
{
|
||||
assertNotNull(reportTypes);
|
||||
assertTrue(reportTypes.contains(TYPE_HOLD_REPORT));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* given that the reported upon node is not a hold, ensure that an error is raised when
|
||||
* the report is generated.
|
||||
*/
|
||||
public void testReportedUponNodeIsNotAHold()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest(AlfrescoRuntimeException.class)
|
||||
{
|
||||
private NodeRef reportedUponNodeRef;
|
||||
|
||||
public void given()
|
||||
{
|
||||
reportedUponNodeRef = recordFolderService.createRecordFolder(rmContainer, GUID.generate());
|
||||
}
|
||||
|
||||
public void when()
|
||||
{
|
||||
reportService.generateReport(TYPE_HOLD_REPORT, reportedUponNodeRef);
|
||||
}
|
||||
|
||||
public void after()
|
||||
{
|
||||
// remove created folder
|
||||
nodeService.deleteNode(reportedUponNodeRef);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a hold that contains items, ensure the report is generated as expected
|
||||
*/
|
||||
public void testGenerateHoldReport()
|
||||
{
|
||||
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||
{
|
||||
private static final String HOLD_NAME = "holdName";
|
||||
private static final String HOLD_REASON = "holdReason";
|
||||
private static final String HOLD_DESCRIPTION = "holdDescription";
|
||||
private static final String FOLDER1_NAME = "folder1Name";
|
||||
|
||||
private NodeRef hold;
|
||||
private NodeRef folder1;
|
||||
private Report report;
|
||||
|
||||
public void given()
|
||||
{
|
||||
// crate a hold
|
||||
hold = holdService.createHold(filePlan, HOLD_NAME, HOLD_REASON, HOLD_DESCRIPTION);
|
||||
|
||||
// add some items to the hold
|
||||
folder1 = recordFolderService.createRecordFolder(rmContainer, FOLDER1_NAME);
|
||||
holdService.addToHold(hold, folder1);
|
||||
holdService.addToHold(hold, recordOne);
|
||||
}
|
||||
|
||||
public void when()
|
||||
{
|
||||
report = reportService.generateReport(TYPE_HOLD_REPORT, hold, MimetypeMap.MIMETYPE_HTML);
|
||||
}
|
||||
|
||||
public void then()
|
||||
{
|
||||
assertNotNull(report);
|
||||
assertEquals(TYPE_HOLD_REPORT, report.getReportType());
|
||||
assertTrue(report.getReportProperties().isEmpty());
|
||||
|
||||
// check the name has been generated correctly
|
||||
assertNotNull(report.getReportName());
|
||||
assertTrue(report.getReportName().contains("Hold Report"));
|
||||
assertTrue(report.getReportName().contains(HOLD_NAME));
|
||||
assertTrue(report.getReportName().contains(".html"));
|
||||
|
||||
// check the content reader
|
||||
ContentReader reader = report.getReportContent();
|
||||
assertNotNull(reader);
|
||||
assertEquals(MimetypeMap.MIMETYPE_HTML, reader.getMimetype());
|
||||
|
||||
// check the content
|
||||
String reportContent = reader.getContentString();
|
||||
assertNotNull(reportContent);
|
||||
assertTrue(reportContent.contains(HOLD_NAME));
|
||||
assertTrue(reportContent.contains(HOLD_REASON));
|
||||
assertTrue(reportContent.contains(HOLD_DESCRIPTION));
|
||||
assertTrue(reportContent.contains(FOLDER1_NAME));
|
||||
assertTrue(reportContent.contains("one"));
|
||||
}
|
||||
|
||||
public void after()
|
||||
{
|
||||
holdService.deleteHold(hold);
|
||||
nodeService.deleteNode(folder1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.integration.report;
|
||||
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
|
||||
/**
|
||||
* Report integration test suite
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses(
|
||||
{
|
||||
HoldReportTest.class
|
||||
})
|
||||
public class ReportTestSuite
|
||||
{
|
||||
}
|
@@ -19,7 +19,6 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.test.service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -28,12 +27,10 @@ import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction;
|
||||
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.FileReportAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.Report;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.ReportModel;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.action.DestructionReportAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.action.TransferNode;
|
||||
import org.alfresco.module.org_alfresco_module_rm.report.action.TransferReportAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
@@ -84,7 +81,7 @@ public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel
|
||||
System.out.println(destructionReport.getReportContent().getContentString());
|
||||
|
||||
// Transfer Report
|
||||
Report transferReport = generateTransfertReport();
|
||||
Report transferReport = reportService.generateReport(TYPE_TRANSFER_REPORT, getTransferObject(), MimetypeMap.MIMETYPE_HTML);
|
||||
System.out.println(transferReport.getReportName());
|
||||
System.out.println(transferReport.getReportContent().getContentString());
|
||||
|
||||
@@ -128,22 +125,7 @@ public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel
|
||||
{
|
||||
return reportService.generateReport(TYPE_DESTRUCTION_REPORT, rmFolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to generate a transfer report
|
||||
*
|
||||
* @return Transfer report
|
||||
*/
|
||||
private Report generateTransfertReport()
|
||||
{
|
||||
Map<String, Serializable> properties = new HashMap<String, Serializable>(2);
|
||||
ArrayList<TransferNode> transferNodes = new ArrayList<TransferNode>(1);
|
||||
String dispositionAuthority = StringUtils.EMPTY;
|
||||
properties.put("transferNodes", transferNodes);
|
||||
properties.put("dispositionAuthority", dispositionAuthority);
|
||||
return reportService.generateReport(TYPE_TRANSFER_REPORT, getTransferObject(), MimetypeMap.MIMETYPE_HTML, properties);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to file a destruction report
|
||||
*
|
||||
@@ -162,7 +144,7 @@ public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel
|
||||
*/
|
||||
private NodeRef fileTransferReport()
|
||||
{
|
||||
Report transferReport = generateTransfertReport();
|
||||
Report transferReport = reportService.generateReport(TYPE_TRANSFER_REPORT, getTransferObject(), MimetypeMap.MIMETYPE_HTML);
|
||||
return reportService.fileReport(filePlan, transferReport);
|
||||
}
|
||||
|
||||
@@ -181,9 +163,9 @@ public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel
|
||||
rmActionService.executeRecordsManagementAction(rmFolder, DestroyAction.NAME);
|
||||
|
||||
Map<String, Serializable> fileReportParams = new HashMap<String, Serializable>(2);
|
||||
fileReportParams.put(DestructionReportAction.REPORT_TYPE, "rmr:destructionReport");
|
||||
fileReportParams.put(DestructionReportAction.DESTINATION, filePlan.toString());
|
||||
rmActionService.executeRecordsManagementAction(rmFolder, DestructionReportAction.NAME, fileReportParams);
|
||||
fileReportParams.put(FileReportAction.REPORT_TYPE, "rmr:destructionReport");
|
||||
fileReportParams.put(FileReportAction.DESTINATION, filePlan.toString());
|
||||
rmActionService.executeRecordsManagementAction(rmFolder, FileReportAction.NAME, fileReportParams);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -198,9 +180,9 @@ public class ReportServiceImplTest extends BaseRMTestCase implements ReportModel
|
||||
{
|
||||
// Create transfer report for the transfer object
|
||||
Map<String, Serializable> params = new HashMap<String, Serializable>(2);
|
||||
params.put(TransferReportAction.REPORT_TYPE, "rmr:transferReport");
|
||||
params.put(TransferReportAction.DESTINATION, filePlan.toString());
|
||||
RecordsManagementActionResult transferReportAction = rmActionService.executeRecordsManagementAction(getTransferObject(), TransferReportAction.NAME, params);
|
||||
params.put(FileReportAction.REPORT_TYPE, "rmr:transferReport");
|
||||
params.put(FileReportAction.DESTINATION, filePlan.toString());
|
||||
RecordsManagementActionResult transferReportAction = rmActionService.executeRecordsManagementAction(getTransferObject(), FileReportAction.NAME, params);
|
||||
// Check transfer report result
|
||||
String transferReportName = (String) transferReportAction.getValue();
|
||||
assertFalse(StringUtils.isBlank(transferReportName));
|
||||
|
@@ -810,49 +810,99 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute behaviour driven test.
|
||||
*
|
||||
* @param test
|
||||
*/
|
||||
protected void doBehaviourDrivenTest(BehaviourDrivenTest test)
|
||||
{
|
||||
test.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Behaviour driven test.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 2.2
|
||||
*/
|
||||
protected abstract class BehaviourDrivenTest
|
||||
{
|
||||
public abstract void given();
|
||||
protected Class<?> expectedException;
|
||||
|
||||
public abstract void when();
|
||||
public BehaviourDrivenTest()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void then();
|
||||
public BehaviourDrivenTest(Class<?> expectedException)
|
||||
{
|
||||
this.expectedException = expectedException;
|
||||
}
|
||||
|
||||
public void given() { /** empty implementation */ }
|
||||
|
||||
public void when() { /** empty implementation */ }
|
||||
|
||||
public void then() { /** empty implementation */ }
|
||||
|
||||
public void after() { /** empty implementation */ }
|
||||
|
||||
public void run()
|
||||
{
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
@Override
|
||||
public void runImpl() throws Exception
|
||||
{
|
||||
given();
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new VoidTest()
|
||||
try
|
||||
{
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
@Override
|
||||
public void runImpl() throws Exception
|
||||
{
|
||||
given();
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void runImpl() throws Exception
|
||||
if (expectedException == null)
|
||||
{
|
||||
when();
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
@Override
|
||||
public void runImpl() throws Exception
|
||||
{
|
||||
when();
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
@Override
|
||||
public void runImpl() throws Exception
|
||||
{
|
||||
then();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void runImpl() throws Exception
|
||||
else
|
||||
{
|
||||
then();
|
||||
doTestInTransaction(new FailureTest(expectedException)
|
||||
{
|
||||
@Override
|
||||
public void run() throws Exception
|
||||
{
|
||||
when();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
finally
|
||||
{
|
||||
doTestInTransaction(new VoidTest()
|
||||
{
|
||||
@Override
|
||||
public void runImpl() throws Exception
|
||||
{
|
||||
after();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user