Search in sources :

Example 31 with OfficeBO

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));
    }
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) OfficeBO(org.mifos.customers.office.business.OfficeBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 32 with OfficeBO

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());
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) OfficePersistence(org.mifos.customers.office.persistence.OfficePersistence) Test(org.junit.Test)

Example 33 with OfficeBO

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()));
}
Also used : Address(org.mifos.framework.business.util.Address) UserContext(org.mifos.security.util.UserContext) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) ArrayList(java.util.ArrayList) FeeDto(org.mifos.accounts.fees.business.FeeDto) CenterBO(org.mifos.customers.center.business.CenterBO) Date(java.util.Date) DateTime(org.joda.time.DateTime) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) Test(org.junit.Test)

Example 34 with OfficeBO

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()));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 35 with OfficeBO

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()));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

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