Search in sources :

Example 76 with AccountFeesEntity

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);
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) ArrayList(java.util.ArrayList) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 77 with AccountFeesEntity

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();
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) ArrayList(java.util.ArrayList) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 78 with AccountFeesEntity

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));
}
Also used : CenterBuilder(org.mifos.domain.builders.CenterBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 79 with AccountFeesEntity

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));
}
Also used : ScheduledEvent(org.mifos.schedule.ScheduledEvent) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) CenterBuilder(org.mifos.domain.builders.CenterBuilder) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) DateTime(org.joda.time.DateTime) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) FeeBuilder(org.mifos.domain.builders.FeeBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 80 with AccountFeesEntity

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);
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Aggregations

AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)118 ArrayList (java.util.ArrayList)78 Test (org.junit.Test)65 CenterBuilder (org.mifos.domain.builders.CenterBuilder)46 DateTime (org.joda.time.DateTime)42 MeetingBO (org.mifos.application.meeting.business.MeetingBO)42 CenterBO (org.mifos.customers.center.business.CenterBO)39 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)38 FeeBO (org.mifos.accounts.fees.business.FeeBO)25 Money (org.mifos.framework.util.helpers.Money)25 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)24 UserContext (org.mifos.security.util.UserContext)22 LocalDate (org.joda.time.LocalDate)21 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)21 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)18 FeeInstallment (org.mifos.accounts.util.helpers.FeeInstallment)17 OfficeBO (org.mifos.customers.office.business.OfficeBO)17 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)17 MifosUser (org.mifos.security.MifosUser)16 AccountException (org.mifos.accounts.exceptions.AccountException)14