Search in sources :

Example 11 with CalendarEventBuilder

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

the class UpdateCustomerMeetingScheduleTest method givenCustomerHasNoExistingMeetingShouldCreateMeetingOnCustomer.

@Test
public void givenCustomerHasNoExistingMeetingShouldCreateMeetingOnCustomer() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    CustomerAccountBuilder accountBuilder = new CustomerAccountBuilder();
    CenterBO center = new CenterBuilder().active().withAccount(accountBuilder).build();
    center.setCustomerMeeting(null);
    MeetingBO weeklyWednesdayMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).occuringOnA(WeekDay.WEDNESDAY).build();
    weeklyWednesdayMeeting.updateDetails(userContext);
    // stubbing
    when(holidayDao.findCalendarEventsForThisYearAndNext(anyShort())).thenReturn(new CalendarEventBuilder().build());
    // exercise test
    customerService.updateCustomerMeetingSchedule(weeklyWednesdayMeeting, center);
    // verification
    assertThat(center.getCustomerMeeting(), is(notNullValue()));
    assertThat(center.getCustomerMeetingValue(), is(notNullValue()));
}
Also used : UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerAccountBuilder(org.mifos.domain.builders.CustomerAccountBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Example 12 with CalendarEventBuilder

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

the class UpdateCustomerMeetingScheduleTest method givenDayOfWeekIsDifferentShouldRegenerateSchedules.

@Test
public void givenDayOfWeekIsDifferentShouldRegenerateSchedules() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    DateTime mondayTwoWeeksAgo = new DateTime().withDayOfWeek(DayOfWeek.monday()).minusWeeks(2);
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(mondayTwoWeeksAgo).build();
    weeklyMeeting.updateDetails(userContext);
    CustomerAccountBuilder accountBuilder = new CustomerAccountBuilder();
    CenterBO center = new CenterBuilder().active().with(weeklyMeeting).withAccount(accountBuilder).build();
    MeetingBO weeklyWednesdayMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).occuringOnA(WeekDay.WEDNESDAY).build();
    weeklyWednesdayMeeting.updateDetails(userContext);
    // stubbing
    when(holidayDao.findCalendarEventsForThisYearAndNext(anyShort())).thenReturn(new CalendarEventBuilder().build());
    // pre - verification
    assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(center, WeekDay.MONDAY);
    // exercise test
    customerService.updateCustomerMeetingSchedule(weeklyWednesdayMeeting, center);
    // verification
    assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged(center, WeekDay.MONDAY);
    assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(center, WeekDay.WEDNESDAY);
}
Also used : UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerAccountBuilder(org.mifos.domain.builders.CustomerAccountBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Example 13 with CalendarEventBuilder

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

the class CenterCreationTest method createsCenterWithCustomerAccount.

@Test
public void createsCenterWithCustomerAccount() throws Exception {
    // setup
    OfficeBO withOffice = new OfficeBO(new Short("1"), "testOffice", new Integer("1"), new Short("1"));
    CenterBO center = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).with(withOffice).build();
    center.setCustomerDao(customerDao);
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    // stub
    CalendarEvent upcomingCalendarEvents = new CalendarEventBuilder().build();
    when(holidayDao.findCalendarEventsForThisYearAndNext((short) 1)).thenReturn(upcomingCalendarEvents);
    when(customerAccountFactory.create(center, accountFees, meeting, upcomingCalendarEvents)).thenReturn(customerAccount);
    when(customerAccount.getType()).thenReturn(AccountTypes.CUSTOMER_ACCOUNT);
    // exercise test
    customerService.createCenter(center, meeting, accountFees);
    // verification
    assertThat(center.getCustomerAccount(), is(customerAccount));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) CalendarEvent(org.mifos.calendar.CalendarEvent) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Example 14 with CalendarEventBuilder

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

the class CenterCreationTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs.

@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs() throws Exception {
    // setup
    CenterBO center = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).build();
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    // stub
    CalendarEvent upcomingCalendarEvents = new CalendarEventBuilder().build();
    when(holidayDao.findCalendarEventsForThisYearAndNext((short) 1)).thenReturn(upcomingCalendarEvents);
    when(customerAccountFactory.create(center, accountFees, meeting, upcomingCalendarEvents)).thenReturn(customerAccount);
    when(customerAccount.getType()).thenReturn(AccountTypes.CUSTOMER_ACCOUNT);
    // stub
    doThrow(new RuntimeException()).when(customerDao).save(center);
    // exercise test
    customerService.createCenter(center, meeting, accountFees);
    // verification
    verify(hibernateTransaction).rollbackTransaction();
    verify(hibernateTransaction).closeSession();
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) CalendarEvent(org.mifos.calendar.CalendarEvent) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Example 15 with CalendarEventBuilder

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

the class UpdateCustomerMeetingScheduleTest method givenLsimIsEnabledShouldNotRegenerateSchedulesForLoanAccountsButShouldRegenerateSchedulesForCustomerAndSavingsAccounts.

@Test
public void givenLsimIsEnabledShouldNotRegenerateSchedulesForLoanAccountsButShouldRegenerateSchedulesForCustomerAndSavingsAccounts() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    DateTime mondayTwoWeeksAgo = new DateTime().withDayOfWeek(DayOfWeek.monday()).minusWeeks(2);
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(mondayTwoWeeksAgo).build();
    weeklyMeeting.updateDetails(userContext);
    CustomerAccountBuilder accountBuilder = new CustomerAccountBuilder();
    CenterBO center = new CenterBuilder().active().with(weeklyMeeting).withAccount(accountBuilder).withAccount(this.loanAccount).build();
    MeetingBO weeklyWednesdayMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).occuringOnA(WeekDay.WEDNESDAY).build();
    weeklyWednesdayMeeting.updateDetails(userContext);
    // stubbing
    CalendarEvent calendarEvent = new CalendarEventBuilder().build();
    when(holidayDao.findCalendarEventsForThisYearAndNext(anyShort())).thenReturn(calendarEvent);
    when(configurationHelper.isLoanScheduleRepaymentIndependentOfCustomerMeetingEnabled()).thenReturn(true);
    // pre - verification
    assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(center, WeekDay.MONDAY);
    // exercise test
    customerService.updateCustomerMeetingSchedule(weeklyWednesdayMeeting, center);
    // verification
    assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged(center, WeekDay.MONDAY);
    assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(center, WeekDay.WEDNESDAY);
}
Also used : UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerAccountBuilder(org.mifos.domain.builders.CustomerAccountBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) CalendarEvent(org.mifos.calendar.CalendarEvent) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) 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