Search in sources :

Example 46 with GroupBuilder

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

the class GroupValidationTest method givenGroupWithNullMeetingShouldThrowBusinessRuleException.

@Test(expected = BusinessRuleException.class)
public void givenGroupWithNullMeetingShouldThrowBusinessRuleException() {
    OfficeBO office = new OfficeBuilder().build();
    PersonnelBO loanOfficer = new PersonnelBuilder().asLoanOfficer().build();
    group = new GroupBuilder().withName("group-On-branch").withOffice(office).withLoanOfficer(loanOfficer).withMeeting(null).buildAsTopOfHierarchy();
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) Test(org.junit.Test)

Example 47 with GroupBuilder

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

the class GroupValidationTest method givenGroupWithNullParentShouldThrowIllegalArgumentException.

@Test(expected = IllegalArgumentException.class)
public void givenGroupWithNullParentShouldThrowIllegalArgumentException() {
    OfficeBO office = new OfficeBuilder().build();
    PersonnelBO loanOfficer = new PersonnelBuilder().asLoanOfficer().build();
    MeetingBO meeting = new MeetingBuilder().customerMeeting().build();
    group = new GroupBuilder().withName("group-On-center").withOffice(office).withLoanOfficer(loanOfficer).withMeeting(meeting).withParentCustomer(null).build();
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) Test(org.junit.Test)

Example 48 with GroupBuilder

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

the class GroupValidationTest method givenAnActiveLoanAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation.

@Test
public void givenAnActiveLoanAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation() {
    // setup
    CenterBO center = new CenterBuilder().build();
    GroupBO group = new GroupBuilder().withParentCustomer(center).build();
    ClientBO client = new ClientBuilder().withParentCustomer(group).active().buildForUnitTests();
    group.addChild(client);
    LoanBO loan = new LoanAccountBuilder().activeInGoodStanding().build();
    client.addAccount(loan);
    // exercise test
    try {
        group.validateNoActiveAccountsExist();
        fail("should fail validation");
    } catch (CustomerException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_CHILDREN_HAS_ACTIVE_ACCOUNT));
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) LoanAccountBuilder(org.mifos.domain.builders.LoanAccountBuilder) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 49 with GroupBuilder

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

the class GroupValidationTest method givenCenterHasMeetingWithDifferentPeriodicityGroupTransferToCenterShouldFailValidation.

@Test
public void givenCenterHasMeetingWithDifferentPeriodicityGroupTransferToCenterShouldFailValidation() {
    // setup
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).build();
    CenterBO toCenter = new CenterBuilder().withName("receivingCenter").with(weeklyMeeting).build();
    MeetingBO monthlyMeeting = new MeetingBuilder().customerMeeting().monthly().every(1).onDayOfMonth(1).build();
    CenterBO oldCenter = new CenterBuilder().withName("oldCenter").with(monthlyMeeting).build();
    GroupBO group = new GroupBuilder().withParentCustomer(oldCenter).build();
    // exercise test
    try {
        group.validateReceivingCenter(toCenter);
        fail("should fail validation");
    } catch (CustomerException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_MEETING_FREQUENCY_MISMATCH));
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) MeetingBO(org.mifos.application.meeting.business.MeetingBO) 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) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) Test(org.junit.Test)

Example 50 with GroupBuilder

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

the class GroupValidationTest method loanOfficerMustBeAssigned.

@Test
public void loanOfficerMustBeAssigned() {
    OfficeBO office = new OfficeBuilder().build();
    group = new GroupBuilder().withName("group-On-branch").withOffice(office).withLoanOfficer(null).buildAsTopOfHierarchy();
    try {
        group.validate();
        fail("should throw customer exception as loan officer must exist when creating group under a branch.");
    } catch (CustomerException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_SELECT_LOAN_OFFICER));
    }
}
Also used : OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) OfficeBO(org.mifos.customers.office.business.OfficeBO) GroupBuilder(org.mifos.domain.builders.GroupBuilder) Test(org.junit.Test)

Aggregations

GroupBuilder (org.mifos.domain.builders.GroupBuilder)67 CenterBuilder (org.mifos.domain.builders.CenterBuilder)53 Test (org.junit.Test)49 GroupBO (org.mifos.customers.group.business.GroupBO)42 CenterBO (org.mifos.customers.center.business.CenterBO)35 ClientBuilder (org.mifos.domain.builders.ClientBuilder)31 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)24 CustomerException (org.mifos.customers.exceptions.CustomerException)21 MeetingBO (org.mifos.application.meeting.business.MeetingBO)16 ClientBO (org.mifos.customers.client.business.ClientBO)14 OfficeBO (org.mifos.customers.office.business.OfficeBO)14 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)13 ArrayList (java.util.ArrayList)12 LocalDate (org.joda.time.LocalDate)11 DateTime (org.joda.time.DateTime)10 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)10 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)9 Before (org.junit.Before)8 CustomerNoteEntity (org.mifos.customers.business.CustomerNoteEntity)8 CustomerStatusFlag (org.mifos.customers.util.helpers.CustomerStatusFlag)8