Search in sources :

Example 11 with LoanProductBuilder

use of org.mifos.domain.builders.LoanProductBuilder in project head by mifos.

the class ClientBoTest method testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsTrueIfCustomerHasSuchAccounts.

// @Test
// public void
// testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsTrueIfLoanAmountSameForAllLoansOptionNotChosen()
// throws Exception {
//
// // setup
// client = new ClientBuilder().active().buildForUnitTests();
// LoanOfferingBO loanProduct = new LoanProductBuilder().withGlobalProductNumber("xxxx-111").buildForUnitTests();
//
// // exercise
// boolean isDisbursalPrevented = client
// .isDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProduct(loanProduct);
//
// assertThat(isDisbursalPrevented, is(true));
// }
@Test
public void testIsDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProductReturnsTrueIfCustomerHasSuchAccounts() throws Exception {
    // setup
    client = new ClientBuilder().active().buildForUnitTests();
    LoanOfferingBO loanProduct = new LoanProductBuilder().active().withoutLoanAmountSameForAllLoans().buildForUnitTests();
    client.addAccount(loanAccount);
    // stubbing
    when(loanAccount.isActiveLoanAccount()).thenReturn(true);
    when(loanAccount.getLoanOffering()).thenReturn(loanProduct);
    // exercise
    boolean isDisbursalPrevented = client.isDisbursalPreventedDueToAnyExistingActiveLoansForTheSameProduct(loanProduct);
    assertThat(isDisbursalPrevented, is(true));
}
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)

Example 12 with LoanProductBuilder

use of org.mifos.domain.builders.LoanProductBuilder in project head by mifos.

the class GroupPerformanceHistoryUsingCustomerServiceIntegrationTest method cleanDatabaseTables.

@Before
public void cleanDatabaseTables() throws Exception {
    databaseCleaner.clean();
    existingUser = IntegrationTestObjectMother.testUser();
    existingLoanOfficer = IntegrationTestObjectMother.testUser();
    existingOffice = IntegrationTestObjectMother.sampleBranchOffice();
    existingMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
    IntegrationTestObjectMother.saveMeeting(existingMeeting);
    existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
    IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
    existingGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_ACTIVE).withParentCustomer(existingCenter).formedBy(existingUser).build();
    IntegrationTestObjectMother.createGroup(existingGroup, existingMeeting);
    existingActiveClient = new ClientBuilder().withName("activeClient").withStatus(CustomerStatus.CLIENT_ACTIVE).withParentCustomer(existingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingActiveClient, existingMeeting);
    existingOnHoldClient = new ClientBuilder().withName("onHoldClient").withStatus(CustomerStatus.CLIENT_HOLD).withParentCustomer(existingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingOnHoldClient, existingMeeting);
    existingCancelledClient = new ClientBuilder().withName("cancelledClient").withStatus(CustomerStatus.CLIENT_CANCELLED).withParentCustomer(existingGroup).buildForIntegrationTests();
    IntegrationTestObjectMother.createClient(existingCancelledClient, existingMeeting);
    DateTime startDate = new DateTime().toDateMidnight().toDateTime();
    LoanOfferingBO groupLoanProduct = new LoanProductBuilder().appliesToGroupsOnly().active().withMeeting(existingMeeting).withName("Loandsdasd").withShortName("fsad").withStartDate(startDate).withDefaultInterest(1.2).buildForIntegrationTests();
    IntegrationTestObjectMother.createProduct(groupLoanProduct);
    account1 = new LoanAccountBuilder().withLoanProduct(groupLoanProduct).withCustomer(existingGroup).withOriginalLoanAmount(400.0).build();
    IntegrationTestObjectMother.saveLoanAccount(account1);
    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);
    account2 = new LoanAccountBuilder().withLoanProduct(clientLoanProduct).withCustomer(existingActiveClient).withOriginalLoanAmount(600.0).build();
    IntegrationTestObjectMother.saveLoanAccount(account2);
    StaticHibernateUtil.flushAndClearSession();
}
Also used : LoanAccountBuilder(org.mifos.domain.builders.LoanAccountBuilder) GroupBuilder(org.mifos.domain.builders.GroupBuilder) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) DateTime(org.joda.time.DateTime) ClientBuilder(org.mifos.domain.builders.ClientBuilder) Before(org.junit.Before)

Example 13 with LoanProductBuilder

use of org.mifos.domain.builders.LoanProductBuilder in project head by mifos.

the class PrdOfferingBOTest method testMergeQuestionGroups.

public void testMergeQuestionGroups() {
    LoanOfferingBO loanOfferingBO = new LoanProductBuilder().buildForUnitTests();
    Set<QuestionGroupReference> questionGroupReferences = getQustionGroups(1, 2, 3, 4);
    loanOfferingBO.mergeQuestionGroups(questionGroupReferences);
    Set<QuestionGroupReference> questionGroups = loanOfferingBO.getQuestionGroups();
    assertThat(questionGroups, is(questionGroupReferences));
    questionGroupReferences = getQustionGroups(2, 5);
    loanOfferingBO.mergeQuestionGroups(questionGroupReferences);
    questionGroups = loanOfferingBO.getQuestionGroups();
    assertThat(questionGroups.size(), is(2));
    QuestionGroupReference[] qgRefs = questionGroups.toArray(new QuestionGroupReference[questionGroups.size()]);
    assertThat(qgRefs[0].getQuestionGroupId(), is(2));
    assertThat(qgRefs[1].getQuestionGroupId(), is(5));
    loanOfferingBO.mergeQuestionGroups(null);
    assertThat(loanOfferingBO.getQuestionGroups(), is(nullValue()));
}
Also used : LoanProductBuilder(org.mifos.domain.builders.LoanProductBuilder)

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