use of org.mifos.domain.builders.OfficeBuilder 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.domain.builders.OfficeBuilder 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)));
}
use of org.mifos.domain.builders.OfficeBuilder in project head by mifos.
the class CustomerStatusUpdateTest method throwsCheckedExceptionWhenCenterTransitionsToInActiveStateAndFailsValidation.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenCenterTransitionsToInActiveStateAndFailsValidation() throws Exception {
// setup
OfficeBO office = new OfficeBuilder().withGlobalOfficeNum("xxx-9999").build();
UserContext userContext = TestUtils.makeUser();
CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().with(CustomerStatus.CENTER_INACTIVE).build();
// stubbing
when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(mockedCenter);
when(mockedCenter.getOffice()).thenReturn(office);
when(mockedCenter.getCustomerStatus()).thenReturn(new CustomerStatusEntity(CustomerStatus.CENTER_ACTIVE));
doThrow(new CustomerException(CustomerConstants.CENTER_STATE_CHANGE_EXCEPTION)).when(mockedCenter).validateChangeToInActive();
// exercise test
customerService.updateCustomerStatus(userContext, customerStatusUpdate);
// verification
verify(mockedCenter).validateChangeToInActive();
}
use of org.mifos.domain.builders.OfficeBuilder in project head by mifos.
the class CenterValidationTest 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.domain.builders.OfficeBuilder in project head by mifos.
the class GroupTransferToCenterTest method transferingGroupToCenterInDifferentBranchCreatesNewCustomerMovementsForGroupAndChangesGroupStatusFromActiveToOnHold.
@Test
public void transferingGroupToCenterInDifferentBranchCreatesNewCustomerMovementsForGroupAndChangesGroupStatusFromActiveToOnHold() throws Exception {
// setup
OfficeBO fromBranch = new OfficeBuilder().branchOffice().withName("fromBranch").withGlobalOfficeNum("xxx1").build();
CenterBO fromCenter = new CenterBuilder().withName("fromCenter").with(fromBranch).build();
GroupBO groupForTransfer = new GroupBuilder().withParentCustomer(fromCenter).active().build();
OfficeBO receivingBranch = new OfficeBuilder().branchOffice().withName("receivingBranch").withGlobalOfficeNum("xxx2").build();
CenterBO receivingCenter = new CenterBuilder().withName("receivingCenter").with(receivingBranch).build();
// exercise test
groupForTransfer.transferTo(receivingCenter);
// verification
assertThat(groupForTransfer.getStatus().isGroupActive(), is(false));
assertThat(groupForTransfer.getStatus().isGroupOnHold(), is(true));
assertThat(groupForTransfer.countOfCustomerMovements(), is(2));
}
Aggregations