Search in sources :

Example 16 with CalendarEventBuilder

use of org.mifos.domain.builders.CalendarEventBuilder 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));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) 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) CalendarEvent(org.mifos.calendar.CalendarEvent) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Matchers.anyShort(org.mockito.Matchers.anyShort) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Example 17 with CalendarEventBuilder

use of org.mifos.domain.builders.CalendarEventBuilder in project head by mifos.

the class CustomerAccountCreationTest method firstCustomerScheduleIsAlwaysTheClosestMatchingDayOfWeekAndDoesNotTakeIntoAccountMonthlyMeetingFrequency.

@Test
public void firstCustomerScheduleIsAlwaysTheClosestMatchingDayOfWeekAndDoesNotTakeIntoAccountMonthlyMeetingFrequency() throws Exception {
    // setup
    applicableCalendarEvents = new CalendarEventBuilder().build();
    DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
    accountFees = new ArrayList<AccountFeesEntity>();
    MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().monthly().every(2).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
    CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
    // exercise test
    CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
    // verification
    List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
    LocalDate firstCenterDate = new LocalDate(centerSchedules.get(0).getActionDate());
    LocalDate mon18thOfMay = new DateTime().withDate(2011, 5, 18).toLocalDate();
    assertThat(firstCenterDate, is(mon18thOfMay));
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) LocalDate(org.joda.time.LocalDate) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) DateTime(org.joda.time.DateTime) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)17 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)17 CenterBuilder (org.mifos.domain.builders.CenterBuilder)17 CenterBO (org.mifos.customers.center.business.CenterBO)15 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)14 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)14 ArrayList (java.util.ArrayList)13 DateTime (org.joda.time.DateTime)12 MeetingBO (org.mifos.application.meeting.business.MeetingBO)12 LocalDate (org.joda.time.LocalDate)10 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)10 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)9 GroupBO (org.mifos.customers.group.business.GroupBO)8 GroupBuilder (org.mifos.domain.builders.GroupBuilder)8 CalendarEvent (org.mifos.calendar.CalendarEvent)4 CustomerAccountBuilder (org.mifos.domain.builders.CustomerAccountBuilder)3 UserContext (org.mifos.security.util.UserContext)3 OfficeBO (org.mifos.customers.office.business.OfficeBO)2 DateMidnight (org.joda.time.DateMidnight)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1