Search in sources :

Example 11 with PersonnelBuilder

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

the class CenterHierarchyCustomerServiceIntegrationTest method cleanDatabaseTables.

@Before
public void cleanDatabaseTables() {
    databaseCleaner.clean();
    // setup
    String centerName = "Center-IntegrationTest";
    OfficeBO existingBranch = sampleBranchOffice();
    PersonnelBO existingLoanOfficer = testUser();
    MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    DateTime today = new DateTime();
    Address noAddress = null;
    String noExternalId = null;
    center = new CenterBuilder().withName(centerName).with(weeklyMeeting).with(existingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(today).with(noAddress).withExternalId(noExternalId).withUserContext().build();
    IntegrationTestObjectMother.createCenter(center, center.getCustomerMeetingValue());
    group = new GroupBuilder().withName("group1").withParentCustomer(center).active().formedBy(center.getPersonnel()).build();
    IntegrationTestObjectMother.createGroup(group, group.getCustomerMeetingValue());
    group2 = new GroupBuilder().withName("group2").withParentCustomer(center).active().formedBy(center.getPersonnel()).build();
    IntegrationTestObjectMother.createGroup(group2, group2.getCustomerMeetingValue());
    otherLoanOfficer = new PersonnelBuilder().withDisplayName("otherLoanOfficer").with(existingBranch).build();
    IntegrationTestObjectMother.createPersonnel(otherLoanOfficer);
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Address(org.mifos.framework.business.util.Address) 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) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) Before(org.junit.Before)

Example 12 with PersonnelBuilder

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

the class GroupTransferToCenterTest method transferingGroupToCenterInSameBranchShouldModifyGroupToHaveSameLoanOfficerAsReceivingCenter.

@Test
public void transferingGroupToCenterInSameBranchShouldModifyGroupToHaveSameLoanOfficerAsReceivingCenter() throws Exception {
    PersonnelBO loanOfficer = new PersonnelBuilder().withDisplayName("old loan officer").build();
    CenterBO fromCenter = new CenterBuilder().withName("fromCenter").withLoanOfficer(loanOfficer).build();
    GroupBO groupForTransfer = new GroupBuilder().withParentCustomer(fromCenter).active().build();
    PersonnelBO newLoanOfficer = new PersonnelBuilder().withDisplayName("loan officer").build();
    CenterBO receivingCenter = new CenterBuilder().withName("receivingCenter").withLoanOfficer(newLoanOfficer).build();
    // pre-verification
    assertThat(receivingCenter.getPersonnel().getDisplayName(), is("loan officer"));
    assertThat(groupForTransfer.getPersonnel().getDisplayName(), is("old loan officer"));
    // exercise test
    groupForTransfer.transferTo(receivingCenter);
    // verification
    assertThat(receivingCenter.getPersonnel().getDisplayName(), is("loan officer"));
    assertThat(groupForTransfer.getPersonnel().getDisplayName(), is("loan officer"));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) 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 13 with PersonnelBuilder

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

the class GroupUpdateTest method updatesLoanOfficerForAllChildrenAndThierAccountsWhenLoanOfficerIsUpdated.

@Test
public void updatesLoanOfficerForAllChildrenAndThierAccountsWhenLoanOfficerIsUpdated() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    GroupUpdate groupUpdate = new GroupUpdateBuilder().build();
    PersonnelBO newLoanOfficer = new PersonnelBuilder().anyLoanOfficer();
    // stubbing
    when(customerDao.findGroupBySystemId(groupUpdate.getGlobalCustNum())).thenReturn(mockedGroup);
    when(mockedGroup.isNameDifferent(groupUpdate.getDisplayName())).thenReturn(false);
    when(personnelDao.findPersonnelById(groupUpdate.getLoanOfficerId())).thenReturn(newLoanOfficer);
    when(mockedGroup.isLoanOfficerChanged(newLoanOfficer)).thenReturn(true);
    when(mockedGroup.getOffice()).thenReturn(new OfficeBuilder().build());
    // exercise test
    customerService.updateGroup(userContext, groupUpdate);
    // verification
    verify(mockedGroup).setLoanOfficer(newLoanOfficer);
    verify(mockedGroup).validate();
    verify(customerDao).updateLoanOfficersForAllChildrenAndAccounts(anyShort(), anyString(), anyShort());
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) GroupUpdateBuilder(org.mifos.domain.builders.GroupUpdateBuilder) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) GroupUpdate(org.mifos.dto.domain.GroupUpdate) Test(org.junit.Test)

Example 14 with PersonnelBuilder

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

the class GroupUpdateTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs.

@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    GroupUpdate groupUpdate = new GroupUpdateBuilder().build();
    PersonnelBO newLoanOfficer = new PersonnelBuilder().anyLoanOfficer();
    // stubbing
    when(customerDao.findGroupBySystemId(groupUpdate.getGlobalCustNum())).thenReturn(mockedGroup);
    when(mockedGroup.isNameDifferent(groupUpdate.getDisplayName())).thenReturn(false);
    when(personnelDao.findPersonnelById(groupUpdate.getLoanOfficerId())).thenReturn(newLoanOfficer);
    when(mockedGroup.isLoanOfficerChanged(newLoanOfficer)).thenReturn(false);
    when(mockedGroup.getOffice()).thenReturn(new OfficeBuilder().build());
    // stub
    doThrow(new RuntimeException()).when(customerDao).save(mockedGroup);
    // exercise test
    customerService.updateGroup(userContext, groupUpdate);
    // verification
    verify(hibernateTransactionHelper).rollbackTransaction();
    verify(hibernateTransactionHelper).closeSession();
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) GroupUpdateBuilder(org.mifos.domain.builders.GroupUpdateBuilder) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) GroupUpdate(org.mifos.dto.domain.GroupUpdate) Test(org.junit.Test)

Example 15 with PersonnelBuilder

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

the class GroupUpdateTest method rollsbackTransactionClosesSessionAndReThrowsApplicationException.

@Test(expected = CustomerException.class)
public void rollsbackTransactionClosesSessionAndReThrowsApplicationException() throws Exception {
    // setup
    UserContext userContext = TestUtils.makeUser();
    GroupUpdate groupUpdate = new GroupUpdateBuilder().build();
    PersonnelBO newLoanOfficer = new PersonnelBuilder().anyLoanOfficer();
    // stubbing
    when(customerDao.findGroupBySystemId(groupUpdate.getGlobalCustNum())).thenReturn(mockedGroup);
    when(mockedGroup.isNameDifferent(groupUpdate.getDisplayName())).thenReturn(false);
    when(personnelDao.findPersonnelById(groupUpdate.getLoanOfficerId())).thenReturn(newLoanOfficer);
    when(mockedGroup.isLoanOfficerChanged(newLoanOfficer)).thenReturn(false);
    when(mockedGroup.getOffice()).thenReturn(new OfficeBuilder().build());
    // stub
    doThrow(new CustomerException(CustomerConstants.ERRORS_DUPLICATE_CUSTOMER)).when(mockedGroup).validate();
    // exercise test
    customerService.updateGroup(userContext, groupUpdate);
    // verification
    verify(hibernateTransactionHelper).rollbackTransaction();
    verify(hibernateTransactionHelper).closeSession();
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) OfficeBuilder(org.mifos.domain.builders.OfficeBuilder) GroupUpdateBuilder(org.mifos.domain.builders.GroupUpdateBuilder) CustomerException(org.mifos.customers.exceptions.CustomerException) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) UserContext(org.mifos.security.util.UserContext) GroupUpdate(org.mifos.dto.domain.GroupUpdate) Test(org.junit.Test)

Aggregations

PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)31 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)31 Test (org.junit.Test)27 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)18 Money (org.mifos.framework.util.helpers.Money)12 DateTime (org.joda.time.DateTime)10 InterestCalculationPeriodResult (org.mifos.accounts.savings.interest.InterestCalculationPeriodResult)8 InterestCalculationPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder)8 InterestPostingPeriodResult (org.mifos.accounts.savings.interest.InterestPostingPeriodResult)8 InterestPostingPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder)8 InterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent)8 MonthlyOnLastDayOfMonthInterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent)8 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)7 OfficeBO (org.mifos.customers.office.business.OfficeBO)7 OfficeBuilder (org.mifos.domain.builders.OfficeBuilder)7 LocalDate (org.joda.time.LocalDate)6 GroupBuilder (org.mifos.domain.builders.GroupBuilder)6 ArrayList (java.util.ArrayList)5 AccountNotesEntity (org.mifos.accounts.business.AccountNotesEntity)5 AccountNotesEntityBuilder (org.mifos.accounts.business.AccountNotesEntityBuilder)5