Search in sources :

Example 11 with ReportsBO

use of org.mifos.reports.business.ReportsBO in project head by mifos.

the class AddReportIntegrationTest method testStartFromStandardStore.

@Test
public void testStartFromStandardStore() throws Exception {
    short newId = 17032;
    AddReport upgrade = new AddReport(ReportsCategoryBO.ANALYSIS, "Detailed Aging of Portfolio at Risk", "DetailedAgingPortfolioAtRisk.rptdesign");
    upgrade.upgrade(session.connection());
    ReportsBO fetched = (ReportsBO) session.get(ReportsBO.class, newId);
    Assert.assertEquals(newId, (int) fetched.getReportId());
    Assert.assertEquals(ReportsBO.ACTIVE, fetched.getIsActive());
    Assert.assertEquals(null, fetched.getActivityId());
    Assert.assertEquals("Detailed Aging of Portfolio at Risk", fetched.getReportName());
    Assert.assertEquals("aging_portfolio_at_risk", fetched.getReportIdentifier());
    Assert.assertEquals(ReportsCategoryBO.ANALYSIS, (int) fetched.getReportsCategoryBO().getReportCategoryId());
    ReportsJasperMap map = fetched.getReportsJasperMap();
    Assert.assertEquals("DetailedAgingPortfolioAtRisk.rptdesign", map.getReportJasper());
}
Also used : ReportsJasperMap(org.mifos.reports.business.ReportsJasperMap) ReportsBO(org.mifos.reports.business.ReportsBO) Test(org.junit.Test)

Example 12 with ReportsBO

use of org.mifos.reports.business.ReportsBO in project head by mifos.

the class AddReportUpgradeIntegrationTest method testShouldUpgrade.

@Test
public void testShouldUpgrade() throws Exception {
    AddReport addReport = createReport();
    addReport.upgrade(connection);
    ReportsBO report = new ReportsPersistence().getReport(ReportsCategoryBO.ANALYSIS);
    Assert.assertNotNull(report.getActivityId());
    Assert.assertTrue(report.getIsActive() == (short) 1);
}
Also used : ReportsBO(org.mifos.reports.business.ReportsBO) Test(org.junit.Test)

Example 13 with ReportsBO

use of org.mifos.reports.business.ReportsBO in project head by mifos.

the class ReportsPersistenceIntegrationTest method testGetAllReportsForACategory.

@Test
public void testGetAllReportsForACategory() {
    List<ReportsCategoryBO> listOfReportCategories = reportsPersistence.getAllReportCategories();
    Set<ReportsBO> reportsSet = listOfReportCategories.get(0).getReportsSet();
    for (Object element : reportsSet) {
        ReportsBO reports = (ReportsBO) element;
        if (reports.getReportId().equals("1")) {
            Assert.assertEquals("Client Detail", reports.getReportName());
        } else if (reports.getReportId().equals("2")) {
            Assert.assertEquals("Performance", reports.getReportName());
        } else if (reports.getReportId().equals("3")) {
            Assert.assertEquals("Kendra", reports.getReportName());
        } else if (reports.getReportId().equals("4")) {
            Assert.assertEquals("Loan Product Detail", reports.getReportName());
        } else if (reports.getReportId().equals("5")) {
            Assert.assertEquals("Status", reports.getReportName());
        } else if (reports.getReportId().equals("6")) {
            Assert.assertEquals("Analysis", reports.getReportName());
        } else if (reports.getReportId().equals("7")) {
            Assert.assertEquals("Miscellaneous", reports.getReportName());
        } else {
        /*
                 * We always get here, because the above code is comparing a
                 * Short to a String. TODO: how do we really want to test this,
                 * anyway?
                 */
        // Assert.fail("unexpected report " + reports.getReportId());
        }
    }
}
Also used : ReportsCategoryBO(org.mifos.reports.business.ReportsCategoryBO) ReportsBO(org.mifos.reports.business.ReportsBO) Test(org.junit.Test)

Example 14 with ReportsBO

use of org.mifos.reports.business.ReportsBO 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)

Example 15 with ReportsBO

use of org.mifos.reports.business.ReportsBO in project head by mifos.

the class BirtReportsUploadActionStrutsTest method removeReport.

private void removeReport(Short reportId) throws PersistenceException {
    ReportsPersistence reportPersistence = new ReportsPersistence();
    reportPersistence.getSession().clear();
    ReportsBO report = reportPersistence.getPersistentObject(ReportsBO.class, reportId);
    ActivityEntity activityEntity = legacyRolesPermissionsDao.getPersistentObject(ActivityEntity.class, report.getActivityId());
    reportPersistence.delete(report);
    LookUpValueEntity anLookUp = activityEntity.getActivityNameLookupValues();
    legacyRolesPermissionsDao.delete(activityEntity);
    legacyRolesPermissionsDao.delete(anLookUp);
    StaticHibernateUtil.flushSession();
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) ReportsPersistence(org.mifos.reports.persistence.ReportsPersistence) ReportsBO(org.mifos.reports.business.ReportsBO) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Aggregations

ReportsBO (org.mifos.reports.business.ReportsBO)21 ReportsPersistence (org.mifos.reports.persistence.ReportsPersistence)10 Test (org.junit.Test)9 BirtReportsUploadActionForm (org.mifos.reports.struts.actionforms.BirtReportsUploadActionForm)7 ReportsCategoryBO (org.mifos.reports.business.ReportsCategoryBO)6 ReportsJasperMap (org.mifos.reports.business.ReportsJasperMap)5 FormFile (org.apache.struts.upload.FormFile)3 MockFormFile (org.mifos.reports.business.MockFormFile)3 ActivityEntity (org.mifos.security.rolesandpermission.business.ActivityEntity)3 IOException (java.io.IOException)2 ActionErrors (org.apache.struts.action.ActionErrors)2 ActionMessage (org.apache.struts.action.ActionMessage)2 LookUpValueEntity (org.mifos.application.master.business.LookUpValueEntity)2 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 OutputStream (java.io.OutputStream)1