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));
}
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();
}
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()));
}
Aggregations