use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class CenterCreationUsingCustomerServiceIntegrationTest method canCreateCenterWithMinimalDetails.
@Test
public void canCreateCenterWithMinimalDetails() throws Exception {
// setup
// minimal details
String centerName = "Center-IntegrationTest";
OfficeBO existingBranch = sampleBranchOffice();
PersonnelBO existingLoanOfficer = testUser();
MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
DateTime today = new DateTime();
Address noAddress = null;
String noExternalId = null;
CenterBO center = new CenterBuilder().withName(centerName).with(weeklyMeeting).with(existingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(today).with(noAddress).withExternalId(noExternalId).withUserContext().build();
List<AccountFeesEntity> noAccountFees = new ArrayList<AccountFeesEntity>();
// exercise test
customerService.createCenter(center, weeklyMeeting, noAccountFees);
// verification
assertThat(center.getCustomerId(), is(notNullValue()));
assertThat(center.getGlobalCustNum(), is(notNullValue()));
assertThat(center.getExternalId(), is(nullValue()));
assertThat(center.getAddress(), is(nullValue()));
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class CenterHierarchyCustomerServiceIntegrationTest method cleanDatabaseTables.
@Before
public void cleanDatabaseTables() {
databaseCleaner.clean();
// setup
String centerName = "Center-IntegrationTest";
OfficeBO existingBranch = sampleBranchOffice();
PersonnelBO existingLoanOfficer = testUser();
MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
DateTime today = new DateTime();
Address noAddress = null;
String noExternalId = null;
center = new CenterBuilder().withName(centerName).with(weeklyMeeting).with(existingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(today).with(noAddress).withExternalId(noExternalId).withUserContext().build();
IntegrationTestObjectMother.createCenter(center, center.getCustomerMeetingValue());
group = new GroupBuilder().withName("group1").withParentCustomer(center).active().formedBy(center.getPersonnel()).build();
IntegrationTestObjectMother.createGroup(group, group.getCustomerMeetingValue());
group2 = new GroupBuilder().withName("group2").withParentCustomer(center).active().formedBy(center.getPersonnel()).build();
IntegrationTestObjectMother.createGroup(group2, group2.getCustomerMeetingValue());
otherLoanOfficer = new PersonnelBuilder().withDisplayName("otherLoanOfficer").with(existingBranch).build();
IntegrationTestObjectMother.createPersonnel(otherLoanOfficer);
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class GroupTransferToCenterTest method transferingGroupToCenterInSameBranchShouldModifyGroupToHaveSameLoanOfficerAsReceivingCenter.
@Test
public void transferingGroupToCenterInSameBranchShouldModifyGroupToHaveSameLoanOfficerAsReceivingCenter() throws Exception {
PersonnelBO loanOfficer = new PersonnelBuilder().withDisplayName("old loan officer").build();
CenterBO fromCenter = new CenterBuilder().withName("fromCenter").withLoanOfficer(loanOfficer).build();
GroupBO groupForTransfer = new GroupBuilder().withParentCustomer(fromCenter).active().build();
PersonnelBO newLoanOfficer = new PersonnelBuilder().withDisplayName("loan officer").build();
CenterBO receivingCenter = new CenterBuilder().withName("receivingCenter").withLoanOfficer(newLoanOfficer).build();
// pre-verification
assertThat(receivingCenter.getPersonnel().getDisplayName(), is("loan officer"));
assertThat(groupForTransfer.getPersonnel().getDisplayName(), is("old loan officer"));
// exercise test
groupForTransfer.transferTo(receivingCenter);
// verification
assertThat(receivingCenter.getPersonnel().getDisplayName(), is("loan officer"));
assertThat(groupForTransfer.getPersonnel().getDisplayName(), is("loan officer"));
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class GroupUpdateTest method updatesLoanOfficerForAllChildrenAndThierAccountsWhenLoanOfficerIsUpdated.
@Test
public void updatesLoanOfficerForAllChildrenAndThierAccountsWhenLoanOfficerIsUpdated() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
GroupUpdate groupUpdate = new GroupUpdateBuilder().build();
PersonnelBO newLoanOfficer = new PersonnelBuilder().anyLoanOfficer();
// stubbing
when(customerDao.findGroupBySystemId(groupUpdate.getGlobalCustNum())).thenReturn(mockedGroup);
when(mockedGroup.isNameDifferent(groupUpdate.getDisplayName())).thenReturn(false);
when(personnelDao.findPersonnelById(groupUpdate.getLoanOfficerId())).thenReturn(newLoanOfficer);
when(mockedGroup.isLoanOfficerChanged(newLoanOfficer)).thenReturn(true);
when(mockedGroup.getOffice()).thenReturn(new OfficeBuilder().build());
// exercise test
customerService.updateGroup(userContext, groupUpdate);
// verification
verify(mockedGroup).setLoanOfficer(newLoanOfficer);
verify(mockedGroup).validate();
verify(customerDao).updateLoanOfficersForAllChildrenAndAccounts(anyShort(), anyString(), anyShort());
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class GroupUpdateTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs.
@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
GroupUpdate groupUpdate = new GroupUpdateBuilder().build();
PersonnelBO newLoanOfficer = new PersonnelBuilder().anyLoanOfficer();
// stubbing
when(customerDao.findGroupBySystemId(groupUpdate.getGlobalCustNum())).thenReturn(mockedGroup);
when(mockedGroup.isNameDifferent(groupUpdate.getDisplayName())).thenReturn(false);
when(personnelDao.findPersonnelById(groupUpdate.getLoanOfficerId())).thenReturn(newLoanOfficer);
when(mockedGroup.isLoanOfficerChanged(newLoanOfficer)).thenReturn(false);
when(mockedGroup.getOffice()).thenReturn(new OfficeBuilder().build());
// stub
doThrow(new RuntimeException()).when(customerDao).save(mockedGroup);
// exercise test
customerService.updateGroup(userContext, groupUpdate);
// verification
verify(hibernateTransactionHelper).rollbackTransaction();
verify(hibernateTransactionHelper).closeSession();
}
Aggregations