Search in sources :

Example 81 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class GroupCreationTest method createsGroupWithCustomerAccount.

@Test
public void createsGroupWithCustomerAccount() throws Exception {
    // setup
    OfficeBO withOffice = new OfficeBO(new Short("1"), "testOffice", new Integer("1"), new Short("1"));
    CenterBO parent = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).with(withOffice).build();
    GroupBO stubbedGroup = new GroupBuilder().withName("group").withParentCustomer(parent).formedBy(anyLoanOfficer()).build();
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    // stub
    CalendarEvent upcomingCalendarEvents = new CalendarEventBuilder().build();
    when(holidayDao.findCalendarEventsForThisYearAndNext((short) 1)).thenReturn(upcomingCalendarEvents);
    when(customerAccountFactory.create(stubbedGroup, accountFees, meeting, upcomingCalendarEvents)).thenReturn(customerAccount);
    when(customerAccount.getType()).thenReturn(AccountTypes.CUSTOMER_ACCOUNT);
    // exercise test
    customerService.createGroup(stubbedGroup, meeting, accountFees);
    // verification
    assertThat(stubbedGroup.getCustomerAccount(), is(customerAccount));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) 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) CalendarEvent(org.mifos.calendar.CalendarEvent) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Matchers.anyShort(org.mockito.Matchers.anyShort) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Example 82 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity 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 83 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity 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 84 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class ClientCreationTest method throwsCheckedExceptionWhenValidationForDuplicateNameOrGovernmentId.

@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenValidationForDuplicateNameOrGovernmentId() throws Exception {
    String displayName = "Test Name";
    Date dob = new Date();
    String govtId = "44354323543";
    // setup
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    List<SavingsOfferingBO> noSavings = new ArrayList<SavingsOfferingBO>();
    // stubbing
    Mockito.when(mockedClient.getDisplayName()).thenReturn(displayName);
    Mockito.when(mockedClient.getDateOfBirth()).thenReturn(dob);
    Mockito.when(mockedClient.getGovernmentId()).thenReturn(govtId);
    doThrow(new CustomerException(CustomerConstants.DUPLICATE_GOVT_ID_EXCEPTION)).when(customerDao).validateClientForDuplicateNameOrGovtId(displayName, dob, govtId);
    // exercise test
    customerService.createClient(mockedClient, meeting, accountFees, noSavings);
    // verify
    verify(customerDao).validateClientForDuplicateNameOrGovtId(mockedClient.getDisplayName(), mockedClient.getDateOfBirth(), mockedClient.getGovernmentId());
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) ArrayList(java.util.ArrayList) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Date(java.util.Date) Test(org.junit.Test)

Example 85 with AccountFeesEntity

use of org.mifos.accounts.business.AccountFeesEntity in project head by mifos.

the class ClientCreationTest method throwsCheckedExceptionWhenClientValidationFails.

@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenClientValidationFails() throws Exception {
    // setup
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    List<SavingsOfferingBO> noSavings = new ArrayList<SavingsOfferingBO>();
    // stubbing
    doThrow(new CustomerException(ClientConstants.ERRORS_GROUP_CANCELLED)).when(mockedClient).validate();
    // exercise test
    customerService.createClient(mockedClient, meeting, accountFees, noSavings);
    // verify
    verify(mockedClient).validate();
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) ArrayList(java.util.ArrayList) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) Test(org.junit.Test)

Aggregations

AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)118 ArrayList (java.util.ArrayList)78 Test (org.junit.Test)65 CenterBuilder (org.mifos.domain.builders.CenterBuilder)46 DateTime (org.joda.time.DateTime)42 MeetingBO (org.mifos.application.meeting.business.MeetingBO)42 CenterBO (org.mifos.customers.center.business.CenterBO)39 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)38 FeeBO (org.mifos.accounts.fees.business.FeeBO)25 Money (org.mifos.framework.util.helpers.Money)25 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)24 UserContext (org.mifos.security.util.UserContext)22 LocalDate (org.joda.time.LocalDate)21 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)21 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)18 FeeInstallment (org.mifos.accounts.util.helpers.FeeInstallment)17 OfficeBO (org.mifos.customers.office.business.OfficeBO)17 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)17 MifosUser (org.mifos.security.MifosUser)16 AccountException (org.mifos.accounts.exceptions.AccountException)14