use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.
the class CenterCreationTest method throwsCheckedExceptionWhenCenterMeetingAndFeesFailValidation.
@Test(expected = BusinessRuleException.class)
public void throwsCheckedExceptionWhenCenterMeetingAndFeesFailValidation() throws Exception {
// setup
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stubbing
doThrow(new CustomerException(CustomerConstants.ERRORS_SPECIFY_MEETING)).when(mockedCenter).validateMeetingAndFees(accountFees);
// exercise test
customerService.createCenter(mockedCenter, meeting, accountFees);
// verification
verify(mockedCenter).validateMeetingAndFees(accountFees);
}
use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.
the class CenterCreationTest method throwsCheckedExceptionWhenCenterValidationFails.
@Test(expected = BusinessRuleException.class)
public void throwsCheckedExceptionWhenCenterValidationFails() throws Exception {
// setup
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stubbing
doThrow(new CustomerException(CustomerConstants.ERRORS_SPECIFY_NAME)).when(mockedCenter).validate();
// exercise test
customerService.createCenter(mockedCenter, meeting, accountFees);
// verification
verify(mockedCenter).validate();
}
use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.
the class CustomerAccountCreationTest method customerAccountIsAlwaysCreatedInActiveState.
@Test
public void customerAccountIsAlwaysCreatedInActiveState() throws Exception {
// setup
customer = new CenterBuilder().inActive().build();
accountFees = new ArrayList<AccountFeesEntity>();
// exercise test
customerAccount = CustomerAccountBO.createNew(customer, accountFees, customerMeeting, applicableCalendarEvents);
// verification
assertThat(customerAccount.isActive(), is(true));
}
use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.
the class CustomerAccountGenerateNextSetOfMeetingDatesTest method canGenerateNextSetOfMeetingScheduleOnTopOfPreviousMeetingScheduleWithRecurringFees.
@Test
public void canGenerateNextSetOfMeetingScheduleOnTopOfPreviousMeetingScheduleWithRecurringFees() {
// use default setup
MeetingBuilder weeklyMeetingBuilder = new MeetingBuilder().customerMeeting().weekly().every(1);
MeetingBO customerMeeting = weeklyMeetingBuilder.build();
customer = new CenterBuilder().active().with(customerMeeting).build();
AmountFeeBO recurringFee = new FeeBuilder().appliesToAllCustomers().periodic().with(weeklyMeetingBuilder).withFeeAmount("3.0").build();
AccountFeesEntity recurringFeeEntity = new AccountFeesEntity(null, recurringFee, recurringFee.getFeeAmount().getAmountDoubleValue());
recurringFeeEntity = spy(recurringFeeEntity);
when(recurringFeeEntity.getAccountFeeId()).thenReturn(1);
accountFees = new ArrayList<AccountFeesEntity>();
accountFees.add(recurringFeeEntity);
customerAccount = CustomerAccountBO.createNew(customer, accountFees, customerMeeting, calendarEvent);
// setup
AccountFeesEntity sameButDifferentRecurringFeeEntity = new AccountFeesEntity(customerAccount, recurringFee, recurringFee.getFeeAmount().getAmountDoubleValue());
sameButDifferentRecurringFeeEntity = spy(sameButDifferentRecurringFeeEntity);
customerAccount.getAccountFees().clear();
customerAccount.addAccountFees(sameButDifferentRecurringFeeEntity);
when(sameButDifferentRecurringFeeEntity.getAccountFeeId()).thenReturn(1);
List<AccountActionDateEntity> schedules = new ArrayList<AccountActionDateEntity>(customerAccount.getAccountActionDates());
DateTime lastScheduledDate = new DateTime(schedules.get(9).getActionDate());
ScheduledEvent scheduledEvent = ScheduledEventFactory.createScheduledEventFrom(customer.getCustomerMeetingValue());
// stubbing
List<DateTime> generatedDates = elevenDatesStartingFromAndIncluding(lastScheduledDate, scheduledEvent);
when(scheduledDateGeneration.generateScheduledDates(anyInt(), (DateTime) anyObject(), (ScheduledEvent) anyObject(), anyBoolean())).thenReturn(generatedDates);
// exercise test
customerAccount.generateNextSetOfMeetingDates(scheduledDateGeneration);
assertThat(customerAccount.getAccountActionDates().size(), is(20));
}
use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.
the class GroupCreationTest method throwsCheckedExceptionWhenGroupNameIsTakenForOfficeAlready.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenGroupNameIsTakenForOfficeAlready() throws Exception {
// setup
CenterBO parent = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).build();
GroupBO stubbedGroup = new GroupBuilder().withName("already-exists-group").withParentCustomer(parent).formedBy(anyLoanOfficer()).build();
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stubbing
doThrow(new CustomerException(CustomerConstants.ERRORS_DUPLICATE_CUSTOMER)).when(customerDao).validateGroupNameIsNotTakenForOffice(anyString(), anyShort());
// exercise test
customerService.createGroup(stubbedGroup, meeting, accountFees);
}
Aggregations