Search in sources :

Example 96 with PersonnelBO

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();
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) GroupUpdateBuilder(org.mifos.domain.builders.GroupUpdateBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) GroupUpdate(org.mifos.dto.domain.GroupUpdate) Test(org.junit.Test)

Example 97 with PersonnelBO

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));
    }
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) Test(org.junit.Test)

Example 98 with PersonnelBO

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));
}
Also used : CustomerStatusUpdate(org.mifos.application.servicefacade.CustomerStatusUpdate) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) LocalDate(org.joda.time.LocalDate) CustomerStatusUpdateBuilder(org.mifos.domain.builders.CustomerStatusUpdateBuilder) Test(org.junit.Test)

Example 99 with PersonnelBO

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));
}
Also used : CustomerStatusUpdate(org.mifos.application.servicefacade.CustomerStatusUpdate) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerStatusUpdateBuilder(org.mifos.domain.builders.CustomerStatusUpdateBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 100 with PersonnelBO

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);
}
Also used : Address(org.mifos.framework.business.util.Address) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) Date(java.util.Date) Name(org.mifos.framework.business.util.Name)

Aggregations

PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)239 Test (org.junit.Test)91 UserContext (org.mifos.security.util.UserContext)65 ArrayList (java.util.ArrayList)62 Money (org.mifos.framework.util.helpers.Money)46 MifosRuntimeException (org.mifos.core.MifosRuntimeException)44 OfficeBO (org.mifos.customers.office.business.OfficeBO)44 MifosUser (org.mifos.security.MifosUser)44 PersistenceException (org.mifos.framework.exceptions.PersistenceException)41 Date (java.util.Date)39 LocalDate (org.joda.time.LocalDate)37 AccountException (org.mifos.accounts.exceptions.AccountException)37 DateTime (org.joda.time.DateTime)36 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)34 BusinessRuleException (org.mifos.service.BusinessRuleException)33 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)31 MeetingBO (org.mifos.application.meeting.business.MeetingBO)30 CustomerBO (org.mifos.customers.business.CustomerBO)27 ServiceException (org.mifos.framework.exceptions.ServiceException)27 LoanBO (org.mifos.accounts.loan.business.LoanBO)25