Search in sources :

Example 26 with OfficeBuilder

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();
}
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 27 with OfficeBuilder

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)));
}
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)

Example 28 with OfficeBuilder

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();
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) CustomerStatusUpdate(org.mifos.application.servicefacade.CustomerStatusUpdate) OfficeBO(org.mifos.customers.office.business.OfficeBO) UserContext(org.mifos.security.util.UserContext) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CustomerStatusUpdateBuilder(org.mifos.domain.builders.CustomerStatusUpdateBuilder) Test(org.junit.Test)

Example 29 with OfficeBuilder

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();
}
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 30 with OfficeBuilder

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

Aggregations

OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)33 OfficeBO (org.mifos.customers.office.business.OfficeBO)23 Test (org.junit.Test)22 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 UserContext (org.mifos.security.util.UserContext)11 GroupBO (org.mifos.customers.group.business.GroupBO)9 GroupBuilder (org.mifos.domain.builders.GroupBuilder)9 CustomerException (org.mifos.customers.exceptions.CustomerException)7 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)7 CenterBuilder (org.mifos.domain.builders.CenterBuilder)6 MeetingBO (org.mifos.application.meeting.business.MeetingBO)5 CenterBO (org.mifos.customers.center.business.CenterBO)5 ClientBO (org.mifos.customers.client.business.ClientBO)4 ClientBuilder (org.mifos.domain.builders.ClientBuilder)4 GroupUpdateBuilder (org.mifos.domain.builders.GroupUpdateBuilder)4 GroupUpdate (org.mifos.dto.domain.GroupUpdate)4 DateTime (org.joda.time.DateTime)3 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)3 DateMidnight (org.joda.time.DateMidnight)2 Before (org.junit.Before)2