Search in sources :

Example 1 with LoanProductBuilder

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"));
}
Also used : QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) Test(org.junit.Test)

Example 2 with LoanProductBuilder

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));
}
Also used : QuestionGroupReference(org.mifos.accounts.productdefinition.business.QuestionGroupReference) QuestionGroupDetail(org.mifos.platform.questionnaire.service.QuestionGroupDetail) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) Test(org.junit.Test)

Example 3 with LoanProductBuilder

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);
}
Also used : LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) Before(org.junit.Before)

Example 4 with LoanProductBuilder

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));
    }
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) CustomerException(org.mifos.customers.exceptions.CustomerException) CustomerStatusFlag(org.mifos.customers.util.helpers.CustomerStatusFlag) LoanAccountBuilder(org.mifos.domain.builders.LoanAccountBuilder) GroupBuilder(org.mifos.domain.builders.GroupBuilder) ClientBO(org.mifos.customers.client.business.ClientBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) DateTime(org.joda.time.DateTime) Date(java.util.Date) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) GroupBO(org.mifos.customers.group.business.GroupBO) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Example 5 with LoanProductBuilder

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));
}
Also used : LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Test(org.junit.Test)

Aggregations

LoanProductBuilder (org.mifos.domain.builders.LoanProductBuilder)13 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)11 Test (org.junit.Test)9 ClientBuilder (org.mifos.domain.builders.ClientBuilder)7 QuestionGroupDetail (org.mifos.platform.questionnaire.service.QuestionGroupDetail)4 CenterBuilder (org.mifos.domain.builders.CenterBuilder)3 GroupBuilder (org.mifos.domain.builders.GroupBuilder)3 DateTime (org.joda.time.DateTime)2 Before (org.junit.Before)2 LoanAccountBuilder (org.mifos.domain.builders.LoanAccountBuilder)2 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)2 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Date (java.util.Date)1 List (java.util.List)1 LocalDate (org.joda.time.LocalDate)1 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 QuestionGroupReference (org.mifos.accounts.productdefinition.business.QuestionGroupReference)1