use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class EditCustomerStatusActionStrutsTest method testUpdateStatusForClientForActiveLoanOfficer.
@SuppressWarnings("unchecked")
@Test
public void testUpdateStatusForClientForActiveLoanOfficer() throws CustomerException, PageExpiredException {
createInitialObjects();
CustomerBOTestUtils.setCustomerStatus(client, new CustomerStatusEntity(CustomerStatus.CLIENT_PARTIAL.getValue()));
client.update();
StaticHibernateUtil.flushAndClearSession();
client = TestObjectFactory.getCustomer(client.getCustomerId());
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.loadStatus.toString());
addRequestParameter("customerId", client.getCustomerId().toString());
actionPerform();
verifyForward(ActionForwards.loadStatus_success.toString());
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.previewStatus.toString());
addRequestParameter("notes", "Test");
addRequestParameter("levelId", client.getCustomerLevel().getId().toString());
addRequestParameter("newStatusId", "3");
addRequestParameter("flagId", "");
actionPerform();
verifyForward(ActionForwards.previewStatus_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NEW_STATUS_NAME, request));
Assert.assertNull("Since new Status is not Closed,so flag should be null.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request.getSession()));
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.updateStatus.toString());
actionPerform();
verifyNoActionErrors();
verifyForward(ActionForwards.client_detail_page.toString());
client = TestObjectFactory.getCustomer(client.getCustomerId());
Assert.assertTrue(client.isActive());
cleanInitialObjects();
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class CustomerUIHelperFnStrutsTest method testUIHelperWhenClientIsNotAssignedPosition.
@Test
public void testUIHelperWhenClientIsNotAssignedPosition() throws CustomerException, PageExpiredException {
createInitialObjects();
PositionEntity positionEntity = (PositionEntity) TestObjectFactory.getObject(PositionEntity.class, Short.valueOf("1"));
CustomerPositionEntity customerPositionEntity = new CustomerPositionEntity(positionEntity, client, client.getParentCustomer());
group.addCustomerPosition(customerPositionEntity);
group.update();
StaticHibernateUtil.flushSession();
client = TestObjectFactory.getCustomer(client.getCustomerId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
center = TestObjectFactory.getCustomer(center.getCustomerId());
group.setUserContext(TestObjectFactory.getContext());
CustomerDetailDto clientDetail = new CustomerDetailDto(client.getCustomerId(), client.getDisplayName(), client.getSearchId(), client.getGlobalCustNum());
List<CustomerPositionOtherDto> customerPositions = new ArrayList<CustomerPositionOtherDto>();
for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
customerPositions.add(new CustomerPositionOtherDto(customerPosition.getPosition().getName(), customerPosition.getCustomer().getCustomerId(), customerPosition.getCustomer().getDisplayName()));
}
String positionName = CustomerUIHelperFn.getClientPosition(customerPositions, clientDetail);
Assert.assertEquals("(Center Leader)", positionName);
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.loadStatus.toString());
addRequestParameter("customerId", client.getCustomerId().toString());
actionPerform();
verifyForward(ActionForwards.loadStatus_success.toString());
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.previewStatus.toString());
addRequestParameter("notes", "Test");
addRequestParameter("levelId", client.getCustomerLevel().getId().toString());
addRequestParameter("newStatusId", "6");
addRequestParameter("flagId", "7");
actionPerform();
verifyForward(ActionForwards.previewStatus_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NEW_STATUS_NAME, request));
Assert.assertNotNull("Since new Status is Closed,so flag should be Duplicate.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request));
for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
Assert.assertNotNull(customerPosition.getCustomer());
break;
}
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.updateStatus.toString());
actionPerform();
verifyNoActionErrors();
verifyForward(ActionForwards.client_detail_page.toString());
client = TestObjectFactory.getCustomer(client.getCustomerId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
Assert.assertFalse(client.isActive());
for (CustomerFlagDetailEntity customerFlagDetailEntity : client.getCustomerFlags()) {
Assert.assertFalse(customerFlagDetailEntity.getStatusFlag().isBlackListed());
break;
}
for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
Assert.assertNull(customerPosition.getCustomer());
break;
}
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class CustomerUIHelperFnStrutsTest method testUIHelperWhenClientIsAssignedPosition.
@Test
public void testUIHelperWhenClientIsAssignedPosition() throws CustomerException, PageExpiredException {
createInitialObjects();
PositionEntity positionEntity = (PositionEntity) TestObjectFactory.getObject(PositionEntity.class, Short.valueOf("1"));
CustomerPositionEntity customerPositionEntity = new CustomerPositionEntity(positionEntity, client, client.getParentCustomer());
group.addCustomerPosition(customerPositionEntity);
group.update();
StaticHibernateUtil.flushSession();
client = TestObjectFactory.getCustomer(client.getCustomerId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
center = TestObjectFactory.getCustomer(center.getCustomerId());
group.setUserContext(TestObjectFactory.getContext());
CustomerDetailDto clientDetail = new CustomerDetailDto(client.getCustomerId(), client.getDisplayName(), client.getSearchId(), client.getGlobalCustNum());
List<CustomerPositionOtherDto> customerPositions = new ArrayList<CustomerPositionOtherDto>();
for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
customerPositions.add(new CustomerPositionOtherDto(customerPosition.getPosition().getName(), customerPosition.getCustomer().getCustomerId(), customerPosition.getCustomer().getDisplayName()));
}
String positionName = CustomerUIHelperFn.getClientPosition(customerPositions, clientDetail);
Assert.assertEquals("(Center Leader)", positionName);
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.loadStatus.toString());
addRequestParameter("customerId", client.getCustomerId().toString());
actionPerform();
verifyForward(ActionForwards.loadStatus_success.toString());
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.previewStatus.toString());
addRequestParameter("notes", "Test");
addRequestParameter("levelId", client.getCustomerLevel().getId().toString());
addRequestParameter("newStatusId", "6");
addRequestParameter("flagId", "7");
actionPerform();
verifyForward(ActionForwards.previewStatus_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NEW_STATUS_NAME, request));
Assert.assertNotNull("Since new Status is Closed,so flag should be Duplicate.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request));
for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
Assert.assertNotNull(customerPosition.getCustomer());
break;
}
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.updateStatus.toString());
actionPerform();
verifyNoActionErrors();
verifyForward(ActionForwards.client_detail_page.toString());
client = TestObjectFactory.getCustomer(client.getCustomerId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
Assert.assertFalse(client.isActive());
for (CustomerFlagDetailEntity customerFlagDetailEntity : client.getCustomerFlags()) {
Assert.assertFalse(customerFlagDetailEntity.getStatusFlag().isBlackListed());
break;
}
for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
Assert.assertNull(customerPosition.getCustomer());
break;
}
}
use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.
the class EditCustomerStatusActionStrutsTest method testUpdateStatusForClientWhenClientIsAssignedPosition.
@SuppressWarnings("unchecked")
@Test
public void testUpdateStatusForClientWhenClientIsAssignedPosition() throws CustomerException, PageExpiredException {
createInitialObjects();
CustomerPositionEntity customerPositionEntity = new CustomerPositionEntity(new PositionEntity(Short.valueOf("1")), client, client.getParentCustomer());
group.addCustomerPosition(customerPositionEntity);
group.update();
StaticHibernateUtil.flushAndClearSession();
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.loadStatus.toString());
addRequestParameter("customerId", client.getCustomerId().toString());
actionPerform();
verifyForward(ActionForwards.loadStatus_success.toString());
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.previewStatus.toString());
addRequestParameter("notes", "Test");
addRequestParameter("levelId", client.getCustomerLevel().getId().toString());
addRequestParameter("newStatusId", "6");
addRequestParameter("flagId", "7");
actionPerform();
verifyForward(ActionForwards.previewStatus_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NEW_STATUS_NAME, request));
Assert.assertNotNull("Since new Status is Closed,so flag should be Duplicate.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request));
for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
Assert.assertNotNull(customerPosition.getCustomer());
break;
}
setRequestPathInfo("/editCustomerStatusAction.do");
addRequestParameter("method", Methods.updateStatus.toString());
actionPerform();
verifyNoActionErrors();
verifyForward(ActionForwards.client_detail_page.toString());
client = TestObjectFactory.getCustomer(client.getCustomerId());
Assert.assertFalse(client.isActive());
for (CustomerFlagDetailEntity customerFlagDetailEntity : client.getCustomerFlags()) {
Assert.assertFalse(customerFlagDetailEntity.getStatusFlag().isBlackListed());
break;
}
group = TestObjectFactory.getCustomer(group.getCustomerId());
for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
Assert.assertNull(customerPosition.getCustomer());
break;
}
cleanInitialObjects();
}
use of org.mifos.accounts.business.AccountStateEntity 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();
}
}
}
Aggregations