use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class GroupValidationTest method givenGroupWithNullMeetingShouldThrowBusinessRuleException.
@Test(expected = BusinessRuleException.class)
public void givenGroupWithNullMeetingShouldThrowBusinessRuleException() {
OfficeBO office = new OfficeBuilder().build();
PersonnelBO loanOfficer = new PersonnelBuilder().asLoanOfficer().build();
group = new GroupBuilder().withName("group-On-branch").withOffice(office).withLoanOfficer(loanOfficer).withMeeting(null).buildAsTopOfHierarchy();
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class GroupValidationTest method givenGroupWithNullParentShouldThrowIllegalArgumentException.
@Test(expected = IllegalArgumentException.class)
public void givenGroupWithNullParentShouldThrowIllegalArgumentException() {
OfficeBO office = new OfficeBuilder().build();
PersonnelBO loanOfficer = new PersonnelBuilder().asLoanOfficer().build();
MeetingBO meeting = new MeetingBuilder().customerMeeting().build();
group = new GroupBuilder().withName("group-On-center").withOffice(office).withLoanOfficer(loanOfficer).withMeeting(meeting).withParentCustomer(null).build();
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class GroupValidationTest method loanOfficerMustBeAssigned.
@Test
public void loanOfficerMustBeAssigned() {
OfficeBO office = new OfficeBuilder().build();
group = new GroupBuilder().withName("group-On-branch").withOffice(office).withLoanOfficer(null).buildAsTopOfHierarchy();
try {
group.validate();
fail("should throw customer exception as loan officer must exist when creating group under a branch.");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_SELECT_LOAN_OFFICER));
}
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class GroupValidationTest method setupDependencies.
@Before
public void setupDependencies() {
OfficeBO office = new OfficeBuilder().build();
PersonnelBO loanOfficer = new PersonnelBuilder().asLoanOfficer().build();
MeetingBO meeting = new MeetingBuilder().customerMeeting().build();
center = new CenterBuilder().with(office).withLoanOfficer(loanOfficer).with(meeting).build();
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class CustomerSearchIdGenerationTest method transferClientFromGroupToGroupTest.
@Test
public void transferClientFromGroupToGroupTest() throws Exception {
final short office1_id = 2;
final Integer group1_id = 33;
final Integer group2_id = 22;
final int group2_child_count = 8;
// setup
UserContext userContext = TestUtils.makeUser();
OfficeBO office1 = new OfficeBuilder().withName("office1").branchOffice().withOfficeId(office1_id).build();
PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
GroupBO existingGroup = new GroupBuilder().pendingApproval().withLoanOfficer(loanOfficer).with(userContext).buildAsTopOfHierarchy();
existingGroup = spy(existingGroup);
when(existingGroup.getCustomerId()).thenReturn(group1_id);
existingGroup.generateSearchId();
ClientBO existingClient = new ClientBuilder().pendingApproval().withParentCustomer(existingGroup).withVersion(1).buildForUnitTests();
existingGroup.addChild(existingClient);
existingGroup.setCustomerDao(customerDao);
GroupBO existingGroup2 = new GroupBuilder().pendingApproval().withLoanOfficer(loanOfficer).with(userContext).withSearchId(group2_child_count).withOffice(office1).buildAsTopOfHierarchy();
existingGroup2.setCustomerDao(customerDao);
existingGroup2 = spy(existingGroup2);
when(existingGroup2.getCustomerId()).thenReturn(group2_id);
existingGroup2.generateSearchId();
// stubbing
when(customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(office1_id)).thenReturn(3);
when(customerDao.findClientBySystemId("clientid")).thenReturn(existingClient);
when(customerDao.findCustomerById(group2_id)).thenReturn(existingGroup2);
when(holidayDao.findCalendarEventsForThisYearAndNext(anyShort())).thenReturn(calendarEvent);
when(configurationHelper.isLoanScheduleRepaymentIndependentOfCustomerMeetingEnabled()).thenReturn(true);
// exercise test
assertThat(existingGroup.getSearchId(), is("1." + group1_id));
assertThat(existingClient.getSearchId(), is("1." + group1_id + ".1"));
customerService.transferClientTo(userContext, group2_id, "clientid", 1);
// verification
assertThat(existingGroup2.getSearchId(), is("1." + group2_id));
assertThat(existingClient.getSearchId(), is("1." + group2_id + "." + (group2_child_count + 1)));
}
Aggregations