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