Search in sources :

Example 41 with GroupBO

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

the class CustomerStatusUpdateTest method throwsCheckedExceptionWhenValidationFailsForTransitioningToActive.

@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenValidationFailsForTransitioningToActive() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().with(CustomerStatus.GROUP_ACTIVE).build();
    CenterBO existingCenter = new CenterBuilder().build();
    GroupBO existingGroup = new GroupBuilder().active().withParentCustomer(existingCenter).withVersion(customerStatusUpdate.getVersionNum()).build();
    existingGroup.setLoanOfficer(null);
    // stubbing
    when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(existingGroup);
    // exercise test
    customerService.updateCustomerStatus(userContext, customerStatusUpdate);
}
Also used : CustomerStatusUpdate(org.mifos.application.servicefacade.CustomerStatusUpdate) UserContext(org.mifos.security.util.UserContext) 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) CustomerStatusUpdateBuilder(org.mifos.domain.builders.CustomerStatusUpdateBuilder) Test(org.junit.Test)

Example 42 with GroupBO

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

the class CustomerStatusUpdateTest method updatesPendingChildrenToPartialWhenTransitioningGroupFromPendingToCancelled.

@Test
public void updatesPendingChildrenToPartialWhenTransitioningGroupFromPendingToCancelled() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().with(CustomerStatus.GROUP_CANCELLED).build();
    PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
    CenterBO existingCenter = new CenterBuilder().withLoanOfficer(loanOfficer).active().build();
    GroupBO existingGroup = new GroupBuilder().pendingApproval().withParentCustomer(existingCenter).withVersion(customerStatusUpdate.getVersionNum()).build();
    ClientBO existingClient = new ClientBuilder().withParentCustomer(existingGroup).pendingApproval().buildForUnitTests();
    existingGroup.addChild(existingClient);
    // stubbing
    when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(existingGroup);
    // exercise test
    customerService.updateCustomerStatus(userContext, customerStatusUpdate);
    // verification
    assertThat(existingGroup.getStatus(), is(CustomerStatus.GROUP_CANCELLED));
    assertThat(existingClient.getUserContext(), is(userContext));
    assertThat(existingClient.getStatus(), is(CustomerStatus.CLIENT_PARTIAL));
}
Also used : CustomerStatusUpdate(org.mifos.application.servicefacade.CustomerStatusUpdate) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) 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) CustomerStatusUpdateBuilder(org.mifos.domain.builders.CustomerStatusUpdateBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 43 with GroupBO

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

the class GroupTransferToCenterTest method transferingGroupToCenterInSameBranchIncrementsMaxChildCountOfNewParentAndDoesNotDecrementsMaxChildCountOfOldParent.

@Test
public void transferingGroupToCenterInSameBranchIncrementsMaxChildCountOfNewParentAndDoesNotDecrementsMaxChildCountOfOldParent() throws Exception {
    CenterBO fromCenter = new CenterBuilder().withName("fromCenter").build();
    GroupBO groupForTransfer = new GroupBuilder().withParentCustomer(fromCenter).active().build();
    fromCenter.addChild(groupForTransfer);
    CenterBO centerWithNoChildren = new CenterBuilder().withName("receivingCenter").build();
    // pre-verification
    assertThat(centerWithNoChildren.getMaxChildCount(), is(0));
    assertThat(centerWithNoChildren.getChildren().size(), is(0));
    assertThat(groupForTransfer.getParentCustomer().getMaxChildCount(), is(1));
    // exercise test
    groupForTransfer.transferTo(centerWithNoChildren);
    // verification
    assertThat(centerWithNoChildren.getMaxChildCount(), is(1));
    assertThat(fromCenter.getMaxChildCount(), is(1));
}
Also used : 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)

Example 44 with GroupBO

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

the class CustomerPersistenceIntegrationTest method testGetAllBasicGroupInfo.

@Test
public void testGetAllBasicGroupInfo() throws Exception {
    CustomerPersistence customerPersistence = new CustomerPersistence();
    center = createCenter("new_center");
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    GroupBO newGroup = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup", CustomerStatus.GROUP_HOLD, center);
    GroupBO newGroup2 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup2", CustomerStatus.GROUP_CANCELLED, center);
    GroupBO newGroup3 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup3", CustomerStatus.GROUP_CLOSED, center);
    GroupBO newGroup4 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup4", CustomerStatus.GROUP_PARTIAL, center);
    GroupBO newGroup5 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup5", CustomerStatus.GROUP_PENDING, center);
    List<BasicGroupInfo> groupInfos = customerPersistence.getAllBasicGroupInfo();
    Assert.assertEquals(2, groupInfos.size());
    Assert.assertEquals(group.getDisplayName(), groupInfos.get(0).getGroupName());
    Assert.assertEquals(group.getSearchId(), groupInfos.get(0).getSearchId());
    Assert.assertEquals(group.getOffice().getOfficeId(), groupInfos.get(0).getBranchId());
    Assert.assertEquals(group.getCustomerId(), groupInfos.get(0).getGroupId());
    Assert.assertEquals(newGroup.getDisplayName(), groupInfos.get(1).getGroupName());
    Assert.assertEquals(newGroup.getSearchId(), groupInfos.get(1).getSearchId());
    Assert.assertEquals(newGroup.getOffice().getOfficeId(), groupInfos.get(1).getBranchId());
    Assert.assertEquals(newGroup.getCustomerId(), groupInfos.get(1).getGroupId());
//        TestObjectFactory.cleanUp(newGroup);
//        TestObjectFactory.cleanUp(newGroup2);
//        TestObjectFactory.cleanUp(newGroup3);
//        TestObjectFactory.cleanUp(newGroup4);
//        TestObjectFactory.cleanUp(newGroup5);
}
Also used : BasicGroupInfo(org.mifos.customers.group.BasicGroupInfo) GroupBO(org.mifos.customers.group.business.GroupBO) Test(org.junit.Test)

Example 45 with GroupBO

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

the class CustomerPersistenceIntegrationTest method testRetrieveAllSavingsAccountUnderCustomer.

@Test
public void testRetrieveAllSavingsAccountUnderCustomer() throws Exception {
    center = createCenter("new_center");
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    CenterBO center1 = createCenter("new_center1");
    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);
    account = getSavingsAccount(center, "Savings Prd1", "Abc1");
    AccountBO account1 = getSavingsAccount(client, "Savings Prd2", "Abc2");
    AccountBO account2 = getSavingsAccount(client2, "Savings Prd3", "Abc3");
    AccountBO account3 = getSavingsAccount(client3, "Savings Prd4", "Abc4");
    AccountBO account4 = getSavingsAccount(group1, "Savings Prd5", "Abc5");
    AccountBO account5 = getSavingsAccount(group, "Savings Prd6", "Abc6");
    AccountBO account6 = getSavingsAccount(center1, "Savings Prd7", "Abc7");
    List<AccountBO> savingsForCenter = customerPersistence.retrieveAccountsUnderCustomer(center.getSearchId(), Short.valueOf("3"), Short.valueOf("2"));
    Assert.assertEquals(4, savingsForCenter.size());
    List<AccountBO> savingsForGroup = customerPersistence.retrieveAccountsUnderCustomer(group.getSearchId(), Short.valueOf("3"), Short.valueOf("2"));
    Assert.assertEquals(3, savingsForGroup.size());
    List<AccountBO> savingsForClient = customerPersistence.retrieveAccountsUnderCustomer(client.getSearchId(), Short.valueOf("3"), Short.valueOf("2"));
    Assert.assertEquals(1, savingsForClient.size());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) 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