use of org.mifos.domain.builders.LoanProductBuilder 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.LoanProductBuilder in project head by mifos.
the class LoanAdjustmentsIntegrationTest method createLoan.
private LoanBO createLoan() throws Exception {
MeetingBO weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter(center, weeklyMeeting);
group = new GroupBuilder().withMeeting(weeklyMeeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(group, weeklyMeeting);
client = new ClientBuilder().withMeeting(weeklyMeeting).withName("Client").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(client, weeklyMeeting);
LoanOfferingBO loanOffering = new LoanProductBuilder().withName("Adjust Loan Product").withMeeting(weeklyMeeting).buildForIntegrationTests();
IntegrationTestObjectMother.createProduct(loanOffering);
AmountFeeBO periodicFee = new FeeBuilder().appliesToLoans().periodic().withFeeAmount("10.0").withName("Periodic Fee").with(sampleBranchOffice()).build();
IntegrationTestObjectMother.saveFee(periodicFee);
BigDecimal loanAmount = BigDecimal.valueOf(Double.valueOf("1000.0"));
BigDecimal minAllowedLoanAmount = loanAmount;
BigDecimal maxAllowedLoanAmount = loanAmount;
Double interestRate = loanOffering.getDefInterestRate();
LocalDate disbursementDate = new LocalDate();
int numberOfInstallments = 10;
int minAllowedNumberOfInstallments = loanOffering.getEligibleInstallmentSameForAllLoan().getMaxNoOfInstall();
int maxAllowedNumberOfInstallments = loanOffering.getEligibleInstallmentSameForAllLoan().getMaxNoOfInstall();
int graceDuration = 0;
Integer sourceOfFundId = null;
Integer loanPurposeId = null;
Integer collateralTypeId = null;
String collateralNotes = null;
String externalId = null;
boolean repaymentScheduleIndependentOfCustomerMeeting = false;
RecurringSchedule recurringSchedule = null;
List<CreateAccountFeeDto> accountFees = new ArrayList<CreateAccountFeeDto>();
accountFees.add(new CreateAccountFeeDto(periodicFee.getFeeId().intValue(), periodicFee.getFeeAmount().toString()));
CreateLoanAccount createLoanAccount = new CreateLoanAccount(client.getCustomerId(), loanOffering.getPrdOfferingId().intValue(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING.getValue().intValue(), loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount, interestRate, disbursementDate, null, numberOfInstallments, minAllowedNumberOfInstallments, maxAllowedNumberOfInstallments, graceDuration, sourceOfFundId, loanPurposeId, collateralTypeId, collateralNotes, externalId, repaymentScheduleIndependentOfCustomerMeeting, recurringSchedule, accountFees, new ArrayList<CreateAccountPenaltyDto>());
return IntegrationTestObjectMother.createClientLoan(createLoanAccount);
}
use of org.mifos.domain.builders.LoanProductBuilder in project head by mifos.
the class QuestionGroupFilterForLoanTest method shouldDoFilterForNoQuestionGroupDetails.
@Test
public void shouldDoFilterForNoQuestionGroupDetails() {
QuestionGroupFilterForLoan questionGroupFilterForLoan = new QuestionGroupFilterForLoan();
LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
loanOfferingBO.setQuestionGroups(getQustionGroups(2, 4));
questionGroupFilterForLoan.setLoanOfferingBO(loanOfferingBO);
List<QuestionGroupDetail> filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(null, null);
assertThat(filteredQuestionGroupDetails, is(nullValue()));
}
use of org.mifos.domain.builders.LoanProductBuilder in project head by mifos.
the class LoanPrdActionTest method shouldSetSelectedQuestionGroupsOnSession.
@Test
public void shouldSetSelectedQuestionGroupsOnSession() throws PageExpiredException {
List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1", true), getQuestionGroupDetail(2, "QG2", true), getQuestionGroupDetail(3, "QG3", false));
when(questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(1)).thenReturn(questionGroupDetails.get(0));
when(questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(2)).thenReturn(questionGroupDetails.get(1));
when(questionnaireServiceFacade.getQuestionGroupDetailForLoanPrd(3)).thenReturn(questionGroupDetails.get(2));
when(request.getAttribute(Constants.CURRENTFLOWKEY)).thenReturn(FLOW_KEY);
when(request.getSession()).thenReturn(session);
when(session.getAttribute(Constants.FLOWMANAGER)).thenReturn(flowManager);
Flow flow = new Flow();
when(flowManager.getFlowWithValidation(FLOW_KEY)).thenReturn(flow);
LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
loanOfferingBO.setQuestionGroups(getQustionGroups(1, 2, 3));
loanPrdAction.setSelectedQuestionGroupsOnSession(request, loanOfferingBO, questionnaireServiceFacade);
List<QuestionGroupDetail> questionGroupDetailList = (List<QuestionGroupDetail>) flow.getObjectFromSession(ProductDefinitionConstants.SELECTEDQGLIST);
assertThat(questionGroupDetailList, is(notNullValue()));
assertThat(questionGroupDetailList.size(), is(2));
assertQuestionGroup(questionGroupDetailList.get(0), 1, "QG1");
assertQuestionGroup(questionGroupDetailList.get(1), 2, "QG2");
verify(questionnaireServiceFacade, times(3)).getQuestionGroupDetailForLoanPrd(anyInt());
verify(request, times(1)).getAttribute(Constants.CURRENTFLOWKEY);
verify(request, times(1)).getSession();
verify(session, times(1)).getAttribute(Constants.FLOWMANAGER);
}
use of org.mifos.domain.builders.LoanProductBuilder 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