Search in sources :

Example 51 with LoanOfferingBO

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

the class ProductMixBusinessServiceIntegrationTest method testCanProductsExist.

@Test
public void testCanProductsExist() throws Exception {
    LegacyProductMixDao productMixPersistenceMock = createMock(LegacyProductMixDao.class);
    short PRD_OFFERING_ID_ONE = (short) 1;
    short PRD_OFFERING_ID_TWO = (short) 2;
    LoanOfferingBO loanOfferingMock1 = createMock(LoanOfferingBO.class);
    LoanOfferingBO loanOfferingMock2 = createMock(LoanOfferingBO.class);
    expect(productMixPersistenceMock.doesPrdOfferingsCanCoexist(PRD_OFFERING_ID_ONE, PRD_OFFERING_ID_TWO)).andReturn(true);
    expect(loanOfferingMock1.getPrdOfferingId()).andReturn(PRD_OFFERING_ID_ONE);
    expect(loanOfferingMock2.getPrdOfferingId()).andReturn(PRD_OFFERING_ID_TWO);
    replay(loanOfferingMock1, loanOfferingMock2, productMixPersistenceMock);
    new ProductMixBusinessService(productMixPersistenceMock).canProductsCoExist(loanOfferingMock1, loanOfferingMock2);
    verify(loanOfferingMock1, loanOfferingMock2, productMixPersistenceMock);
}
Also used : LegacyProductMixDao(org.mifos.accounts.productsmix.persistence.LegacyProductMixDao) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Test(org.junit.Test)

Example 52 with LoanOfferingBO

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

the class LoanPrdPersistenceIntegrationTest method testGetAllLoanOfferingsShouldReturnLoanOfferingListSortedByName.

@Test
public void testGetAllLoanOfferingsShouldReturnLoanOfferingListSortedByName() throws PersistenceException {
    String[] loanPrdNamesSortedByName = new String[] { "firstLoanOffering", "secondLoanOffering", "thirdLoanOffering" };
    loanOffering1 = createLoanOfferingBO(loanPrdNamesSortedByName[1], "Loa1");
    loanOffering2 = createLoanOfferingBO(loanPrdNamesSortedByName[2], "Loa2");
    loanOffering3 = createLoanOfferingBO(loanPrdNamesSortedByName[0], "Loa3");
    StaticHibernateUtil.flushSession();
    List<LoanOfferingBO> loanOfferings = new LoanPrdPersistence().getAllLoanOfferings((short) 1);
    Assert.assertNotNull(loanOfferings);
    Assert.assertEquals(3, loanOfferings.size());
    int i = 0;
    for (LoanOfferingBO loanOfferingBO : loanOfferings) {
        Assert.assertEquals(loanPrdNamesSortedByName[i++], loanOfferingBO.getPrdOfferingName());
        Assert.assertNotNull(loanOfferingBO.getPrdOfferingId());
        Assert.assertNotNull(loanOfferingBO.getPrdStatus().getPrdState().getName());
    }
    StaticHibernateUtil.flushSession();
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Test(org.junit.Test)

Example 53 with LoanOfferingBO

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

the class LoanProductDaoHibernateIntegrationTest method testShouldFindOnlyActiveLoanProductsApplicableToCustomerLevel.

@Test
public void testShouldFindOnlyActiveLoanProductsApplicableToCustomerLevel() {
    CustomerLevelEntity groupLevel = new CustomerLevelEntity(CustomerLevel.GROUP);
    // exercise test
    List<LoanOfferingBO> activeLoanProductsApplicableToGroup = loanProductDao.findActiveLoanProductsApplicableToCustomerLevel(groupLevel);
    assertThat("Only active products applicable to groups should be returned", activeLoanProductsApplicableToGroup.size(), is(1));
    assertThat(activeLoanProductsApplicableToGroup, hasItem(activeLoanProduct));
}
Also used : CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Test(org.junit.Test)

Example 54 with LoanOfferingBO

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

the class LoanPrdBusinessServiceIntegrationTest method testGetAllLoanOfferings.

@Test
public void testGetAllLoanOfferings() throws ServiceException {
    loanOffering = createLoanOfferingBO("Loan Offering", "Loan");
    LoanOfferingBO loanOffering1 = createLoanOfferingBO("Loan Offering1", "Loa1");
    StaticHibernateUtil.flushSession();
    List<LoanOfferingBO> loanOfferings = new LoanPrdBusinessService().getAllLoanOfferings((short) 1);
    Assert.assertNotNull(loanOfferings);
    Assert.assertEquals(2, loanOfferings.size());
    for (LoanOfferingBO loanOfferingBO : loanOfferings) {
        Assert.assertNotNull(loanOfferingBO.getPrdOfferingName());
        Assert.assertNotNull(loanOfferingBO.getPrdOfferingId());
        Assert.assertNotNull(loanOfferingBO.getPrdStatus().getPrdState().getName());
    }
    StaticHibernateUtil.flushSession();
    TestObjectFactory.removeObject(loanOffering1);
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) Test(org.junit.Test)

Example 55 with LoanOfferingBO

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

the class ClientStatusChangeIntegrationTest method givenClientHasActiveAccountsShouldNotPassValidationWhenTryingToTranistionClientToClosed.

@Test
public void givenClientHasActiveAccountsShouldNotPassValidationWhenTryingToTranistionClientToClosed() throws Exception {
    // setup
    CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
    IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
    GroupBO existingActiveGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_ACTIVE).withParentCustomer(existingCenter).formedBy(existingUser).build();
    IntegrationTestObjectMother.createGroup(existingActiveGroup, existingMeeting);
    ClientBO existingActiveClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_ACTIVE).withParentCustomer(existingActiveGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingActiveClient, existingMeeting);
    StaticHibernateUtil.flushAndClearSession();
    DateTime startDate = new DateTime().minusDays(14);
    LoanOfferingBO clientLoanProduct = new LoanProductBuilder().appliesToClientsOnly().withGlobalProductNumber("XXX-00002").active().withMeeting(existingMeeting).withName("Loan-client").withShortName("dsvd").withStartDate(startDate).withDefaultInterest(1.2).buildForIntegrationTests();
    IntegrationTestObjectMother.createProduct(clientLoanProduct);
    LoanBO clientLoan = new LoanAccountBuilder().withLoanProduct(clientLoanProduct).withCustomer(existingActiveClient).withOriginalLoanAmount(600.0).build();
    IntegrationTestObjectMother.saveLoanAccount(clientLoan);
    existingActiveGroup = this.customerDao.findGroupBySystemId(existingActiveGroup.getGlobalCustNum());
    existingActiveClient = this.customerDao.findClientBySystemId(existingActiveClient.getGlobalCustNum());
    existingActiveClient.setUserContext(TestUtils.makeUser());
    CustomerStatusFlag customerStatusFlag = null;
    CustomerNoteEntity customerNote = new CustomerNoteEntity("go active", new Date(), existingActiveClient.getPersonnel(), existingActiveClient);
    // exercise test
    try {
        customerService.updateClientStatus(existingActiveClient, existingActiveClient.getStatus(), CustomerStatus.CLIENT_CLOSED, customerStatusFlag, customerNote);
        fail("should fail validation");
    } catch (CustomerException expected) {
        assertThat(expected.getKey(), is(CustomerConstants.CUSTOMER_HAS_ACTIVE_ACCOUNTS_EXCEPTION));
        assertThat(existingActiveClient.getStatus(), is(CustomerStatus.CLIENT_ACTIVE));
    }
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerException(org.mifos.customers.exceptions.CustomerException) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) LoanAccountBuilder(org.mifos.domain.builders.LoanAccountBuilder) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) DateTime(org.joda.time.DateTime) Date(java.util.Date) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) GroupBO(org.mifos.customers.group.business.GroupBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) 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