Search in sources :

Example 41 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO 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 42 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO 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 43 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO 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)

Example 44 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class CustomerStatusUpdateTest method updateDetailsAreSetWhenUpdatingCustomerStatus.

@Test
public void updateDetailsAreSetWhenUpdatingCustomerStatus() throws Exception {
    // setup
    OfficeBO office = new OfficeBuilder().withGlobalOfficeNum("xxx-9999").build();
    UserContext userContext = TestUtils.makeUser();
    CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().build();
    // stubbing
    when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(mockedCenter);
    when(mockedCenter.getOffice()).thenReturn(office);
    when(mockedCenter.getCustomerStatus()).thenReturn(new CustomerStatusEntity(CustomerStatus.CENTER_ACTIVE));
    // exercise test
    customerService.updateCustomerStatus(userContext, customerStatusUpdate);
    // verification
    verify(mockedCenter).updateDetails(userContext);
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) 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 45 with OfficeBO

use of org.mifos.customers.office.business.OfficeBO in project head by mifos.

the class OfficeDaoHibernateIntegrationTest method createOfficeHierarchy.

private void createOfficeHierarchy() {
    // A default head office is added as seed data for integration tests along with a 'TestAreaOffice' as child
    headOffice = IntegrationTestObjectMother.findOfficeById(Short.valueOf("1"));
    regionalOffice = new OfficeBuilder().withGlobalOfficeNum("002").withName("region1").regionalOffice().withParentOffice(headOffice).build();
    IntegrationTestObjectMother.createOffice(regionalOffice);
    OfficeBO subRegionalOffice = new OfficeBuilder().withGlobalOfficeNum("003").withName("sub1-of-region1").subRegionalOffice().withParentOffice(regionalOffice).build();
    IntegrationTestObjectMother.createOffice(subRegionalOffice);
    areaOffice = new OfficeBuilder().withGlobalOfficeNum("004").withName("area-of-sub1-regional").areaOffice().withParentOffice(subRegionalOffice).build();
    IntegrationTestObjectMother.createOffice(areaOffice);
    branch1 = new OfficeBuilder().withGlobalOfficeNum("005").withName("branch1-of-area").branchOffice().withParentOffice(areaOffice).build();
    IntegrationTestObjectMother.createOffice(branch1);
    branch2 = new OfficeBuilder().withGlobalOfficeNum("006").withName("branch2-of-area").branchOffice().withParentOffice(areaOffice).build();
    IntegrationTestObjectMother.createOffice(branch2);
    branch3 = new OfficeBuilder().withGlobalOfficeNum("007").withName("branch1-of-regional").branchOffice().withParentOffice(regionalOffice).build();
    IntegrationTestObjectMother.createOffice(branch3);
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO)

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