Search in sources :

Example 31 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class GroupTransferToCenterTest method transferingGroupToCenterInSameBranchCreatesActiveCustomerHierarchyBetweenGroupAndNewParent.

@Test
public void transferingGroupToCenterInSameBranchCreatesActiveCustomerHierarchyBetweenGroupAndNewParent() throws Exception {
    CenterBO fromCenter = new CenterBuilder().withName("fromCenter").build();
    GroupBO groupForTransfer = new GroupBuilder().withParentCustomer(fromCenter).active().build();
    fromCenter.addChild(groupForTransfer);
    CenterBO receivingCenter = new CenterBuilder().withName("receivingCenter").build();
    // pre-verification
    assertThat(receivingCenter.getActiveCustomerHierarchy(), is(nullValue()));
    // exercise test
    groupForTransfer.transferTo(receivingCenter);
    // verification
    assertThat(groupForTransfer.getActiveCustomerHierarchy(), is(notNullValue()));
    assertThat(fromCenter.getActiveCustomerHierarchy(), is(nullValue()));
}
Also used : 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)

Example 32 with GroupBO

use of org.mifos.customers.group.business.GroupBO 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"));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) 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)

Example 33 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class GroupTransferToOfficeServiceTest method givenOfficeIsNullGroupTransferToBranchShouldFailValidation.

@Test
public void givenOfficeIsNullGroupTransferToBranchShouldFailValidation() {
    // setup
    GroupBO group = new GroupBuilder().build();
    OfficeBO office = null;
    // exercise test
    try {
        customerService.transferGroupTo(group, office);
        fail("should fail validation");
    } catch (CustomerException e) {
        assertThat(e.getKey(), is(CustomerConstants.INVALID_OFFICE));
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Example 34 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class GroupTransferToOfficeServiceTest method givenOfficeIsInactiveGroupTransferToBranchShouldFailValidation.

@Test
public void givenOfficeIsInactiveGroupTransferToBranchShouldFailValidation() {
    // setup
    GroupBO group = new GroupBuilder().build();
    OfficeBO office = new OfficeBuilder().inActive().build();
    // exercise test
    try {
        customerService.transferGroupTo(group, office);
        fail("should fail validation");
    } catch (CustomerException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_TRANSFER_IN_INACTIVE_OFFICE));
    }
}
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) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Example 35 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class GroupTransferToOfficeServiceTest method givenOfficeAlreadyHasGroupWithSameNameThenGroupTransferToBranchShouldFailValidation.

@Test
public void givenOfficeAlreadyHasGroupWithSameNameThenGroupTransferToBranchShouldFailValidation() throws Exception {
    // setup
    GroupBO group = new GroupBuilder().withName("already-exists-group").build();
    OfficeBO office = new OfficeBuilder().inActive().build();
    // stubbing
    doThrow(new CustomerException(CustomerConstants.ERRORS_DUPLICATE_CUSTOMER)).when(customerDao).validateGroupNameIsNotTakenForOffice(anyString(), anyShort());
    // exercise test
    try {
        customerService.transferGroupTo(group, office);
        fail("should fail validation");
    } catch (CustomerException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_TRANSFER_IN_INACTIVE_OFFICE));
    }
}
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) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Aggregations

GroupBO (org.mifos.customers.group.business.GroupBO)84 Test (org.junit.Test)56 CenterBO (org.mifos.customers.center.business.CenterBO)45 GroupBuilder (org.mifos.domain.builders.GroupBuilder)42 CenterBuilder (org.mifos.domain.builders.CenterBuilder)36 CustomerException (org.mifos.customers.exceptions.CustomerException)23 ClientBO (org.mifos.customers.client.business.ClientBO)22 ArrayList (java.util.ArrayList)16 OfficeBO (org.mifos.customers.office.business.OfficeBO)16 MeetingBO (org.mifos.application.meeting.business.MeetingBO)15 ClientBuilder (org.mifos.domain.builders.ClientBuilder)15 DateTime (org.joda.time.DateTime)14 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)11 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)11 UserContext (org.mifos.security.util.UserContext)11 LocalDate (org.joda.time.LocalDate)10 MifosRuntimeException (org.mifos.core.MifosRuntimeException)10 ApplicationException (org.mifos.framework.exceptions.ApplicationException)10 Date (java.util.Date)9