Search in sources :

Example 21 with CenterBuilder

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

the class CustomerAccountCreationTest method customerAccountIsCreatedWithCustomerSchedulesWhenAssociatedCustomerIsActive.

@Test
public void customerAccountIsCreatedWithCustomerSchedulesWhenAssociatedCustomerIsActive() throws Exception {
    // setup
    applicableCalendarEvents = new CalendarEventBuilder().build();
    customerMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).build();
    accountFees = new ArrayList<AccountFeesEntity>();
    customer = new CenterBuilder().active().build();
    // exercise test
    customerAccount = CustomerAccountBO.createNew(customer, accountFees, customerMeeting, applicableCalendarEvents);
    // verification
    assertThat(customerAccount.getAccountActionDates().isEmpty(), is(false));
}
Also used : CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Example 22 with CenterBuilder

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

the class CustomerAccountCreationTest method givenTriMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent.

@Test
public void givenTriMonthlyFrequencyFirstCustomerScheduleForChildSynchsWithNearestScheduleOfParent() throws Exception {
    // setup
    applicableCalendarEvents = new CalendarEventBuilder().build();
    DateTime tue19thOfApril = new DateTime().withDate(2011, 4, 19);
    DateTime tue26thOfApril = new DateTime().withDate(2011, 4, 26);
    accountFees = new ArrayList<AccountFeesEntity>();
    MeetingBO centerMeeting = new MeetingBuilder().customerMeeting().monthly().every(3).occuringOnA(WeekDay.MONDAY).startingFrom(tue19thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
    MeetingBO groupMeeting = new MeetingBuilder().customerMeeting().monthly().every(3).occuringOnA(WeekDay.MONDAY).startingFrom(tue26thOfApril.minusDays(1).toDate()).onDayOfMonth(18).build();
    CenterBO center = new CenterBuilder().active().withActivationDate(tue19thOfApril).with(centerMeeting).build();
    GroupBO group = new GroupBuilder().active().withParentCustomer(center).withActivationDate(tue26thOfApril).withMeeting(groupMeeting).build();
    // exercise test
    CustomerAccountBO centerAccount = CustomerAccountBO.createNew(center, accountFees, centerMeeting, applicableCalendarEvents);
    CustomerAccountBO groupAccount = CustomerAccountBO.createNew(group, accountFees, groupMeeting, applicableCalendarEvents);
    // verification
    List<AccountActionDateEntity> centerSchedules = new ArrayList<AccountActionDateEntity>(centerAccount.getAccountActionDates());
    List<AccountActionDateEntity> groupSchedules = new ArrayList<AccountActionDateEntity>(groupAccount.getAccountActionDates());
    LocalDate firstCenterDate = new LocalDate(centerSchedules.get(0).getActionDate());
    LocalDate secondCenterDate = new LocalDate(centerSchedules.get(1).getActionDate());
    LocalDate firstGroupDate = new LocalDate(groupSchedules.get(0).getActionDate());
    LocalDate secondGroupDate = new LocalDate(groupSchedules.get(1).getActionDate());
    assertThat(firstGroupDate, is(firstCenterDate));
    assertThat(secondGroupDate, is(secondCenterDate));
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) 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) GroupBO(org.mifos.customers.group.business.GroupBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 23 with CenterBuilder

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

the class CenterValidationTest method cannotCreateCenterWithBlankName.

@Test
public void cannotCreateCenterWithBlankName() {
    // setup
    center = new CenterBuilder().withName("").build();
    // exercise test
    try {
        center.validate();
        fail("cannotCreateCenterWithBlankName");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_SPECIFY_NAME));
    }
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) CenterBuilder(org.mifos.domain.builders.CenterBuilder) Test(org.junit.Test)

Example 24 with CenterBuilder

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

the class CenterValidationTest method cannotCreateCenterWithoutALoanOfficer.

@Test
public void cannotCreateCenterWithoutALoanOfficer() {
    // setup
    PersonnelBO noLoanOfficer = null;
    center = new CenterBuilder().withName("center1").withLoanOfficer(noLoanOfficer).build();
    // exercise test
    try {
        center.validate();
        fail("cannotCreateCenterWithoutALoanOfficer");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_SELECT_LOAN_OFFICER));
    }
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) Test(org.junit.Test)

Example 25 with CenterBuilder

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

the class CenterValidationTest method cannotCreateCenterWithoutAMeeting.

@Test
public void cannotCreateCenterWithoutAMeeting() {
    // setup
    MeetingBuilder noMeetingBuilder = null;
    MeetingBO noMeeting = null;
    center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(noMeeting).with(noMeetingBuilder).build();
    List<AccountFeesEntity> noAccountFees = new ArrayList<AccountFeesEntity>();
    // exercise test
    try {
        center.validateMeetingAndFees(noAccountFees);
        fail("cannotCreateCenterWithoutAMeeting");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_SPECIFY_MEETING));
    }
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Aggregations

CenterBuilder (org.mifos.domain.builders.CenterBuilder)123 Test (org.junit.Test)98 CenterBO (org.mifos.customers.center.business.CenterBO)82 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)73 MeetingBO (org.mifos.application.meeting.business.MeetingBO)54 GroupBuilder (org.mifos.domain.builders.GroupBuilder)53 DateTime (org.joda.time.DateTime)52 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)46 ArrayList (java.util.ArrayList)42 GroupBO (org.mifos.customers.group.business.GroupBO)36 ClientBuilder (org.mifos.domain.builders.ClientBuilder)30 OfficeBO (org.mifos.customers.office.business.OfficeBO)21 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)19 CustomerException (org.mifos.customers.exceptions.CustomerException)18 FeeBuilder (org.mifos.domain.builders.FeeBuilder)18 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)17 LocalDate (org.joda.time.LocalDate)14 Before (org.junit.Before)14 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)13 ClientBO (org.mifos.customers.client.business.ClientBO)13