Search in sources :

Example 6 with AdminDocAccStateMixBO

use of org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO in project head by mifos.

the class PentahoReportsServiceIntegrationTest method testGetAdminReport.

@Test
public void testGetAdminReport() throws Exception {
    String adminDocumentUploadPath = viewOrganizationSettingsServiceFacade.getAdminDocumentStorageDirectory();
    String adminDocumentPath = "IntegrationTest_Loan_template.prpt";
    File adminDocumentSrc = new File(this.getClass().getResource("/Loan_template.prpt").toString().replace("file:", ""));
    File adminDocumentDst = new File(adminDocumentUploadPath + "/" + adminDocumentPath);
    try {
        FileUtils.copyFile(adminDocumentSrc, adminDocumentDst);
        AdminDocumentBO adminDocumentBO = new AdminDocumentBO();
        adminDocumentBO.setAdmindocId(Short.valueOf("1"));
        adminDocumentBO.setAdminDocumentName("IntegrationTest_Loan_template");
        adminDocumentBO.setIsActive(Short.valueOf("1"));
        adminDocumentBO.setAdminDocumentIdentifier(adminDocumentPath);
        AdminDocAccStateMixBO adminDocAccStateMixBO = new AdminDocAccStateMixBO();
        AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.LOAN_APPROVED);
        adminDocAccStateMixBO.setAccountStateID(accountStateEntity);
        adminDocAccStateMixBO.setAdminDocumentID(adminDocumentBO);
        legacyAdminDocumentDao.createOrUpdate(adminDocumentBO);
        Map<String, AbstractPentahoParameter> params = new HashMap<String, AbstractPentahoParameter>();
        PentahoInputParameter entityIdParameter = new PentahoInputParameter();
        entityIdParameter.setParamName("entity_id");
        entityIdParameter.setValue("000100000000002");
        params.put("entity_id", entityIdParameter);
        Integer adminDocId = Integer.parseInt(adminDocumentBO.getAdmindocId().toString());
        for (PentahoOutputType outputType : PentahoOutputType.values()) {
            PentahoReport report = pentahoReportsServiceImpl.getAdminReport(adminDocId, outputType.getId(), params);
            Assert.assertTrue(report.getFileExtension() == outputType.getFileExtension());
            Assert.assertTrue(report.getContentType() == outputType.getContentType());
            Assert.assertTrue(report.getErrors().isEmpty());
        }
    } catch (Exception e) {
        throw e;
    } finally {
        if (adminDocumentDst.exists()) {
            adminDocumentDst.delete();
        }
    }
}
Also used : PentahoReport(org.mifos.reports.pentaho.PentahoReport) AbstractPentahoParameter(org.mifos.reports.pentaho.params.AbstractPentahoParameter) HashMap(java.util.HashMap) AdminDocAccStateMixBO(org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) PentahoOutputType(org.mifos.reports.pentaho.util.PentahoOutputType) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) PentahoInputParameter(org.mifos.reports.pentaho.params.PentahoInputParameter) File(java.io.File) Test(org.junit.Test)

Aggregations

AdminDocAccStateMixBO (org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO)6 AdminDocumentBO (org.mifos.reports.admindocuments.business.AdminDocumentBO)6 ArrayList (java.util.ArrayList)5 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)5 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)5 List (java.util.List)3 AdminDocAccActionMixBO (org.mifos.reports.admindocuments.business.AdminDocAccActionMixBO)3 BirtAdminDocumentUploadActionForm (org.mifos.reports.admindocuments.struts.actionforms.BirtAdminDocumentUploadActionForm)3 FormFile (org.apache.struts.upload.FormFile)2 AccountActionEntity (org.mifos.accounts.business.AccountActionEntity)2 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)2 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)2 UserContext (org.mifos.security.util.UserContext)2 File (java.io.File)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1 AccountStateFlagEntity (org.mifos.accounts.business.AccountStateFlagEntity)1