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