use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class CustomerSearchIdGenerationTest method transferClientFromGroupToGroupTest.
@Test
public void transferClientFromGroupToGroupTest() throws Exception {
final short office1_id = 2;
final Integer group1_id = 33;
final Integer group2_id = 22;
final int group2_child_count = 8;
// setup
UserContext userContext = TestUtils.makeUser();
OfficeBO office1 = new OfficeBuilder().withName("office1").branchOffice().withOfficeId(office1_id).build();
PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
GroupBO existingGroup = new GroupBuilder().pendingApproval().withLoanOfficer(loanOfficer).with(userContext).buildAsTopOfHierarchy();
existingGroup = spy(existingGroup);
when(existingGroup.getCustomerId()).thenReturn(group1_id);
existingGroup.generateSearchId();
ClientBO existingClient = new ClientBuilder().pendingApproval().withParentCustomer(existingGroup).withVersion(1).buildForUnitTests();
existingGroup.addChild(existingClient);
existingGroup.setCustomerDao(customerDao);
GroupBO existingGroup2 = new GroupBuilder().pendingApproval().withLoanOfficer(loanOfficer).with(userContext).withSearchId(group2_child_count).withOffice(office1).buildAsTopOfHierarchy();
existingGroup2.setCustomerDao(customerDao);
existingGroup2 = spy(existingGroup2);
when(existingGroup2.getCustomerId()).thenReturn(group2_id);
existingGroup2.generateSearchId();
// stubbing
when(customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(office1_id)).thenReturn(3);
when(customerDao.findClientBySystemId("clientid")).thenReturn(existingClient);
when(customerDao.findCustomerById(group2_id)).thenReturn(existingGroup2);
when(holidayDao.findCalendarEventsForThisYearAndNext(anyShort())).thenReturn(calendarEvent);
when(configurationHelper.isLoanScheduleRepaymentIndependentOfCustomerMeetingEnabled()).thenReturn(true);
// exercise test
assertThat(existingGroup.getSearchId(), is("1." + group1_id));
assertThat(existingClient.getSearchId(), is("1." + group1_id + ".1"));
customerService.transferClientTo(userContext, group2_id, "clientid", 1);
// verification
assertThat(existingGroup2.getSearchId(), is("1." + group2_id));
assertThat(existingClient.getSearchId(), is("1." + group2_id + "." + (group2_child_count + 1)));
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class SavingsScheduleIntegrationTest method createClientSavingsAccount.
public void createClientSavingsAccount() throws Exception {
meeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(expectedFirstDepositDate).build();
IntegrationTestObjectMother.saveMeeting(meeting);
center = new CenterBuilder().with(meeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter(center, meeting);
group = new GroupBuilder().withMeeting(meeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(group, meeting);
client = new ClientBuilder().withMeeting(meeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(client, meeting);
savingsProduct = new SavingsProductBuilder().mandatory().appliesToClientsOnly().buildForIntegrationTests();
HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
List<Holiday> holidays = holidayDao.findAllHolidaysThisYearAndNext(client.getOfficeId());
savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(client).with(holidays).build();
IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class SavingsAccountSchedulesIntegrationTest method createCenterGroupClientHierarchy.
private void createCenterGroupClientHierarchy(MeetingBO aWeeklyMeeting) throws CustomerException {
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);
client = new ClientBuilder().withName("Client 1").active().withMeeting(aWeeklyMeeting).withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(client, aWeeklyMeeting);
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class SavingsBOMoreIntegrationTest method cleanDatabaseTables.
@Before
public void cleanDatabaseTables() throws Exception {
databaseCleaner.clean();
MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
center = new CenterBuilder().with(weeklyMeeting).withName("Savings Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter(center, weeklyMeeting);
group = new GroupBuilder().withMeeting(weeklyMeeting).withName("Savings Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(group, weeklyMeeting);
client = new ClientBuilder().withMeeting(weeklyMeeting).withName("Savings Client").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(client, weeklyMeeting);
String recommendedAmountString = "3.0";
recommendedAmount = new Money(Money.getDefaultCurrency(), recommendedAmountString);
savings = new TestCollectionSheetRetrieveSavingsAccountsUtils().createSavingsAccount(client, "clm", recommendedAmountString, false, false);
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class ClientBoTest method testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsFalseIfCustomerHasSuchAccountsButIsDefinedAsSameForAllLoans.
@Test
public void testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsFalseIfCustomerHasSuchAccountsButIsDefinedAsSameForAllLoans() throws Exception {
// Same for all loans is the default in the LoanProductBuilder
// setup
client = new ClientBuilder().active().buildForUnitTests();
LoanOfferingBO loanProduct = new LoanProductBuilder().active().buildForUnitTests();
client.addAccount(loanAccount);
// stubbing
when(loanAccount.isActiveLoanAccount()).thenReturn(true);
when(loanAccount.getLoanOffering()).thenReturn(loanProduct);
// exercise
boolean isDisbursalPrevented = client.isDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProduct(loanProduct);
assertThat(isDisbursalPrevented, is(false));
}
Aggregations