use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.
the class GroupCreationTest method createsGroupWithCustomerAccount.
@Test
public void createsGroupWithCustomerAccount() throws Exception {
// setup
OfficeBO withOffice = new OfficeBO(new Short("1"), "testOffice", new Integer("1"), new Short("1"));
CenterBO parent = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).with(withOffice).build();
GroupBO stubbedGroup = new GroupBuilder().withName("group").withParentCustomer(parent).formedBy(anyLoanOfficer()).build();
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stub
CalendarEvent upcomingCalendarEvents = new CalendarEventBuilder().build();
when(holidayDao.findCalendarEventsForThisYearAndNext((short) 1)).thenReturn(upcomingCalendarEvents);
when(customerAccountFactory.create(stubbedGroup, accountFees, meeting, upcomingCalendarEvents)).thenReturn(customerAccount);
when(customerAccount.getType()).thenReturn(AccountTypes.CUSTOMER_ACCOUNT);
// exercise test
customerService.createGroup(stubbedGroup, meeting, accountFees);
// verification
assertThat(stubbedGroup.getCustomerAccount(), is(customerAccount));
}
use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.
the class GroupCreationTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs.
@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs() throws Exception {
// setup
CenterBO parent = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).build();
GroupBO stubbedGroup = new GroupBuilder().withName("group").withParentCustomer(parent).formedBy(anyLoanOfficer()).build();
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stub
doThrow(new RuntimeException()).when(customerDao).save(stubbedGroup);
// exercise test
customerService.createGroup(stubbedGroup, meeting, accountFees);
// verification
verify(hibernateTransactionHelper).rollbackTransaction();
verify(hibernateTransactionHelper).closeSession();
}
use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.
the class CenterValidationTest method cannotCreateCenterWithMultipleInstancesOfSamePeriodFee.
@Test
public void cannotCreateCenterWithMultipleInstancesOfSamePeriodFee() {
// setup
DateTime today = new DateTime();
MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly();
CenterBO center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(aWeeklyMeeting).withMfiJoiningDate(today).build();
MeetingBuilder aWeeklyFeeMeeting = new MeetingBuilder().periodicFeeMeeting().weekly();
AmountFeeBO montlyPeriodicFee = new FeeBuilder().appliesToCenterOnly().with(aWeeklyFeeMeeting).build();
AccountFeesEntity accountFee = new AccountFeesEntity(null, montlyPeriodicFee, montlyPeriodicFee.getFeeAmount().getAmountDoubleValue());
List<AccountFeesEntity> centerAccountFees = new ArrayList<AccountFeesEntity>();
centerAccountFees.add(accountFee);
centerAccountFees.add(accountFee);
// exercise test
try {
center.validateMeetingAndFees(centerAccountFees);
fail("cannotCreateCenterWithFeeThatHasDifferentPeriod");
} catch (ApplicationException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_DUPLICATE_PERIODIC_FEE));
}
}
use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.
the class ClientCreationTest method throwsCheckedExceptionWhenValidationForDuplicateNameOrGovernmentId.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenValidationForDuplicateNameOrGovernmentId() throws Exception {
String displayName = "Test Name";
Date dob = new Date();
String govtId = "44354323543";
// setup
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
List<SavingsOfferingBO> noSavings = new ArrayList<SavingsOfferingBO>();
// stubbing
Mockito.when(mockedClient.getDisplayName()).thenReturn(displayName);
Mockito.when(mockedClient.getDateOfBirth()).thenReturn(dob);
Mockito.when(mockedClient.getGovernmentId()).thenReturn(govtId);
doThrow(new CustomerException(CustomerConstants.DUPLICATE_GOVT_ID_EXCEPTION)).when(customerDao).validateClientForDuplicateNameOrGovtId(displayName, dob, govtId);
// exercise test
customerService.createClient(mockedClient, meeting, accountFees, noSavings);
// verify
verify(customerDao).validateClientForDuplicateNameOrGovtId(mockedClient.getDisplayName(), mockedClient.getDateOfBirth(), mockedClient.getGovernmentId());
}
use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.
the class ClientCreationTest method throwsCheckedExceptionWhenClientValidationFails.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenClientValidationFails() throws Exception {
// setup
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
List<SavingsOfferingBO> noSavings = new ArrayList<SavingsOfferingBO>();
// stubbing
doThrow(new CustomerException(ClientConstants.ERRORS_GROUP_CANCELLED)).when(mockedClient).validate();
// exercise test
customerService.createClient(mockedClient, meeting, accountFees, noSavings);
// verify
verify(mockedClient).validate();
}
Aggregations