Search in sources :

Example 31 with OfficeBuilder

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

the class GroupTransferToOfficeServiceTest method givenOfficeIsSameAsGroupsOfficeGroupTransferToBranchShouldFailValidation.

@Test
public void givenOfficeIsSameAsGroupsOfficeGroupTransferToBranchShouldFailValidation() {
    // setup
    OfficeBO office = new OfficeBuilder().build();
    CenterBO parent = new CenterBuilder().with(office).build();
    GroupBO group = new GroupBuilder().withParentCustomer(parent).build();
    // exercise test
    try {
        customerService.transferGroupTo(group, office);
        fail("should fail validation");
    } catch (CustomerException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_SAME_BRANCH_TRANSFER));
    }
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Example 32 with OfficeBuilder

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

the class GroupTransferServiceIntegrationTest method transferingGroupToCenterWithDifferentMeetingDayOfWeekCausesFutureSchedulesToBeRegeneratedForGroup.

@Ignore
@Test
public void transferingGroupToCenterWithDifferentMeetingDayOfWeekCausesFutureSchedulesToBeRegeneratedForGroup() throws Exception {
    // setup
    OfficeBO branchOffice = anExistingBranchOffice(new OfficeBuilder().withGlobalOfficeNum("xxxx-003").withName("builder-branch-office1").withShortName("bf1").withSearchId("1.1.1.1."));
    OfficeBO branchOffice2 = new OfficeBuilder().withParentOffice(branchOffice.getParentOffice()).branchOffice().withGlobalOfficeNum("xxxx-004").withName("builder-branch-office2").withShortName("bf1").withSearchId("1.1.1.2.").build();
    IntegrationTestObjectMother.createOffice(branchOffice2);
    DateTime todaySixWeeksAgo = new DateMidnight().toDateTime().minusWeeks(6);
    MeetingBO weeklyMeeting = aWeeklyMeeting().withLocation("weeklyMeeting-sixWeeksAgo").startingFrom(todaySixWeeksAgo.toDate()).build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    CenterBuilder centerWithWeeklyMeeting = anActiveCenter().withName("center-with-no-children").with(weeklyMeeting).with(branchOffice).withActivationDate(todaySixWeeksAgo).withLoanOfficer(anExistingLoanOfficer());
    CenterBO centerWithNoChildren = anExistingActiveCenter(centerWithWeeklyMeeting);
    DateTime tomorrowTwoWeeksAgo = new DateMidnight().toDateTime().minusWeeks(2).plusDays(1);
    MeetingBO differentWeeklyMeeting = aWeeklyMeeting().withLocation("weeklyMeeting-tomorrow-twoWeeksAgo").withStartDate(tomorrowTwoWeeksAgo.minusWeeks(1)).build();
    IntegrationTestObjectMother.saveMeeting(differentWeeklyMeeting);
    CenterBuilder centerInDifferentBranchWithDifferentMeeting = centerWithWeeklyMeeting.withName("center-with-group").with(branchOffice2).with(differentWeeklyMeeting).withActivationDate(tomorrowTwoWeeksAgo);
    GroupBO groupForTransfer = anExistingGroupUnderCenterInDifferentBranchAs(centerInDifferentBranchWithDifferentMeeting);
    // pre-verification
    assertThat(groupForTransfer.getStatus().isGroupActive(), is(true));
    TestUtils.assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(groupForTransfer, WeekDay.getJodaWeekDay(tomorrowTwoWeeksAgo.getDayOfWeek()));
    // exercise test
    customerService.transferGroupTo(groupForTransfer, centerWithNoChildren);
    // verification
    groupForTransfer = customerDao.findGroupBySystemId(groupForTransfer.getGlobalCustNum());
    assertThat(groupForTransfer.getStatus().isGroupActive(), is(false));
    TestUtils.assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged(groupForTransfer, WeekDay.getJodaWeekDay(tomorrowTwoWeeksAgo.getDayOfWeek()));
//TO-FIX TestUtils.assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(groupForTransfer, WeekDay.getJodaWeekDay(todaySixWeeksAgo.getDayOfWeek()));
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) DateMidnight(org.joda.time.DateMidnight) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 33 with OfficeBuilder

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

the class IntegrationTestObjectMotherBuilderDsl method anExistingGroupUnderCenterInDifferentBranchAs.

public static GroupBO anExistingGroupUnderCenterInDifferentBranchAs(CenterBuilder centerBuilder) {
    OfficeBO office = new OfficeBuilder().withGlobalOfficeNum("xxxx-123").withName("newOffice").build();
    IntegrationTestObjectMother.createOffice(office);
    CenterBO centerAsParent = centerBuilder.build();
    IntegrationTestObjectMother.createCenter(centerAsParent, centerAsParent.getCustomerMeetingValue());
    GroupBO group = anActiveGroup().withParentCustomer(centerAsParent).formedBy(anExistingApplicationUser()).build();
    IntegrationTestObjectMother.createGroup(group, group.getCustomerMeetingValue());
    return group;
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO)

Aggregations

OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)33 OfficeBO (org.mifos.customers.office.business.OfficeBO)23 Test (org.junit.Test)22 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 UserContext (org.mifos.security.util.UserContext)11 GroupBO (org.mifos.customers.group.business.GroupBO)9 GroupBuilder (org.mifos.domain.builders.GroupBuilder)9 CustomerException (org.mifos.customers.exceptions.CustomerException)7 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)7 CenterBuilder (org.mifos.domain.builders.CenterBuilder)6 MeetingBO (org.mifos.application.meeting.business.MeetingBO)5 CenterBO (org.mifos.customers.center.business.CenterBO)5 ClientBO (org.mifos.customers.client.business.ClientBO)4 ClientBuilder (org.mifos.domain.builders.ClientBuilder)4 GroupUpdateBuilder (org.mifos.domain.builders.GroupUpdateBuilder)4 GroupUpdate (org.mifos.dto.domain.GroupUpdate)4 DateTime (org.joda.time.DateTime)3 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)3 DateMidnight (org.joda.time.DateMidnight)2 Before (org.junit.Before)2