Search in sources :

Example 1 with AddActivity

use of org.mifos.security.AddActivity in project head by mifos.

the class BirtReportsUploadActionStrutsTest method testUpgradePathNotRuined.

@Test
public void testUpgradePathNotRuined() throws Exception {
    // TODO Temporary solution to avoid unsuccessful test on some machines
    // Retrieve initial activities information
    List<ActivityEntity> activities = new RolesPermissionsBusinessService().getActivities();
    int newActivityId = activities.get(activities.size() - 1).getId() + 1;
    // Upload a report creating an activity for the report
    FormFile file = new MockFormFile("testFilename.rptdesign");
    BirtReportsUploadActionForm actionForm = new BirtReportsUploadActionForm();
    setRequestPathInfo("/birtReportsUploadAction.do");
    addRequestParameter("method", "upload");
    actionForm.setFile(file);
    actionForm.setReportTitle("exsitTitle");
    actionForm.setReportCategoryId("1");
    actionForm.setIsActive("1");
    setActionForm(actionForm);
    actionPerform();
    Assert.assertEquals(0, getErrorSize());
    Assert.assertNotNull(request.getAttribute("report"));
    // Simulate an future activities upgrade
    AddActivity activity = null;
    try {
        activity = new AddActivity((short) newActivityId, SecurityConstants.ORGANIZATION_MANAGEMENT, "no name");
        activity.upgrade(StaticHibernateUtil.getSessionTL().connection());
    } catch (Exception e) {
        legacyRolesPermissionsDao.delete(request.getAttribute("report"));
        StaticHibernateUtil.flushSession();
        throw e;
    }
    // Undo
    ReportsBO report = (ReportsBO) request.getAttribute("report");
    removeReport(report.getReportId());
}
Also used : RolesPermissionsBusinessService(org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService) ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) MockFormFile(org.mifos.reports.business.MockFormFile) AddActivity(org.mifos.security.AddActivity) BirtReportsUploadActionForm(org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm) MifosRuntimeException(org.mifos.core.MifosRuntimeException) IOException(java.io.IOException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) FormFile(org.apache.struts.upload.FormFile) MockFormFile(org.mifos.reports.business.MockFormFile) ReportsBO(org.mifos.reports.business.ReportsBO) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)1 FormFile (org.apache.struts.upload.FormFile)1 Test (org.junit.Test)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 MockFormFile (org.mifos.reports.business.MockFormFile)1 ReportsBO (org.mifos.reports.business.ReportsBO)1 BirtReportsUploadActionForm (org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)1 AddActivity (org.mifos.security.AddActivity)1 ActivityEntity (org.mifos.security.rolesandpermission.business.ActivityEntity)1 RolesPermissionsBusinessService (org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService)1