use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class GroupUpdateTest method rollsbackTransactionClosesSessionAndReThrowsApplicationException.
@Test(expected = CustomerException.class)
public void rollsbackTransactionClosesSessionAndReThrowsApplicationException() 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 CustomerException(CustomerConstants.ERRORS_DUPLICATE_CUSTOMER)).when(mockedGroup).validate();
// exercise test
customerService.updateGroup(userContext, groupUpdate);
// verification
verify(hibernateTransactionHelper).rollbackTransaction();
verify(hibernateTransactionHelper).closeSession();
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class GroupValidationTest method givenReceivingCenterIsNullShouldFailValidation.
@Test
public void givenReceivingCenterIsNullShouldFailValidation() {
PersonnelBO formedBy = new PersonnelBuilder().build();
group = new GroupBuilder().withName("group-On-center").withParentCustomer(center).formedBy(formedBy).build();
CenterBO toCenter = null;
try {
group.validateReceivingCenter(toCenter);
fail("givenReceivingCenterIsNullShouldThrowCustomerException");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.INVALID_PARENT));
}
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class CustomerStatusUpdateTest method setsActivationDateAndUpdatesCustomerHierarchyWhenTransitioningToActiveForFirstTime.
@Test
public void setsActivationDateAndUpdatesCustomerHierarchyWhenTransitioningToActiveForFirstTime() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().with(CustomerStatus.GROUP_ACTIVE).build();
PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
CenterBO existingCenter = new CenterBuilder().withLoanOfficer(loanOfficer).active().build();
GroupBO existingGroup = new GroupBuilder().pendingApproval().withParentCustomer(existingCenter).withVersion(customerStatusUpdate.getVersionNum()).build();
// stubbing
when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(existingGroup);
// exercise test
customerService.updateCustomerStatus(userContext, customerStatusUpdate);
// verification
assertThat(new LocalDate(existingGroup.getCustomerActivationDate()), is(new LocalDate()));
assertThat((CenterBO) existingGroup.getActiveCustomerHierarchy().getParentCustomer(), is(existingCenter));
assertThat((GroupBO) existingGroup.getActiveCustomerHierarchy().getCustomer(), is(existingGroup));
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class CustomerStatusUpdateTest method updatesPendingChildrenToPartialWhenTransitioningGroupFromPendingToCancelled.
@Test
public void updatesPendingChildrenToPartialWhenTransitioningGroupFromPendingToCancelled() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().with(CustomerStatus.GROUP_CANCELLED).build();
PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
CenterBO existingCenter = new CenterBuilder().withLoanOfficer(loanOfficer).active().build();
GroupBO existingGroup = new GroupBuilder().pendingApproval().withParentCustomer(existingCenter).withVersion(customerStatusUpdate.getVersionNum()).build();
ClientBO existingClient = new ClientBuilder().withParentCustomer(existingGroup).pendingApproval().buildForUnitTests();
existingGroup.addChild(existingClient);
// stubbing
when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(existingGroup);
// exercise test
customerService.updateCustomerStatus(userContext, customerStatusUpdate);
// verification
assertThat(existingGroup.getStatus(), is(CustomerStatus.GROUP_CANCELLED));
assertThat(existingClient.getUserContext(), is(userContext));
assertThat(existingClient.getStatus(), is(CustomerStatus.CLIENT_PARTIAL));
}
use of org.mifos.customers.personnel.business.PersonnelBO in project head by mifos.
the class PersonnelNoteActionStrutsTest method createPersonnelAndSetInSession.
private void createPersonnelAndSetInSession(OfficeBO office, PersonnelLevel personnelLevel) throws Exception {
List<CustomFieldDto> customFieldDto = new ArrayList<CustomFieldDto>();
customFieldDto.add(new CustomFieldDto(Short.valueOf("9"), "123456", CustomFieldType.NUMERIC.getValue()));
Address address = new Address("abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd", "abcd");
Name name = new Name("XYZ", null, null, "Last Name");
Date date = new Date();
personnel = new PersonnelBO(personnelLevel, office, Integer.valueOf("1"), Short.valueOf("1"), "ABCD", "XYZ", "xyz@yahoo.com", null, customFieldDto, name, "111111", date, Integer.valueOf("1"), Integer.valueOf("1"), date, date, address, userContext.getId(), null, null);
IntegrationTestObjectMother.createPersonnel(personnel);
personnel = IntegrationTestObjectMother.findPersonnelById(personnel.getPersonnelId());
SessionUtils.setAttribute(Constants.BUSINESS_KEY, personnel, request);
}
Aggregations