Search in sources :

Example 36 with MeetingBuilder

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

the class UpdateCustomerMeetingScheduleTest method throwsCheckedExceptionWhenCustomerIsNotTopOfCustomerHierarchy.

@Test(expected = BusinessRuleException.class)
public void throwsCheckedExceptionWhenCustomerIsNotTopOfCustomerHierarchy() throws Exception {
    // setup
    MeetingBO newMeeting = new MeetingBuilder().build();
    // stubbing
    doThrow(new BusinessRuleException(CustomerConstants.INVALID_MEETING)).when(mockedCenter).validateIsTopOfHierarchy();
    // exercise test
    customerService.updateCustomerMeetingSchedule(newMeeting, mockedCenter);
    // verification
    verify(mockedCenter).validateIsTopOfHierarchy();
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) Test(org.junit.Test)

Example 37 with MeetingBuilder

use of org.mifos.domain.builders.MeetingBuilder 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 38 with MeetingBuilder

use of org.mifos.domain.builders.MeetingBuilder 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 39 with MeetingBuilder

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

the class CenterCreationUsingCustomerServiceIntegrationTest method canNotCreateCenterWithNameOfAlreadyExistingCenter.

@Test(expected = BusinessRuleException.class)
public void canNotCreateCenterWithNameOfAlreadyExistingCenter() throws Exception {
    // minimal details
    MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
    String centerName = "existingCenterName";
    OfficeBO anExistingBranch = sampleBranchOffice();
    PersonnelBO existingLoanOfficer = testUser();
    DateTime aWeekFromNow = new DateTime().plusWeeks(1);
    CenterBO existingCenter = new CenterBuilder().withName(centerName).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
    IntegrationTestObjectMother.createCenter(existingCenter, existingCenter.getCustomerMeetingValue());
    CenterBO newCenter = new CenterBuilder().withName(existingCenter.getDisplayName()).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
    // setup
    List<AccountFeesEntity> noCenterAccountFees = new ArrayList<AccountFeesEntity>();
    // exercise test
    customerService.createCenter(newCenter, newCenter.getCustomerMeetingValue(), noCenterAccountFees);
    // verification
    assertThat(existingCenter.getGlobalCustNum(), is(not(newCenter.getGlobalCustNum())));
    assertThat(existingCenter.getDisplayName(), is(newCenter.getDisplayName()));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 40 with MeetingBuilder

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

the class CenterCreationUsingCustomerServiceIntegrationTest method canCreateCenterWithAddress.

@Test
public void canCreateCenterWithAddress() throws Exception {
    // minimal details
    MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
    String centerName = "Center-IntegrationTest";
    OfficeBO anExistingBranch = sampleBranchOffice();
    PersonnelBO existingLoanOfficer = testUser();
    DateTime aWeekFromNow = new DateTime().plusWeeks(1);
    CenterBO center = new CenterBuilder().withName(centerName).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).with(anAddress()).withUserContext().build();
    List<AccountFeesEntity> noAccountFees = new ArrayList<AccountFeesEntity>();
    // exercise test
    customerService.createCenter(center, center.getCustomerMeetingValue(), noAccountFees);
    // verification
    assertThat(center.getCustomerId(), is(notNullValue()));
    assertThat(center.getGlobalCustNum(), is(notNullValue()));
    assertThat(center.getAddress(), is(notNullValue()));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)106 Test (org.junit.Test)74 MeetingBO (org.mifos.application.meeting.business.MeetingBO)74 CenterBuilder (org.mifos.domain.builders.CenterBuilder)73 DateTime (org.joda.time.DateTime)58 ArrayList (java.util.ArrayList)47 CenterBO (org.mifos.customers.center.business.CenterBO)43 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)38 LocalDate (org.joda.time.LocalDate)27 GroupBuilder (org.mifos.domain.builders.GroupBuilder)24 Before (org.junit.Before)21 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)20 FeeBuilder (org.mifos.domain.builders.FeeBuilder)20 OfficeBO (org.mifos.customers.office.business.OfficeBO)19 ClientBuilder (org.mifos.domain.builders.ClientBuilder)15 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)14 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)14 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)13 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)11 Ignore (org.junit.Ignore)10