use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class ClientBoTest method testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductDoesNotFetchLoanOfferingIfNoActiveLoanAccounts.
@Test
public void testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductDoesNotFetchLoanOfferingIfNoActiveLoanAccounts() throws Exception {
// setup
client = new ClientBuilder().active().buildForUnitTests();
LoanOfferingBO loanProduct1 = new LoanProductBuilder().withGlobalProductNumber("xxxx-111").withoutLoanAmountSameForAllLoans().buildForUnitTests();
client.addAccount(loanAccount);
// stubbing
when(loanAccount.isActiveLoanAccount()).thenReturn(false);
// exercise
boolean isDisbursalPrevented = client.isDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProduct(loanProduct1);
assertThat(isDisbursalPrevented, is(false));
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class ClientBoTest method testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsFalseIfCustomerHasNoSuchAccountsForThatProduct.
@Test
public void testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsFalseIfCustomerHasNoSuchAccountsForThatProduct() throws Exception {
// setup
client = new ClientBuilder().active().buildForUnitTests();
LoanOfferingBO loanProduct1 = new LoanProductBuilder().withGlobalProductNumber("xxxx-111").withoutLoanAmountSameForAllLoans().buildForUnitTests();
LoanOfferingBO loanProduct2 = new LoanProductBuilder().withGlobalProductNumber("xxxx-222").buildForUnitTests();
client.addAccount(loanAccount);
// stubbing
when(loanAccount.isActiveLoanAccount()).thenReturn(true);
when(loanAccount.getLoanOffering()).thenReturn(loanProduct2);
// exercise
boolean isDisbursalPrevented = client.isDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProduct(loanProduct1);
assertThat(isDisbursalPrevented, is(false));
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class CustomerSearchIdGenerationTest method transferClientFromOfficeToOfficeTest.
@Test
public void transferClientFromOfficeToOfficeTest() throws Exception {
final short office1_id = 2;
// setup
OfficeBO office1 = new OfficeBuilder().withName("office1").branchOffice().withOfficeId(office1_id).build();
PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
ClientBO existingClient = new ClientBuilder().pendingApproval().withNoParent().withLoanOfficer(loanOfficer).buildForUnitTests();
existingClient.setCustomerDao(customerDao);
existingClient = spy(existingClient);
int customer_id = 22;
when(existingClient.getCustomerId()).thenReturn(customer_id);
existingClient.generateSearchId();
UserContext userContext = TestUtils.makeUser();
existingClient.setUserContext(userContext);
// stubbing
when(customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(office1_id)).thenReturn(3);
// exercise test
assertThat(existingClient.getSearchId(), is("1." + customer_id));
customerService.transferClientTo(existingClient, office1);
// verification
assertThat(existingClient.getSearchId(), is("1." + customer_id));
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class CustomerSearchIdGenerationTest method transferGroupFromOfficeToOfficeTest.
@Test
public void transferGroupFromOfficeToOfficeTest() throws Exception {
final short office1_id = 2;
// setup
OfficeBO office1 = new OfficeBuilder().withName("office1").branchOffice().withOfficeId(office1_id).build();
PersonnelBO loanOfficer = PersonnelBuilder.anyLoanOfficer();
GroupBO existingGroup = new GroupBuilder().pendingApproval().withLoanOfficer(loanOfficer).buildAsTopOfHierarchy();
existingGroup = spy(existingGroup);
int customer_id = 22;
when(existingGroup.getCustomerId()).thenReturn(customer_id);
existingGroup.generateSearchId();
ClientBO existingClient = new ClientBuilder().pendingApproval().withParentCustomer(existingGroup).buildForUnitTests();
existingGroup.addChild(existingClient);
existingGroup.setCustomerDao(customerDao);
UserContext userContext = TestUtils.makeUser();
existingGroup.setUserContext(userContext);
// stubbing
when(customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(office1_id)).thenReturn(3);
// exercise test
assertThat(existingGroup.getSearchId(), is("1." + customer_id));
assertThat(existingClient.getSearchId(), is("1." + customer_id + ".1"));
customerService.transferGroupTo(existingGroup, office1);
// verification
assertThat(existingGroup.getSearchId(), is("1." + customer_id));
assertThat(existingClient.getSearchId(), is("1." + customer_id + ".1"));
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class TestCollectionSheetRetrieveSavingsAccountsUtils method createSampleCenterHierarchy.
/**
* By default generates 1 center with a mandatory savings account (center savings accounts are always
* PER_INDIVIDUAL)
*
* 1 group with a voluntary COMPLETE_GROUP savings account
*
* 1 client with a mandatory savings account
*
* 1 group with a mandatory PER_INDIVIDUAL savings account
*
* 1 client with a voluntary savings account
*/
public void createSampleCenterHierarchy() throws Exception {
// TODO - correct clientBuilder so that when there are "PER_INDIVIDUAL" savings accounts relevant to it... a
// saving schedule is created.
//
// As a work-around for this problem... the two "PER_INDIVIDUAL" savings accounts (centerSavingsAccount and
// groupPerIndividualSavingsAccount) are created last... this kicks of a process that creates schedules for all
// the relevant clients.
MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
center = new CenterBuilder().withNumberOfExistingCustomersInOffice(3).with(weeklyMeeting).withName("Savings Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter(center, weeklyMeeting);
if (!onlyCreateCenterAndItsSavingsAccount) {
groupCompleteGroup = new GroupBuilder().withMeeting(weeklyMeeting).withName("Savings Group Complete Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(groupCompleteGroup, weeklyMeeting);
groupCompleteGroupSavingsAccount = createSavingsAccount(groupCompleteGroup, "gvcg", "2.0", true, false);
MeetingBO weeklyClientMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
groupCompleteGroup.setMeeting(weeklyClientMeeting);
clientOfGroupCompleteGroup = new ClientBuilder().withSearchId(center.getSearchId() + ".1.1").withMeeting(weeklyClientMeeting).withName("Savings Client Of Group Complete Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(groupCompleteGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(clientOfGroupCompleteGroup, weeklyClientMeeting);
clientOfGroupCompleteGroupSavingsAccount = createSavingsAccount(clientOfGroupCompleteGroup, "clm", "3.0", false, false);
groupPerIndividual = new GroupBuilder().withMeeting(weeklyMeeting).withName("Savings Group Per Individual").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(groupPerIndividual, weeklyMeeting);
clientOfGroupPerIndividual = new ClientBuilder().withSearchId(center.getSearchId() + ".2.1").withMeeting(weeklyMeeting).withName("Savings Client Of Group Per Individual").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(groupPerIndividual).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(clientOfGroupPerIndividual, weeklyMeeting);
clientOfGroupPerIndividualSavingsAccount = createSavingsAccount(clientOfGroupPerIndividual, "clv", "5.0", true, false);
groupPerIndividualSavingsAccount = createSavingsAccount(groupPerIndividual, "gmi", "4.0", false, true);
}
centerSavingsAccount = createSavingsAccount(center, "cemi", "1.0", false, false);
}
Aggregations