Search in sources :

Example 86 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class GroupCreationTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs.

@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs() throws Exception {
    // setup
    CenterBO parent = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).build();
    GroupBO stubbedGroup = new GroupBuilder().withName("group").withParentCustomer(parent).formedBy(anyLoanOfficer()).build();
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    // stub
    doThrow(new RuntimeException()).when(customerDao).save(stubbedGroup);
    // exercise test
    customerService.createGroup(stubbedGroup, meeting, accountFees);
    // verification
    verify(hibernateTransactionHelper).rollbackTransaction();
    verify(hibernateTransactionHelper).closeSession();
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Example 87 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class GroupTransferToCenterServiceTest method validatesReceivingCenterWhenTransferingGroup.

@Test(expected = CustomerException.class)
public void validatesReceivingCenterWhenTransferingGroup() throws Exception {
    // setup
    CenterBO toCenter = new CenterBuilder().build();
    // stubbing
    doThrow(new CustomerException(CustomerConstants.INVALID_PARENT)).when(group).validateReceivingCenter(toCenter);
    // exercise test
    customerService.transferGroupTo(group, toCenter);
    // verification
    verify(group).validateReceivingCenter(toCenter);
}
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 88 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class GroupTransferToCenterServiceTest method validatesNoActiveAccountExistWhenTransferingGroup.

@Test(expected = CustomerException.class)
public void validatesNoActiveAccountExistWhenTransferingGroup() throws Exception {
    // setup
    CenterBO toCenter = new CenterBuilder().build();
    // stubbing
    doThrow(new CustomerException(CustomerConstants.ERRORS_HAS_ACTIVE_ACCOUNT)).when(group).validateNoActiveAccountsExist();
    // exercise test
    customerService.transferGroupTo(group, toCenter);
    // verification
    verify(group).validateNoActiveAccountsExist();
}
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 89 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class CenterValidationTest method cannotCreateCenterWithMultipleInstancesOfSamePeriodFee.

@Test
public void cannotCreateCenterWithMultipleInstancesOfSamePeriodFee() {
    // setup
    DateTime today = new DateTime();
    MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly();
    CenterBO center = new CenterBuilder().withName("center1").withLoanOfficer(anyLoanOfficer()).with(aWeeklyMeeting).withMfiJoiningDate(today).build();
    MeetingBuilder aWeeklyFeeMeeting = new MeetingBuilder().periodicFeeMeeting().weekly();
    AmountFeeBO montlyPeriodicFee = new FeeBuilder().appliesToCenterOnly().with(aWeeklyFeeMeeting).build();
    AccountFeesEntity accountFee = new AccountFeesEntity(null, montlyPeriodicFee, montlyPeriodicFee.getFeeAmount().getAmountDoubleValue());
    List<AccountFeesEntity> centerAccountFees = new ArrayList<AccountFeesEntity>();
    centerAccountFees.add(accountFee);
    centerAccountFees.add(accountFee);
    // exercise test
    try {
        center.validateMeetingAndFees(centerAccountFees);
        fail("cannotCreateCenterWithFeeThatHasDifferentPeriod");
    } catch (ApplicationException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_DUPLICATE_PERIODIC_FEE));
    }
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) ApplicationException(org.mifos.framework.exceptions.ApplicationException) 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) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Example 90 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class GroupTransferToCenterTest method transferingGroupToCenterInDifferentBranchCreatesNewCustomerMovementsForGroupAndChangesGroupStatusFromActiveToOnHold.

@Test
public void transferingGroupToCenterInDifferentBranchCreatesNewCustomerMovementsForGroupAndChangesGroupStatusFromActiveToOnHold() throws Exception {
    // setup
    OfficeBO fromBranch = new OfficeBuilder().branchOffice().withName("fromBranch").withGlobalOfficeNum("xxx1").build();
    CenterBO fromCenter = new CenterBuilder().withName("fromCenter").with(fromBranch).build();
    GroupBO groupForTransfer = new GroupBuilder().withParentCustomer(fromCenter).active().build();
    OfficeBO receivingBranch = new OfficeBuilder().branchOffice().withName("receivingBranch").withGlobalOfficeNum("xxx2").build();
    CenterBO receivingCenter = new CenterBuilder().withName("receivingCenter").with(receivingBranch).build();
    // exercise test
    groupForTransfer.transferTo(receivingCenter);
    // verification
    assertThat(groupForTransfer.getStatus().isGroupActive(), is(false));
    assertThat(groupForTransfer.getStatus().isGroupOnHold(), is(true));
    assertThat(groupForTransfer.countOfCustomerMovements(), is(2));
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Aggregations

CenterBO (org.mifos.customers.center.business.CenterBO)117 Test (org.junit.Test)91 CenterBuilder (org.mifos.domain.builders.CenterBuilder)82 DateTime (org.joda.time.DateTime)47 MeetingBO (org.mifos.application.meeting.business.MeetingBO)46 GroupBO (org.mifos.customers.group.business.GroupBO)45 ArrayList (java.util.ArrayList)43 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)43 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)39 GroupBuilder (org.mifos.domain.builders.GroupBuilder)35 CustomerException (org.mifos.customers.exceptions.CustomerException)22 OfficeBO (org.mifos.customers.office.business.OfficeBO)21 ClientBO (org.mifos.customers.client.business.ClientBO)19 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)19 UserContext (org.mifos.security.util.UserContext)18 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)15 ClientBuilder (org.mifos.domain.builders.ClientBuilder)13 LocalDate (org.joda.time.LocalDate)12 Ignore (org.junit.Ignore)12 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)12