Search in sources :

Example 96 with OfficeBO

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

Example 97 with OfficeBO

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();
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) Test(org.junit.Test)

Example 98 with OfficeBO

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));
    }
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) Test(org.junit.Test)

Example 99 with OfficeBO

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();
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) Before(org.junit.Before)

Example 100 with OfficeBO

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)));
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) 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) GroupBO(org.mifos.customers.group.business.GroupBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Aggregations

OfficeBO (org.mifos.customers.office.business.OfficeBO)115 Test (org.junit.Test)62 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)45 DateTime (org.joda.time.DateTime)33 ArrayList (java.util.ArrayList)31 MeetingBO (org.mifos.application.meeting.business.MeetingBO)28 UserContext (org.mifos.security.util.UserContext)25 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)23 CenterBO (org.mifos.customers.center.business.CenterBO)21 CenterBuilder (org.mifos.domain.builders.CenterBuilder)21 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)19 MifosUser (org.mifos.security.MifosUser)18 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)17 Address (org.mifos.framework.business.util.Address)17 GroupBO (org.mifos.customers.group.business.GroupBO)16 OfficePersistence (org.mifos.customers.office.persistence.OfficePersistence)16 MifosRuntimeException (org.mifos.core.MifosRuntimeException)14 ClientBO (org.mifos.customers.client.business.ClientBO)14 GroupBuilder (org.mifos.domain.builders.GroupBuilder)14 AddressDto (org.mifos.dto.domain.AddressDto)13