Search in sources :

Example 71 with CenterBO

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

the class CenterCreationTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs.

@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs() throws Exception {
    // setup
    CenterBO center = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).build();
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    // stub
    CalendarEvent upcomingCalendarEvents = new CalendarEventBuilder().build();
    when(holidayDao.findCalendarEventsForThisYearAndNext((short) 1)).thenReturn(upcomingCalendarEvents);
    when(customerAccountFactory.create(center, accountFees, meeting, upcomingCalendarEvents)).thenReturn(customerAccount);
    when(customerAccount.getType()).thenReturn(AccountTypes.CUSTOMER_ACCOUNT);
    // stub
    doThrow(new RuntimeException()).when(customerDao).save(center);
    // exercise test
    customerService.createCenter(center, meeting, accountFees);
    // verification
    verify(hibernateTransaction).rollbackTransaction();
    verify(hibernateTransaction).closeSession();
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) CalendarEvent(org.mifos.calendar.CalendarEvent) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Example 72 with CenterBO

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

the class ClientBuilder method buildForUnitTests.

public ClientBO buildForUnitTests() {
    ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1), Integer.valueOf(1).shortValue(), Integer.valueOf(1).shortValue(), Integer.valueOf(1).shortValue());
    this.clientDetailEntity = new ClientDetailEntity();
    this.clientDetailEntity.updateClientDetails(clientPersonalDetailDto);
    ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto();
    clientNameDetailDto.setNames("first_name,middle_name,last_name,second_last_name".split(","));
    this.clientNameDetailEntity = new ClientNameDetailEntity(null, null, clientNameDetailDto);
    if (underBranch) {
        ClientBO client = ClientBO.createNewOutOfGroupHierarchy(userContext, name, customerStatus, mfiJoiningDate, office, loanOfficer, meeting, formedBy, clientNameDetailEntity, dateOfBirth, governmentId, trained, trainedDate, groupFlag, clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, associatedOfferings, externalId, address, 10);
        client.setVersionNo(versionNumber);
        return client;
    }
    if (parentCustomer == null) {
        CenterBO center = new CenterBuilder().withLoanOfficer(loanOfficer).with(meeting).with(office).build();
        parentCustomer = new GroupBuilder().withParentCustomer(center).build();
    }
    ClientBO client = ClientBO.createNewInGroupHierarchy(userContext, name, customerStatus, mfiJoiningDate, parentCustomer, formedBy, clientNameDetailEntity, dateOfBirth, governmentId, trained, trainedDate, groupFlag, clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, associatedOfferings, externalId, address, new LocalDate(activationDate));
    client.setVersionNo(versionNumber);
    return client;
}
Also used : ClientNameDetailDto(org.mifos.dto.screen.ClientNameDetailDto) ClientNameDetailEntity(org.mifos.customers.client.business.ClientNameDetailEntity) ClientPersonalDetailDto(org.mifos.dto.screen.ClientPersonalDetailDto) ClientBO(org.mifos.customers.client.business.ClientBO) ClientDetailEntity(org.mifos.customers.client.business.ClientDetailEntity) CenterBO(org.mifos.customers.center.business.CenterBO) LocalDate(org.joda.time.LocalDate)

Example 73 with CenterBO

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

the class GroupActionStrutsTest method createCenterWithoutFee.

private void createCenterWithoutFee() throws Exception {
    meeting = new MeetingBO(WeekDay.MONDAY, EVERY_WEEK, new Date(), MeetingType.CUSTOMER_MEETING, "Delhi");
    center = new CenterBO(userContext, "MyCenter", null, null, null, "1234", null, TestObjectFactory.getBranchOffice(), meeting, TestObjectFactory.getTestUser(), new CustomerPersistence());
    new CenterPersistence().saveCenter(center);
    StaticHibernateUtil.flushAndClearSession();
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBO(org.mifos.customers.center.business.CenterBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) Date(java.util.Date) CenterPersistence(org.mifos.customers.center.persistence.CenterPersistence)

Example 74 with CenterBO

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

the class CustomerPersistenceIntegrationTest method testRetrieveAllLoanAccountUnderCustomer.

@Test
public void testRetrieveAllLoanAccountUnderCustomer() throws PersistenceException {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = createCenter("center");
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    CenterBO center1 = createCenter("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_ACTIVE, group);
    ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_ACTIVE, group1);
    account = getLoanAccount(group, meeting, "cdfggdfs", "1qdd");
    AccountBO account1 = getLoanAccount(client, meeting, "fdbdhgsgh", "54hg");
    AccountBO account2 = getLoanAccount(client2, meeting, "fasdfdsfasdf", "1qwe");
    AccountBO account3 = getLoanAccount(client3, meeting, "fdsgdfgfd", "543g");
    AccountBO account4 = getLoanAccount(group1, meeting, "fasdf23", "3fds");
    CustomerBOTestUtils.setCustomerStatus(client2, new CustomerStatusEntity(CustomerStatus.CLIENT_CLOSED));
    TestObjectFactory.updateObject(client2);
    client2 = TestObjectFactory.getClient(client2.getCustomerId());
    CustomerBOTestUtils.setCustomerStatus(client3, new CustomerStatusEntity(CustomerStatus.CLIENT_CANCELLED));
    TestObjectFactory.updateObject(client3);
    client3 = TestObjectFactory.getClient(client3.getCustomerId());
    List<AccountBO> loansForCenter = customerPersistence.retrieveAccountsUnderCustomer(center.getSearchId(), Short.valueOf("3"), Short.valueOf("1"));
    Assert.assertEquals(3, loansForCenter.size());
    List<AccountBO> loansForGroup = customerPersistence.retrieveAccountsUnderCustomer(group.getSearchId(), Short.valueOf("3"), Short.valueOf("1"));
    Assert.assertEquals(3, loansForGroup.size());
    List<AccountBO> loansForClient = customerPersistence.retrieveAccountsUnderCustomer(client.getSearchId(), Short.valueOf("3"), Short.valueOf("1"));
    Assert.assertEquals(1, loansForClient.size());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ClientBO(org.mifos.customers.client.business.ClientBO) CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) Test(org.junit.Test)

Example 75 with CenterBO

use of org.mifos.customers.center.business.CenterBO 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)

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