Search in sources :

Example 96 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class CustomerAccountCreationTest method customerAccountIsNotCreatedWithCustomerSchedulesWhenAssociatedCustomerIsNotActive.

@Test
public void customerAccountIsNotCreatedWithCustomerSchedulesWhenAssociatedCustomerIsNotActive() throws Exception {
    // setup
    accountFees = new ArrayList<AccountFeesEntity>();
    customer = new CenterBuilder().inActive().build();
    // exercise test
    customerAccount = CustomerAccountBO.createNew(customer, accountFees, customerMeeting, applicableCalendarEvents);
    // verification
    assertThat(customerAccount.getAccountActionDates().isEmpty(), is(true));
}
Also used : CenterBuilder(org.mifos.domain.builders.CenterBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 97 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class GroupTransferToCenterServiceTest method rollsbackTransactionOnException.

@Test(expected = RuntimeException.class)
public void rollsbackTransactionOnException() throws Exception {
    // setup
    CenterBO toCenter = new CenterBuilder().build();
    // stubbing
    when(group.isDifferentBranch(toCenter.getOffice())).thenReturn(false);
    when(group.getUserContext()).thenReturn(TestUtils.makeUser());
    doThrow(new RuntimeException()).when(customerDao).save(group);
    // exercise test
    customerService.transferGroupTo(group, toCenter);
    // verification
    verify(hibernateTransaction).rollbackTransaction();
}
Also used : CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) Test(org.junit.Test)

Example 98 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class GroupTransferToCenterServiceTest method validatesGroupNameIsNotAlreadyTakenWhenTransferingGroupToDifferentOffice.

@Test(expected = CustomerException.class)
public void validatesGroupNameIsNotAlreadyTakenWhenTransferingGroupToDifferentOffice() throws Exception {
    // setup
    CenterBO toCenter = new CenterBuilder().build();
    // stubbing
    when(group.isDifferentBranch(toCenter.getOffice())).thenReturn(true);
    doThrow(new CustomerException(CustomerConstants.ERRORS_DUPLICATE_CUSTOMER)).when(customerDao).validateGroupNameIsNotTakenForOffice(anyString(), eq(toCenter.getOfficeId()));
    // exercise test
    customerService.transferGroupTo(group, toCenter);
    // verification
    verify(customerDao).validateGroupNameIsNotTakenForOffice(anyString(), eq(toCenter.getOfficeId()));
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) Test(org.junit.Test)

Example 99 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class GroupTransferToCenterServiceTest method transfersGroupToReceivingCenter.

@Test
public void transfersGroupToReceivingCenter() throws Exception {
    // setup
    CenterBO toCenter = new CenterBuilder().build();
    // stubbing
    when(group.isDifferentBranch(toCenter.getOffice())).thenReturn(false);
    when(group.getUserContext()).thenReturn(TestUtils.makeUser());
    // exercise test
    customerService.transferGroupTo(group, toCenter);
    // verification
    verify(group).transferTo(toCenter);
}
Also used : CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) Test(org.junit.Test)

Example 100 with CenterBuilder

use of org.mifos.domain.builders.CenterBuilder in project head by mifos.

the class SavingsScheduleIntegrationTest method createClientSavingsAccount.

public void createClientSavingsAccount() throws Exception {
    meeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(expectedFirstDepositDate).build();
    IntegrationTestObjectMother.saveMeeting(meeting);
    center = new CenterBuilder().with(meeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter(center, meeting);
    group = new GroupBuilder().withMeeting(meeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, meeting);
    client = new ClientBuilder().withMeeting(meeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, meeting);
    savingsProduct = new SavingsProductBuilder().mandatory().appliesToClientsOnly().buildForIntegrationTests();
    HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
    List<Holiday> holidays = holidayDao.findAllHolidaysThisYearAndNext(client.getOfficeId());
    savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(client).with(holidays).build();
    IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) Holiday(org.mifos.application.holiday.business.Holiday) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) HolidayDao(org.mifos.application.holiday.persistence.HolidayDao) ClientBuilder(org.mifos.domain.builders.ClientBuilder)

Aggregations

CenterBuilder (org.mifos.domain.builders.CenterBuilder)123 Test (org.junit.Test)98 CenterBO (org.mifos.customers.center.business.CenterBO)82 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)73 MeetingBO (org.mifos.application.meeting.business.MeetingBO)54 GroupBuilder (org.mifos.domain.builders.GroupBuilder)53 DateTime (org.joda.time.DateTime)52 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)46 ArrayList (java.util.ArrayList)42 GroupBO (org.mifos.customers.group.business.GroupBO)36 ClientBuilder (org.mifos.domain.builders.ClientBuilder)30 OfficeBO (org.mifos.customers.office.business.OfficeBO)21 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)19 CustomerException (org.mifos.customers.exceptions.CustomerException)18 FeeBuilder (org.mifos.domain.builders.FeeBuilder)18 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)17 LocalDate (org.joda.time.LocalDate)14 Before (org.junit.Before)14 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)13 ClientBO (org.mifos.customers.client.business.ClientBO)13