use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class CenterValidationTest method cannotCreateCenterWithoutABranch.
@Test
public void cannotCreateCenterWithoutABranch() {
// setup
DateTime today = new DateTime();
MeetingBuilder customerMeeting = new MeetingBuilder().customerMeeting();
OfficeBO noBranch = null;
CenterBO center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(customerMeeting).withMfiJoiningDate(today).with(noBranch).build();
// exercise test
try {
center.validate();
fail("cannotCreateCenterWithoutABranch");
} catch (ApplicationException e) {
assertThat(e.getKey(), is(CustomerConstants.INVALID_OFFICE));
}
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class ConfigurationIntegrationTest method testHeadOfficeConfiguration.
@Test
public void testHeadOfficeConfiguration() throws Exception {
OfficeBO headOffice = new OfficePersistence().getHeadOffice();
OfficeConfig officeConfig = configuration.getOfficeConfig(headOffice.getOfficeId());
assertForAccountConfig(officeConfig.getAccountConfig());
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class CustomerCreationDaoHibernateIntegrationTest method testShouldCreateCustomerAndCustomerAccount.
@Test
public void testShouldCreateCustomerAndCustomerAccount() throws Exception {
String displayName = "centerCascade";
Address address = null;
final List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
final List<FeeDto> fees = new ArrayList<FeeDto>();
final String externalId = null;
final Date mfiJoiningDate = new DateTime().minusDays(1).toDate();
final OfficeBO existingOffice = IntegrationTestObjectMother.sampleBranchOffice();
final PersonnelBO loanOfficer = IntegrationTestObjectMother.testUser();
UserContext userContext = new UserContext();
userContext.setId(loanOfficer.getPersonnelId());
userContext.setBranchId(existingOffice.getOfficeId());
userContext.setBranchGlobalNum(existingOffice.getGlobalOfficeNum());
center = new CenterBO(userContext, displayName, address, customFields, fees, externalId, mfiJoiningDate, existingOffice, weeklyMeeting, loanOfficer, new CustomerPersistence());
StaticHibernateUtil.startTransaction();
customerDao.save(center);
StaticHibernateUtil.flushSession();
assertThat(center.getCustomerAccount(), is(notNullValue()));
assertThat(center.getGlobalCustNum(), is(nullValue()));
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class CenterCreationUsingCustomerServiceIntegrationTest method canNotCreateCenterWithNameOfAlreadyExistingCenter.
@Test(expected = BusinessRuleException.class)
public void canNotCreateCenterWithNameOfAlreadyExistingCenter() throws Exception {
// minimal details
MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
String centerName = "existingCenterName";
OfficeBO anExistingBranch = sampleBranchOffice();
PersonnelBO existingLoanOfficer = testUser();
DateTime aWeekFromNow = new DateTime().plusWeeks(1);
CenterBO existingCenter = new CenterBuilder().withName(centerName).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingCenter.getCustomerMeetingValue());
CenterBO newCenter = new CenterBuilder().withName(existingCenter.getDisplayName()).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
// setup
List<AccountFeesEntity> noCenterAccountFees = new ArrayList<AccountFeesEntity>();
// exercise test
customerService.createCenter(newCenter, newCenter.getCustomerMeetingValue(), noCenterAccountFees);
// verification
assertThat(existingCenter.getGlobalCustNum(), is(not(newCenter.getGlobalCustNum())));
assertThat(existingCenter.getDisplayName(), is(newCenter.getDisplayName()));
}
use of org.mifos.customers.office.business.OfficeBO in project head by mifos.
the class CenterCreationUsingCustomerServiceIntegrationTest method canCreateCenterWithAddress.
@Test
public void canCreateCenterWithAddress() throws Exception {
// minimal details
MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
String centerName = "Center-IntegrationTest";
OfficeBO anExistingBranch = sampleBranchOffice();
PersonnelBO existingLoanOfficer = testUser();
DateTime aWeekFromNow = new DateTime().plusWeeks(1);
CenterBO center = new CenterBuilder().withName(centerName).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).with(anAddress()).withUserContext().build();
List<AccountFeesEntity> noAccountFees = new ArrayList<AccountFeesEntity>();
// exercise test
customerService.createCenter(center, center.getCustomerMeetingValue(), noAccountFees);
// verification
assertThat(center.getCustomerId(), is(notNullValue()));
assertThat(center.getGlobalCustNum(), is(notNullValue()));
assertThat(center.getAddress(), is(notNullValue()));
}
Aggregations