Search in sources :

Example 1 with CenterBuilder

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

the class SavingsDaoHibernateIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    enableCustomWorkingDays();
    weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
    weeklyPeriodicFeeForCenterOnly = new FeeBuilder().appliesToCenterOnly().withFeeAmount("100.0").withName("Center Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForCenterOnly);
    center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
    IntegrationTestObjectMother.createCenter((CenterBO) center, weeklyMeeting);
    weeklyPeriodicFeeForGroupOnly = new FeeBuilder().appliesToGroupsOnly().withFeeAmount("50.0").withName("Group Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForGroupOnly);
    group = new GroupBuilder().withMeeting(weeklyMeeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withFee(weeklyPeriodicFeeForGroupOnly).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, weeklyMeeting);
    weeklyPeriodicFeeForClientsOnly = new FeeBuilder().appliesToClientsOnly().withFeeAmount("10.0").withName("Client Weekly Periodic Fee").withSameRecurrenceAs(weeklyMeeting).with(sampleBranchOffice()).build();
    IntegrationTestObjectMother.saveFee(weeklyPeriodicFeeForClientsOnly);
    client = new ClientBuilder().withMeeting(weeklyMeeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, weeklyMeeting);
    customerHierarchyParams = new CustomerHierarchyParams(center.getCustomerId(), center.getOffice().getOfficeId(), center.getSearchId() + ".%", new LocalDate());
    baseDao = new GenericDaoHibernate();
    savingsDao = new SavingsDaoHibernate(baseDao);
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CustomerHierarchyParams(org.mifos.application.servicefacade.CustomerHierarchyParams) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) LocalDate(org.joda.time.LocalDate) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Before(org.junit.Before)

Example 2 with CenterBuilder

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

the class SavingsAccountSchedulesIntegrationTest method createCenterAndGroupHierarchyWithNoClients.

private void createCenterAndGroupHierarchyWithNoClients(MeetingBO aWeeklyMeeting) {
    center = new CenterBuilder().withName("Savings Center").with(aWeeklyMeeting).with(sampleBranchOffice()).withLoanOfficer(testUser()).withActivationDate(mondayTwoWeeksAgo()).build();
    IntegrationTestObjectMother.createCenter(center, aWeeklyMeeting);
    group = new GroupBuilder().withName("Group").withMeeting(aWeeklyMeeting).withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, aWeeklyMeeting);
}
Also used : GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder)

Example 3 with CenterBuilder

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

the class EditStatusActionStrutsTest method createCenterGroupClientHierarchy.

private void createCenterGroupClientHierarchy() throws CustomerException {
    meeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(meeting);
    center = new CenterBuilder().withName("Savings Center").with(meeting).with(sampleBranchOffice()).withLoanOfficer(testUser()).withActivationDate(mondayTwoWeeksAgo()).build();
    IntegrationTestObjectMother.createCenter(center, meeting);
    group = new GroupBuilder().withName("Group").withMeeting(meeting).withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
    IntegrationTestObjectMother.createGroup(group, meeting);
    client = new ClientBuilder().withName("Client 1").active().withMeeting(meeting).withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(client, meeting);
}
Also used : GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder)

Example 4 with CenterBuilder

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

the class CenterStatusChangeIntegrationTest method givenCenterIsInactiveAndAssignedLoanOfficerIsInactiveShouldNotPassValidationWhenTryingToTranistionClientToActive.

@Test
public void givenCenterIsInactiveAndAssignedLoanOfficerIsInactiveShouldNotPassValidationWhenTryingToTranistionClientToActive() throws Exception {
    // setup
    CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
    existingCenter.updateCustomerStatus(CustomerStatus.CENTER_INACTIVE);
    IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
    existingLoanOfficer = this.personnelDao.findPersonnelById(existingLoanOfficer.getPersonnelId());
    updatePersonnel(existingLoanOfficer, PersonnelLevel.LOAN_OFFICER, PersonnelStatus.INACTIVE, existingOffice);
    GroupBO existingPartialGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_PARTIAL).withParentCustomer(existingCenter).formedBy(existingUser).build();
    IntegrationTestObjectMother.createGroup(existingPartialGroup, existingMeeting);
    ClientBO existingPartialClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_PARTIAL).withParentCustomer(existingPartialGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingPartialClient, existingMeeting);
    StaticHibernateUtil.flushAndClearSession();
    existingCenter = this.customerDao.findCenterBySystemId(existingCenter.getGlobalCustNum());
    existingCenter.setUserContext(TestUtils.makeUser());
    existingPartialGroup = this.customerDao.findGroupBySystemId(existingPartialGroup.getGlobalCustNum());
    existingPartialClient = this.customerDao.findClientBySystemId(existingPartialClient.getGlobalCustNum());
    existingPartialClient.setUserContext(TestUtils.makeUser());
    CustomerStatusFlag customerStatusFlag = null;
    CustomerNoteEntity customerNote = new CustomerNoteEntity("go active", new Date(), existingCenter.getPersonnel(), existingCenter);
    // exercise test
    try {
        customerService.updateCenterStatus(existingCenter, CustomerStatus.CENTER_ACTIVE, customerStatusFlag, customerNote);
        fail("should fail validation");
    } catch (CustomerException expected) {
        assertThat(expected.getKey(), is(CustomerConstants.CUSTOMER_LOAN_OFFICER_INACTIVE_EXCEPTION));
        assertThat(existingCenter.getStatus(), is(CustomerStatus.CENTER_INACTIVE));
    }
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerException(org.mifos.customers.exceptions.CustomerException) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) 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) Date(java.util.Date) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 5 with CenterBuilder

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

the class CenterStatusChangeIntegrationTest method shouldValidateStatusWithActiveGroups.

@Test
public void shouldValidateStatusWithActiveGroups() throws Exception {
    // setup
    CenterBO existingCenter = new CenterBuilder().withName("Center-IntegrationTest").with(existingMeeting).with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
    IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
    GroupBO existingActiveGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_ACTIVE).withParentCustomer(existingCenter).formedBy(existingUser).build();
    IntegrationTestObjectMother.createGroup(existingActiveGroup, existingMeeting);
    ClientBO existingCancelledClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_CANCELLED).withParentCustomer(existingActiveGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingCancelledClient, existingMeeting);
    existingCenter = this.customerDao.findCenterBySystemId(existingCenter.getGlobalCustNum());
    existingCenter.setUserContext(TestUtils.makeUserWithLocales());
    existingActiveGroup = this.customerDao.findGroupBySystemId(existingActiveGroup.getGlobalCustNum());
    existingCancelledClient = this.customerDao.findClientBySystemId(existingCancelledClient.getGlobalCustNum());
    CustomerStatusFlag customerStatusFlag = null;
    CustomerNoteEntity customerNote = new CustomerNoteEntity("go inactive", new Date(), existingCenter.getPersonnel(), existingCenter);
    // exercise test
    try {
        customerService.updateCenterStatus(existingCenter, CustomerStatus.CENTER_INACTIVE, customerStatusFlag, customerNote);
        fail("should fail validation");
    } catch (CustomerException expected) {
        // verification
        assertThat(expected.getKey(), is(CustomerConstants.ERROR_STATE_CHANGE_EXCEPTION));
        assertThat(existingCenter.getStatus(), is(CustomerStatus.CENTER_ACTIVE));
    }
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerException(org.mifos.customers.exceptions.CustomerException) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) 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) Date(java.util.Date) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Aggregations

CenterBuilder (org.mifos.domain.builders.CenterBuilder)123 Test (org.junit.Test)98 CenterBO (org.mifos.customers.center.business.CenterBO)82 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)73 MeetingBO (org.mifos.application.meeting.business.MeetingBO)54 GroupBuilder (org.mifos.domain.builders.GroupBuilder)53 DateTime (org.joda.time.DateTime)52 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)46 ArrayList (java.util.ArrayList)42 GroupBO (org.mifos.customers.group.business.GroupBO)36 ClientBuilder (org.mifos.domain.builders.ClientBuilder)30 OfficeBO (org.mifos.customers.office.business.OfficeBO)21 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)19 CustomerException (org.mifos.customers.exceptions.CustomerException)18 FeeBuilder (org.mifos.domain.builders.FeeBuilder)18 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)17 LocalDate (org.joda.time.LocalDate)14 Before (org.junit.Before)14 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)13 ClientBO (org.mifos.customers.client.business.ClientBO)13