Search in sources :

Example 11 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class ReverseLoanDisbursalActionStrutsTest method createLoanAccount.

private void createLoanAccount() {
    Date startDate = new Date(System.currentTimeMillis());
    createInitialCustomers();
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(this.getClass().getSimpleName() + " LOAN", "L", startDate, center.getCustomerMeeting().getMeeting());
    loan = TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_APPROVED, startDate, loanOffering);
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Date(java.util.Date)

Example 12 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class ProductMixValidatorIntegrationTest method testShouldAllowValidProductMix.

@Test
public void testShouldAllowValidProductMix() throws Exception {
    LoanBO loanMock1 = createMock(LoanBO.class);
    LoanBO loanMock2 = createMock(LoanBO.class);
    LoanOfferingBO loanOfferingMock1 = createMock(LoanOfferingBO.class);
    LoanOfferingBO loanOfferingMock2 = createMock(LoanOfferingBO.class);
    expect(loanMock1.getLoanOffering()).andReturn(loanOfferingMock1);
    expect(loanMock2.getLoanOffering()).andReturn(loanOfferingMock2);
    expect(productMixBusinessServiceMock.canProductsCoExist(loanOfferingMock2, loanOfferingMock1)).andReturn(true);
    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));
        verify(loanMock1, loanMock2, loanOfferingMock1, loanOfferingMock2, productMixBusinessServiceMock);
    } catch (AccountException e) {
        Assert.fail("Invalid Product mix conflict detected");
    }
}
Also used : AccountException(org.mifos.accounts.exceptions.AccountException) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Test(org.junit.Test)

Example 13 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class MultipleLoanAccountsCreationActionStrutsTest method testGetPrdOfferingsApplicableForCustomersWithMeeting.

@SuppressWarnings("unchecked")
@Test
public void testGetPrdOfferingsApplicableForCustomersWithMeeting() throws Exception {
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    createInitialCustomers();
    LoanOfferingBO loanOffering1 = getLoanOffering("vcxvxc", "a123", ApplicableTo.CLIENTS, WEEKLY, EVERY_WEEK);
    LoanOfferingBO loanOffering2 = getLoanOffering("fgdsghdh", "4fdh", ApplicableTo.CLIENTS, WEEKLY, EVERY_WEEK);
    LoanOfferingBO loanOffering3 = getLoanOffering("mgkkkj", "6tyu", ApplicableTo.GROUPS, WEEKLY, EVERY_WEEK);
    LoanOfferingBO loanOffering4 = getLoanOffering("aq12sfdsf", "456j", ApplicableTo.CLIENTS, MONTHLY, EVERY_MONTH);
    LoanOfferingBO loanOffering5 = getLoanOffering("bdfhgfh", "6yu7", ApplicableTo.CLIENTS, WEEKLY, (short) 3);
    setRequestPathInfo("/multipleloansaction.do");
    addRequestParameter("method", "getPrdOfferings");
    addRequestParameter("branchOfficeId", "1");
    addRequestParameter("loanOfficerId", "1");
    addRequestParameter("centerId", center.getCustomerId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(LoanConstants.IS_CENTER_HIERARCHY_EXISTS, Constants.YES, request);
    /*
         * Why two calls to actionPerform? Are we trying to test the case where the user clicks twice or is this just a
         * mistake?
         */
    actionPerform();
    performNoErrors();
    verifyForward(ActionForwards.load_success.toString());
    Assert.assertEquals(3, ((List<LoanOfferingBO>) SessionUtils.getAttribute(LoanConstants.LOANPRDOFFERINGS, request)).size());
    TestObjectFactory.removeObject(loanOffering1);
    TestObjectFactory.removeObject(loanOffering2);
    TestObjectFactory.removeObject(loanOffering3);
    TestObjectFactory.removeObject(loanOffering4);
    TestObjectFactory.removeObject(loanOffering5);
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Test(org.junit.Test)

Example 14 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class MultipleLoanAccountsCreationActionStrutsTest method testGetPrdOfferings.

@Test
public void testGetPrdOfferings() throws Exception {
    createInitialCustomers();
    LoanOfferingBO loanOffering1 = getLoanOffering("Loan Offering123", "LOOF", ApplicableTo.CLIENTS, WEEKLY, EVERY_WEEK);
    setRequestPathInfo("/multipleloansaction.do");
    addRequestParameter("method", "load");
    actionPerform();
    setRequestPathInfo("/multipleloansaction.do");
    addRequestParameter("method", "getLoanOfficers");
    addRequestParameter("branchOfficeId", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    setRequestPathInfo("/multipleloansaction.do");
    addRequestParameter("method", "getCenters");
    addRequestParameter("branchOfficeId", "1");
    addRequestParameter("loanOfficerId", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    setRequestPathInfo("/multipleloansaction.do");
    addRequestParameter("method", "getPrdOfferings");
    addRequestParameter("loanOfficerId", "1");
    addRequestParameter("branchOfficeId", "1");
    addRequestParameter("centerId", center.getCustomerId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    performNoErrors();
    verifyForward(ActionForwards.load_success.toString());
    Assert.assertNotNull(SessionUtils.getAttribute(LoanConstants.MULTIPLE_LOANS_OFFICES_LIST, request));
    Assert.assertNotNull(SessionUtils.getAttribute(LoanConstants.IS_CENTER_HIERARCHY_EXISTS, request));
    Assert.assertNotNull(SessionUtils.getAttribute(LoanConstants.MULTIPLE_LOANS_LOAN_OFFICERS_LIST, request));
    Assert.assertNotNull(SessionUtils.getAttribute(LoanConstants.MULTIPLE_LOANS_CENTERS_LIST, request));
    Assert.assertNotNull(SessionUtils.getAttribute(LoanConstants.LOANPRDOFFERINGS, request));
    TestObjectFactory.removeObject(loanOffering1);
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Test(org.junit.Test)

Example 15 with LoanOfferingBO

use of org.mifos.accounts.productdefinition.business.LoanOfferingBO in project head by mifos.

the class MultipleLoanAccountsCreationActionStrutsTest method testGetWithoutClients.

@Test
public void testGetWithoutClients() throws Exception {
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    LoanOfferingBO loanOffering1 = getLoanOffering("vcxvxc", "a123", ApplicableTo.CLIENTS, WEEKLY, EVERY_WEEK);
    setRequestPathInfo("/multipleloansaction.do");
    addRequestParameter("method", "get");
    addRequestParameter("branchOfficeId", center.getOffice().getOfficeId().toString());
    SessionUtils.setAttribute(LoanConstants.IS_CENTER_HIERARCHY_EXISTS, Constants.YES, request);
    addRequestParameter("loanOfficerId", center.getPersonnel().getPersonnelId().toString());
    addRequestParameter("centerId", center.getCustomerId().toString());
    addRequestParameter("prdOfferingId", loanOffering1.getPrdOfferingId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyActionErrors(new String[] { LoanConstants.NOSEARCHRESULTS });
    verifyForwardPath("/pages/application/loan/jsp/CreateMultipleLoanAccounts.jsp");
    TestObjectFactory.removeObject(loanOffering1);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Test(org.junit.Test)

Aggregations

LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)135 MeetingBO (org.mifos.application.meeting.business.MeetingBO)44 Date (java.util.Date)37 Test (org.junit.Test)37 ArrayList (java.util.ArrayList)26 Date (java.sql.Date)21 LoanBO (org.mifos.accounts.loan.business.LoanBO)18 LocalDate (org.joda.time.LocalDate)17 CustomerBO (org.mifos.customers.business.CustomerBO)12 LoanProductBuilder (org.mifos.domain.builders.LoanProductBuilder)11 UserContext (org.mifos.security.util.UserContext)9 ClientBuilder (org.mifos.domain.builders.ClientBuilder)8 Money (org.mifos.framework.util.helpers.Money)8 MifosUser (org.mifos.security.MifosUser)8 BusinessRuleException (org.mifos.service.BusinessRuleException)8 ProductCategoryBO (org.mifos.accounts.productdefinition.business.ProductCategoryBO)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)7 BigDecimal (java.math.BigDecimal)6 AccountException (org.mifos.accounts.exceptions.AccountException)6 FeeBO (org.mifos.accounts.fees.business.FeeBO)6