use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class CustSearchActionStrutsTest method testLoadMainSearchNonLoBoUser.
@Test
public void testLoadMainSearchNonLoBoUser() throws Exception {
OfficeBO officeBO = TestObjectFactory.getOffice(TestObjectFactory.SAMPLE_BRANCH_OFFICE);
PersonnelBO personnelBO = TestObjectFactory.createPersonnel(PersonnelLevel.NON_LOAN_OFFICER, officeBO, Integer.valueOf("1"), Short.valueOf("1"), "1234", "raj", null, null, null, new Name("abe", null, null, null), null, new Date(), null, Integer.valueOf("1"), null, null, null, new Date(), new HashSet());
userContext.setId(personnelBO.getPersonnelId());
addActionAndMethod(Methods.loadMainSearch.toString());
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward(CustomerSearchConstants.LOADFORWARDNONLOANOFFICER_SUCCESS);
List<PersonnelBO> personnelList = (List<PersonnelBO>) SessionUtils.getAttribute(CustomerSearchConstants.LOANOFFICERSLIST, request);
Assert.assertNotNull(personnelList);
Assert.assertEquals(1, personnelList.size());
Assert.assertEquals(officeBO.getOfficeName(), SessionUtils.getAttribute(CustomerSearchConstants.OFFICE, request));
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class ApplyHolidayChangesHelperIntegrationTest method createOfficeHolidayTestData.
private void createOfficeHolidayTestData(DateTime startDate) throws Exception {
/*
* When startDate is 'yesterday' Head Office Holiday: from 2010-02-22 thru 2010-03-01 ... repayment rule is next
* meeting date Branch Holiday:
*
* from 2010-03-08 thru 2010-03-22 ... moratorium
*
* One more holiday that should not affect any schedules
*/
// Creating Office Holidays
Set<HolidayBO> holidays;
OfficeBO headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
holidays = new HashSet<HolidayBO>();
holidays.add((HolidayBO) new HolidayBuilder().withName("HO Holiday").from(startDate).to(startDate.plusWeeks(1)).withRepaymentRule(RepaymentRuleTypes.NEXT_MEETING_OR_REPAYMENT).build());
headOffice.setHolidays(holidays);
IntegrationTestObjectMother.createOffice(headOffice);
OfficeBO centerOffice = testSaveCollectionSheetUtils.getCenter().getOffice();
holidays = new HashSet<HolidayBO>();
holidays.add((HolidayBO) new HolidayBuilder().withName("Center Hierarchy Holiday").from(startDate.plusWeeks(2)).to(startDate.plusWeeks(4)).withRepaymentMoratoriumRule().build());
centerOffice.setHolidays(holidays);
IntegrationTestObjectMother.createOffice(centerOffice);
// builder not setting searchId correctly due to not going thru office.save (which uses HierarchyManager)
String headOfficeSearchId = headOffice.getSearchId();
OfficeBO anotherOffice = new OfficeBuilder().withParentOffice(headOffice).withName("Another Office").withSearchId(headOfficeSearchId + "26.").withGlobalOfficeNum("n/a001").build();
holidays = new HashSet<HolidayBO>();
holidays.add((HolidayBO) new HolidayBuilder().withName("N/A").from(startDate.minusWeeks(3)).to(startDate.plusWeeks(8)).withRepaymentMoratoriumRule().build());
anotherOffice.setHolidays(holidays);
IntegrationTestObjectMother.createOffice(anotherOffice);
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class IntegrationTestObjectMotherBuilderDsl method anExistingBranchOffice.
public static OfficeBO anExistingBranchOffice(OfficeBuilder aBranchOffice) {
OfficeBO headOffice = new OfficeBuilder().withGlobalOfficeNum("xxxx-001").withName("builder-head-office").withShortName("hf1").withSearchId("1.1.").headOffice().build();
IntegrationTestObjectMother.createOffice(headOffice);
OfficeBO areaOffice = new OfficeBuilder().withParentOffice(headOffice).withGlobalOfficeNum("xxxx-002").withName("builder-area-office").withShortName("af1").withSearchId("1.1.1.").areaOffice().build();
IntegrationTestObjectMother.createOffice(areaOffice);
OfficeBO branchOffice = aBranchOffice.withParentOffice(areaOffice).branchOffice().build();
IntegrationTestObjectMother.createOffice(branchOffice);
return branchOffice;
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class CustomerSearchIdGenerationTest method transferClientFromOfficeToOfficeTest.
@Test
public void transferClientFromOfficeToOfficeTest() throws Exception {
final short office1_id = 2;
// setup
OfficeBO office1 = new OfficeBuilder().withName("office1").branchOffice().withOfficeId(office1_id).build();
PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
ClientBO existingClient = new ClientBuilder().pendingApproval().withNoParent().withLoanOfficer(loanOfficer).buildForUnitTests();
existingClient.setCustomerDao(customerDao);
existingClient = spy(existingClient);
int customer_id = 22;
when(existingClient.getCustomerId()).thenReturn(customer_id);
existingClient.generateSearchId();
UserContext userContext = TestUtils.makeUser();
existingClient.setUserContext(userContext);
// stubbing
when(customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(office1_id)).thenReturn(3);
// exercise test
assertThat(existingClient.getSearchId(), is("1." + customer_id));
customerService.transferClientTo(existingClient, office1);
// verification
assertThat(existingClient.getSearchId(), is("1." + customer_id));
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class CustomerSearchIdGenerationTest method transferGroupFromOfficeToOfficeTest.
@Test
public void transferGroupFromOfficeToOfficeTest() throws Exception {
final short office1_id = 2;
// setup
OfficeBO office1 = new OfficeBuilder().withName("office1").branchOffice().withOfficeId(office1_id).build();
PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
GroupBO existingGroup = new GroupBuilder().pendingApproval().withLoanOfficer(loanOfficer).buildAsTopOfHierarchy();
existingGroup = spy(existingGroup);
int customer_id = 22;
when(existingGroup.getCustomerId()).thenReturn(customer_id);
existingGroup.generateSearchId();
ClientBO existingClient = new ClientBuilder().pendingApproval().withParentCustomer(existingGroup).buildForUnitTests();
existingGroup.addChild(existingClient);
existingGroup.setCustomerDao(customerDao);
UserContext userContext = TestUtils.makeUser();
existingGroup.setUserContext(userContext);
// stubbing
when(customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(office1_id)).thenReturn(3);
// exercise test
assertThat(existingGroup.getSearchId(), is("1." + customer_id));
assertThat(existingClient.getSearchId(), is("1." + customer_id + ".1"));
customerService.transferGroupTo(existingGroup, office1);
// verification
assertThat(existingGroup.getSearchId(), is("1." + customer_id));
assertThat(existingClient.getSearchId(), is("1." + customer_id + ".1"));
}
Aggregations