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));
}
}
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()));
}
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;
}
Aggregations