use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.
the class CloseLoanActionStrutsTest method getLoanAccount.
private LoanBO getLoanAccount() {
Date startDate = new DateTimeService().getCurrentJavaDateTime();
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
return TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
}
use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.
the class RepayLoanActionStrutsTest method getLoanAccount.
private AccountBO getLoanAccount() {
Date startDate = new DateTimeService().getCurrentJavaDateTime();
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
return TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
}
use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.
the class ProductMixValidatorIntegrationTest method testShouldDetectProductMixConflicts.
@Test
public void testShouldDetectProductMixConflicts() throws Exception {
short PRD_OFFERING_ID_TWO = (short) 2;
LoanBO loanMock1 = createMock(LoanBO.class);
LoanBO loanMock2 = createMock(LoanBO.class);
LoanOfferingBO loanOfferingMock1 = createMock(LoanOfferingBO.class);
LoanOfferingBO loanOfferingMock2 = createMock(LoanOfferingBO.class);
expect(loanMock2.getLoanOffering()).andReturn(loanOfferingMock2);
expect(loanMock1.getLoanOffering()).andReturn(loanOfferingMock1);
expect(loanOfferingMock2.getPrdOfferingId()).andReturn(PRD_OFFERING_ID_TWO);
expect(productMixBusinessServiceMock.canProductsCoExist(loanOfferingMock2, loanOfferingMock1)).andReturn(false);
replay(loanMock1, loanMock2, loanOfferingMock1, loanOfferingMock2, productMixBusinessServiceMock);
try {
new ProductMixValidator(configServiceMock, productMixBusinessServiceMock) {
@Override
void handleConflict(LoanBO newloan, LoanBO loan) throws AccountException {
throw new AccountException("Some exception code");
}
}.validateProductMix(loanMock2, Arrays.asList(loanMock1));
Assert.fail("Product mix conflict not detected");
verify(loanMock1, loanMock2, loanOfferingMock1, loanOfferingMock2, productMixBusinessServiceMock);
} catch (AccountException e) {
}
}
use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.
the class MultipleLoanAccountsCreationActionStrutsTest method testCreate.
@SuppressWarnings("unchecked")
@Test
public void testCreate() throws Exception {
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
EntityMasterData.getInstance().init();
FieldConfig fieldConfig = FieldConfig.getInstance();
fieldConfig.init();
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createInitialCustomers();
LoanOfferingBO loanOffering = getLoanOffering("vcxvxc", "a123", ApplicableTo.CLIENTS, WEEKLY, EVERY_WEEK);
setRequestPathInfo("/multipleloansaction.do");
addRequestParameter("method", "get");
addRequestParameter("branchOfficeId", center.getOffice().getOfficeId().toString());
addRequestParameter("loanOfficerId", center.getPersonnel().getPersonnelId().toString());
addRequestParameter("prdOfferingId", loanOffering.getPrdOfferingId().toString());
SessionUtils.setAttribute(LoanConstants.IS_CENTER_HIERARCHY_EXISTS, Constants.YES, request);
addRequestParameter("centerId", center.getCustomerId().toString());
addRequestParameter("centerSearchId", center.getSearchId().toString());
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
setRequestPathInfo("/multipleloansaction.do");
addRequestParameter("clientDetails[0].loanAmount", loanOffering.getEligibleLoanAmountSameForAllLoan().getDefaultLoanAmount().toString());
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("stateSelected", "1");
addRequestParameter("clientDetails[0].selected", "true");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("method", "create");
addRequestParameter("stateSelected", "1");
actionPerform();
verifyActionErrors(new String[] { LoanExceptionConstants.CUSTOMER_PURPOSE_OF_LOAN_FIELD });
addRequestParameter("clientDetails[0].businessActivity", "0001");
performNoErrors();
verifyForward(ActionForwards.create_success.toString());
List<String> accountNumbers = ((List<String>) request.getAttribute(LoanConstants.ACCOUNTS_LIST));
Assert.assertEquals(1, accountNumbers.size());
LoanBO loan = ApplicationContextProvider.getBean(LoanBusinessService.class).findBySystemId(accountNumbers.get(0));
Assert.assertEquals(loanOffering.getEligibleLoanAmountSameForAllLoan().getDefaultLoanAmount().toString(), loan.getLoanAmount().toString());
Assert.assertEquals(loanOffering.getDefInterestRate(), loan.getInterestRate());
Assert.assertEquals(loanOffering.getEligibleInstallmentSameForAllLoan().getDefaultNoOfInstall(), loan.getNoOfInstallments());
Assert.assertEquals(Short.valueOf("1"), loan.getGracePeriodDuration());
Assert.assertEquals(Short.valueOf("1"), loan.getAccountState().getId());
Assert.assertNull(request.getAttribute(Constants.CURRENTFLOWKEY));
loan = null;
}
use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.
the class MultipleLoanAccountsCreationActionStrutsTest method testCreateWithouSelectingClient.
@Test
public void testCreateWithouSelectingClient() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createInitialCustomers();
LoanOfferingBO loanOffering = getLoanOffering("vcxvxc", "a123", ApplicableTo.CLIENTS, WEEKLY, EVERY_WEEK);
// loanOffering.updateLoanOfferingSameForAllLoan(loanOffering);
LoanAmountSameForAllLoanBO eligibleLoanAmountRange = loanOffering.getEligibleLoanAmountSameForAllLoan();
setRequestPathInfo("/multipleloansaction.do");
addRequestParameter("method", "get");
addRequestParameter("branchOfficeId", center.getOffice().getOfficeId().toString());
addRequestParameter("loanOfficerId", center.getPersonnel().getPersonnelId().toString());
addRequestParameter("prdOfferingId", loanOffering.getPrdOfferingId().toString());
SessionUtils.setAttribute(LoanConstants.IS_CENTER_HIERARCHY_EXISTS, Constants.YES, request);
addRequestParameter("centerId", center.getCustomerId().toString());
addRequestParameter("centerSearchId", center.getSearchId().toString());
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
setRequestPathInfo("/multipleloansaction.do");
addRequestParameter("clientDetails[0].loanAmount", eligibleLoanAmountRange.getDefaultLoanAmount().toString());
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("stateSelected", "1");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("method", "create");
addRequestParameter("stateSelected", "1");
actionPerform();
verifyActionErrors(new String[] { LoanExceptionConstants.SELECT_ATLEAST_ONE_RECORD });
verifyInputForward();
TestObjectFactory.removeObject(loanOffering);
}
Aggregations