use of org.mifos.domain.builders.LoanProductBuilder in project head by mifos.
the class QuestionGroupFilterForLoanTest method shouldDoFilter.
@Test
public void shouldDoFilter() {
QuestionGroupFilterForLoan questionGroupFilterForLoan = new QuestionGroupFilterForLoan();
LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
loanOfferingBO.setQuestionGroups(getQustionGroups(2, 4));
questionGroupFilterForLoan.setLoanOfferingBO(loanOfferingBO);
List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1"), getQuestionGroupDetail(2, "QG2"), getQuestionGroupDetail(3, "QG3"), getQuestionGroupDetail(4, "QG4"));
List<QuestionGroupDetail> filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(questionGroupDetails, new Criteria<QuestionGroupDetail>() {
@Override
public QuestionGroupDetail filter(Integer questionGroupId, List<QuestionGroupDetail> questionGroupDetails) {
QuestionGroupDetail result = null;
for (QuestionGroupDetail questionGroupDetail : questionGroupDetails) {
if (questionGroupId.equals(questionGroupDetail.getId())) {
result = questionGroupDetail;
break;
}
}
return result;
}
});
assertThat(filteredQuestionGroupDetails, is(notNullValue()));
assertThat(filteredQuestionGroupDetails.size(), is(2));
assertThat(filteredQuestionGroupDetails.get(0).getId(), is(2));
assertThat(filteredQuestionGroupDetails.get(0).getTitle(), is("QG2"));
assertThat(filteredQuestionGroupDetails.get(1).getId(), is(4));
assertThat(filteredQuestionGroupDetails.get(1).getTitle(), is("QG4"));
}
use of org.mifos.domain.builders.LoanProductBuilder in project head by mifos.
the class QuestionGroupFilterForLoanTest method shouldDoFilterForNoLoanOfferingQuestionGroups.
@Test
public void shouldDoFilterForNoLoanOfferingQuestionGroups() {
QuestionGroupFilterForLoan questionGroupFilterForLoan = new QuestionGroupFilterForLoan();
LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
loanOfferingBO.setQuestionGroups(new HashSet<QuestionGroupReference>());
questionGroupFilterForLoan.setLoanOfferingBO(loanOfferingBO);
List<QuestionGroupDetail> questionGroupDetails = asList(getQuestionGroupDetail(1, "QG1"), getQuestionGroupDetail(2, "QG2"), getQuestionGroupDetail(3, "QG3"), getQuestionGroupDetail(4, "QG4"));
List<QuestionGroupDetail> filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(questionGroupDetails, null);
assertThat(filteredQuestionGroupDetails, is(notNullValue()));
assertThat(filteredQuestionGroupDetails.size(), is(0));
loanOfferingBO.setQuestionGroups(null);
filteredQuestionGroupDetails = questionGroupFilterForLoan.doFilter(questionGroupDetails, null);
assertThat(filteredQuestionGroupDetails, is(notNullValue()));
assertThat(filteredQuestionGroupDetails.size(), is(0));
}
use of org.mifos.domain.builders.LoanProductBuilder in project head by mifos.
the class LoanProductDaoHibernateIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
databaseCleaner.clean();
activeLoanProduct = new LoanProductBuilder().active().withName("Active Loan Product").withShortName("ALP").appliesToGroupsOnly().withGlobalProductNumber("AAA-111").buildForIntegrationTests();
inActiveLoanProduct = new LoanProductBuilder().inActive().withName("inActive Loan Product").withShortName("ILP").appliesToGroupsOnly().withGlobalProductNumber("AAA-112").buildForIntegrationTests();
IntegrationTestObjectMother.saveLoanProducts(activeLoanProduct, inActiveLoanProduct);
}
use of org.mifos.domain.builders.LoanProductBuilder in project head by mifos.
the class ClientStatusChangeIntegrationTest method givenClientHasActiveAccountsShouldNotPassValidationWhenTryingToTranistionClientToClosed.
@Test
public void givenClientHasActiveAccountsShouldNotPassValidationWhenTryingToTranistionClientToClosed() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").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 existingActiveClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_ACTIVE).withParentCustomer(existingActiveGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingActiveClient, existingMeeting);
StaticHibernateUtil.flushAndClearSession();
DateTime startDate = new DateTime().minusDays(14);
LoanOfferingBO clientLoanProduct = new LoanProductBuilder().appliesToClientsOnly().withGlobalProductNumber("XXX-00002").active().withMeeting(existingMeeting).withName("Loan-client").withShortName("dsvd").withStartDate(startDate).withDefaultInterest(1.2).buildForIntegrationTests();
IntegrationTestObjectMother.createProduct(clientLoanProduct);
LoanBO clientLoan = new LoanAccountBuilder().withLoanProduct(clientLoanProduct).withCustomer(existingActiveClient).withOriginalLoanAmount(600.0).build();
IntegrationTestObjectMother.saveLoanAccount(clientLoan);
existingActiveGroup = this.customerDao.findGroupBySystemId(existingActiveGroup.getGlobalCustNum());
existingActiveClient = this.customerDao.findClientBySystemId(existingActiveClient.getGlobalCustNum());
existingActiveClient.setUserContext(TestUtils.makeUser());
CustomerStatusFlag customerStatusFlag = null;
CustomerNoteEntity customerNote = new CustomerNoteEntity("go active", new Date(), existingActiveClient.getPersonnel(), existingActiveClient);
// exercise test
try {
customerService.updateClientStatus(existingActiveClient, existingActiveClient.getStatus(), CustomerStatus.CLIENT_CLOSED, customerStatusFlag, customerNote);
fail("should fail validation");
} catch (CustomerException expected) {
assertThat(expected.getKey(), is(CustomerConstants.CUSTOMER_HAS_ACTIVE_ACCOUNTS_EXCEPTION));
assertThat(existingActiveClient.getStatus(), is(CustomerStatus.CLIENT_ACTIVE));
}
}
use of org.mifos.domain.builders.LoanProductBuilder 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));
}
Aggregations