use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class CenterServiceFacadeWebTierIntegrationTest method shouldCreateCenterWithExpectedSearchId.
@Test
public void shouldCreateCenterWithExpectedSearchId() {
MeetingBO meeting = new MeetingBuilder().withStartDate(new DateTime().minusWeeks(2)).build();
MeetingDto meetingDto = meeting.toDto();
String displayName = "testCenter";
String externalId = null;
AddressDto addressDto = new AddressDto("here", "", "", "", "", "", "", "");
PersonnelBO user = IntegrationTestObjectMother.findPersonnelById(Short.valueOf("1"));
Short loanOfficerId = user.getPersonnelId();
List<CreateAccountFeeDto> feesToApply = new ArrayList<CreateAccountFeeDto>();
CustomerStatus.GROUP_ACTIVE.getValue();
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
// setup
createOfficeHierarchyUnderHeadOffice(headOffice);
Short officeId = branch1.getOfficeId();
DateTime mfiJoiningDate = new DateTime().minusWeeks(2);
new DateTime().minusWeeks(1);
CenterCreationDetail centerCreationDetail = new CenterCreationDetail(mfiJoiningDate.toLocalDate(), displayName, externalId, addressDto, loanOfficerId, officeId, feesToApply);
// exercise test
CustomerDetailsDto newlyCreatedCenterDetails = centerServiceFacade.createNewCenter(centerCreationDetail, meetingDto);
// verification
CenterBO center = customerDao.findCenterBySystemId(newlyCreatedCenterDetails.getGlobalCustNum());
Assert.assertThat(center.getSearchId(), is("1." + center.getCustomerId()));
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class HolidayDaoHibernateIntegrationTest method shouldThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDifferFromPreviousParentOffice.
@Test
public void shouldThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDifferFromPreviousParentOffice() throws Exception {
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
// setup
createOfficeHierarchyUnderHeadOffice(headOffice);
DateTime tomorrow = new DateTime().plusDays(1);
HolidayDetails holidayDetails = new HolidayBuilder().withName("areaOffice2Holiday").from(tomorrow).to(tomorrow).buildDto();
IntegrationTestObjectMother.createHoliday(holidayDetails, Arrays.asList(areaOffice2.getOfficeId()));
HolidayDetails branchOnlyHolidayDetails = new HolidayBuilder().withName("branchOnlyHoliday").from(tomorrow).to(tomorrow).buildDto();
IntegrationTestObjectMother.createHoliday(branchOnlyHolidayDetails, Arrays.asList(branch1.getOfficeId()));
// refetch
branch1 = IntegrationTestObjectMother.findOfficeById(branch1.getOfficeId());
// exercise test
try {
holidayDao.validateNoExtraFutureHolidaysApplicableOnParentOffice(branch1.getParentOffice().getOfficeId(), areaOffice2.getOfficeId());
fail("shouldThrowExceptionWhenFutureHolidaysApplicableToNewParentOfficeDifferFromPreviousParentOffice");
} catch (ApplicationException e) {
assertThat(e.getKey(), is(OfficeConstants.ERROR_REPARENT_NOT_ALLOWED_AS_FUTURE_APPLICABLE_HOLIDAYS_ARE_DIFFERENT_ON_PREVIOUS_AND_NEW_PARENT));
}
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class HolidayDaoHibernateIntegrationTest method shouldSaveFutureHoliday.
@Test
public void shouldSaveFutureHoliday() throws Exception {
List<Holiday> holidays = holidayDao.findAllHolidaysThisYearAndNext((short) 1);
int initialCount = holidays.size();
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
Holiday futureHoliday = new HolidayBuilder().from(new DateTime()).to(new DateTime().plusDays(1)).appliesTo(headOffice).build();
StaticHibernateUtil.startTransaction();
holidayDao.save(futureHoliday);
StaticHibernateUtil.flushSession();
holidays = holidayDao.findAllHolidaysThisYearAndNext(headOffice.getOfficeId());
assertFalse(holidays.isEmpty());
assertThat(holidays.size() - initialCount, is(1));
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class GroupTransferServiceIntegrationTest method transferingGroupToCenterWithDifferentMeetingDayOfWeekCausesFutureSchedulesToBeRegeneratedForGroupsChildren.
@Ignore
@Test
public void transferingGroupToCenterWithDifferentMeetingDayOfWeekCausesFutureSchedulesToBeRegeneratedForGroupsChildren() 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);
ClientBO child1 = new ClientBuilder().active().withName("client1").withParentCustomer(groupForTransfer).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(child1, child1.getCustomerMeetingValue());
// pre-verification
ClientBO client = customerDao.findClientBySystemId(child1.getGlobalCustNum());
TestUtils.assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(client, WeekDay.getJodaWeekDay(tomorrowTwoWeeksAgo.getDayOfWeek()));
// exercise test
groupForTransfer = customerDao.findGroupBySystemId(groupForTransfer.getGlobalCustNum());
groupForTransfer.setUserContext(TestUtils.makeUser());
customerService.transferGroupTo(groupForTransfer, centerWithNoChildren);
// verification
client = customerDao.findClientBySystemId(child1.getGlobalCustNum());
TestUtils.assertThatAllCustomerSchedulesOccuringBeforeOrOnCurrentInstallmentPeriodRemainUnchanged(client, WeekDay.getJodaWeekDay(tomorrowTwoWeeksAgo.getDayOfWeek()));
// TO-FIX TestUtils.assertThatAllCustomerSchedulesOccuringAfterCurrentInstallmentPeriodFallOnDayOfWeek(client, WeekDay.getJodaWeekDay(todaySixWeeksAgo.getDayOfWeek()));
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class CenterBOIntegrationTest method testSearchIdOnlyUniquePerOffice.
@Test
public void testSearchIdOnlyUniquePerOffice() throws Exception {
Date startDate = new Date();
StaticHibernateUtil.startTransaction();
// In real life, would be another branch rather than an area
OfficeBO branch1 = new OfficePersistence().getOffice(TestObjectFactory.SAMPLE_AREA_OFFICE);
MeetingBO meeting = new MeetingBO(WeekDay.THURSDAY, (short) 1, startDate, MeetingType.CUSTOMER_MEETING, "Delhi");
PersonnelBO systemUser = legacyPersonnelDao.getPersonnel(PersonnelConstants.SYSTEM_USER);
center = new CenterBO(TestUtils.makeUser(), "Center", null, null, null, null, startDate, branch1, meeting, systemUser, new CustomerPersistence());
StaticHibernateUtil.getSessionTL().save(center);
CenterBO center2 = new CenterBO(TestUtils.makeUser(), "center2", null, null, null, null, startDate, new OfficePersistence().getOffice(TestObjectFactory.SAMPLE_BRANCH_OFFICE), meeting, systemUser, new CustomerPersistence());
CenterBO sameBranch = new CenterBO(TestUtils.makeUser(), "sameBranch", null, null, null, null, startDate, branch1, meeting, systemUser, new CustomerPersistence());
StaticHibernateUtil.getSessionTL().save(center);
StaticHibernateUtil.flushSession();
Assert.assertEquals("1.1", center.getSearchId());
Assert.assertEquals("1.1", center2.getSearchId());
Assert.assertEquals("1.2", sameBranch.getSearchId());
}
Aggregations