use of org.mifos.domain.builders.GroupBuilder in project head by mifos.
the class CenterHierarchyCustomerServiceIntegrationTest method cleanDatabaseTables.
@Before
public void cleanDatabaseTables() {
databaseCleaner.clean();
// setup
String centerName = "Center-IntegrationTest";
OfficeBO existingBranch = sampleBranchOffice();
PersonnelBO existingLoanOfficer = testUser();
MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
DateTime today = new DateTime();
Address noAddress = null;
String noExternalId = null;
center = new CenterBuilder().withName(centerName).with(weeklyMeeting).with(existingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(today).with(noAddress).withExternalId(noExternalId).withUserContext().build();
IntegrationTestObjectMother.createCenter(center, center.getCustomerMeetingValue());
group = new GroupBuilder().withName("group1").withParentCustomer(center).active().formedBy(center.getPersonnel()).build();
IntegrationTestObjectMother.createGroup(group, group.getCustomerMeetingValue());
group2 = new GroupBuilder().withName("group2").withParentCustomer(center).active().formedBy(center.getPersonnel()).build();
IntegrationTestObjectMother.createGroup(group2, group2.getCustomerMeetingValue());
otherLoanOfficer = new PersonnelBuilder().withDisplayName("otherLoanOfficer").with(existingBranch).build();
IntegrationTestObjectMother.createPersonnel(otherLoanOfficer);
}
use of org.mifos.domain.builders.GroupBuilder 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.domain.builders.GroupBuilder 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.domain.builders.GroupBuilder 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.domain.builders.GroupBuilder 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));
}
}
Aggregations