Search in sources :

Example 66 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testGetAllChildrenForParent.

@Test
public void testGetAllChildrenForParent() throws NumberFormatException, PersistenceException {
    center = createCenter("Center");
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    CenterBO center1 = createCenter("center11");
    GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center1);
    client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
    ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
    ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group1);
    List<CustomerBO> customerList1 = customerPersistence.getAllChildrenForParent(center.getSearchId(), Short.valueOf("3"), CustomerLevel.CENTER.getValue());
    Assert.assertEquals(2, customerList1.size());
    List<CustomerBO> customerList2 = customerPersistence.getAllChildrenForParent(center.getSearchId(), Short.valueOf("3"), CustomerLevel.GROUP.getValue());
    Assert.assertEquals(1, customerList2.size());
    //        TestObjectFactory.cleanUp(client3);
    //        TestObjectFactory.cleanUp(client2);
    group1 = null;
    center1 = null;
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerBO(org.mifos.customers.business.CustomerBO) Test(org.junit.Test)

Example 67 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class GroupValidationTest method givenAnActiveSavingsAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation.

@Test
public void givenAnActiveSavingsAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation() {
    // setup
    CenterBO center = new CenterBuilder().build();
    GroupBO group = new GroupBuilder().withParentCustomer(center).build();
    ClientBO client = new ClientBuilder().withParentCustomer(group).active().buildForUnitTests();
    group.addChild(client);
    SavingsBO savings = new SavingsAccountBuilder().active().withCustomer(group).build();
    client.addAccount(savings);
    // 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) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 68 with GroupBO

use of org.mifos.customers.group.business.GroupBO 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 69 with GroupBO

use of org.mifos.customers.group.business.GroupBO 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 70 with GroupBO

use of org.mifos.customers.group.business.GroupBO in project head by mifos.

the class GroupValidationTest method givenCenterIsSameAsGroupsParentGroupTransferToCenterShouldFailValidation.

@Test
public void givenCenterIsSameAsGroupsParentGroupTransferToCenterShouldFailValidation() {
    // setup
    CenterBO center = new CenterBuilder().build();
    GroupBO group = new GroupBuilder().withParentCustomer(center).build();
    // exercise test
    try {
        group.validateReceivingCenter(center);
        fail("should fail validation");
    } catch (CustomerException e) {
        assertThat(e.getKey(), is(CustomerConstants.ERRORS_SAME_CENTER_TRANSFER));
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) 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

GroupBO (org.mifos.customers.group.business.GroupBO)84 Test (org.junit.Test)56 CenterBO (org.mifos.customers.center.business.CenterBO)45 GroupBuilder (org.mifos.domain.builders.GroupBuilder)42 CenterBuilder (org.mifos.domain.builders.CenterBuilder)36 CustomerException (org.mifos.customers.exceptions.CustomerException)23 ClientBO (org.mifos.customers.client.business.ClientBO)22 ArrayList (java.util.ArrayList)16 OfficeBO (org.mifos.customers.office.business.OfficeBO)16 MeetingBO (org.mifos.application.meeting.business.MeetingBO)15 ClientBuilder (org.mifos.domain.builders.ClientBuilder)15 DateTime (org.joda.time.DateTime)14 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)12 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)11 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)11 UserContext (org.mifos.security.util.UserContext)11 LocalDate (org.joda.time.LocalDate)10 MifosRuntimeException (org.mifos.core.MifosRuntimeException)10 ApplicationException (org.mifos.framework.exceptions.ApplicationException)10 Date (java.util.Date)9