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);
}
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();
}
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));
}
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);
}
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));
}
}
Aggregations