use of org.mifos.domain.builders.ClientBuilder 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.ClientBuilder 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.ClientBuilder in project head by mifos.
the class GroupStatusChangeIntegrationTest method givenGroupIsPendingAndContainsClientsInPartialStateThenWhenTransitioningToCancelledStateAllClientsAreTransitionedToPartial.
@Test
public void givenGroupIsPendingAndContainsClientsInPartialStateThenWhenTransitioningToCancelledStateAllClientsAreTransitionedToPartial() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
GroupBO existingPendingGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_PENDING).withParentCustomer(existingCenter).formedBy(existingUser).build();
IntegrationTestObjectMother.createGroup(existingPendingGroup, existingMeeting);
ClientBO existingPartialClient = new ClientBuilder().withName("partialClient").withStatus(CustomerStatus.CLIENT_PARTIAL).withParentCustomer(existingPendingGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingPartialClient, existingMeeting);
ClientBO existingPendingClient = new ClientBuilder().withName("pendingClient").withStatus(CustomerStatus.CLIENT_PENDING).withParentCustomer(existingPendingGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingPendingClient, existingMeeting);
existingPendingGroup = this.customerDao.findGroupBySystemId(existingPendingGroup.getGlobalCustNum());
existingPendingGroup.setUserContext(TestUtils.makeUser());
StaticHibernateUtil.startTransaction();
existingPartialClient = this.customerDao.findClientBySystemId(existingPartialClient.getGlobalCustNum());
existingPendingClient = this.customerDao.findClientBySystemId(existingPendingClient.getGlobalCustNum());
CustomerStatusFlag customerStatusFlag = CustomerStatusFlag.GROUP_CANCEL_BLACKLISTED;
CustomerNoteEntity customerNote = new CustomerNoteEntity("Made Inactive", new java.util.Date(), existingPendingGroup.getPersonnel(), existingPendingGroup);
// exercise test
customerService.updateGroupStatus(existingPendingGroup, existingPendingGroup.getStatus(), CustomerStatus.GROUP_CANCELLED, customerStatusFlag, customerNote);
// verification
assertThat(existingPendingGroup.getStatus(), is(CustomerStatus.GROUP_CANCELLED));
assertThat(existingPendingClient.getStatus(), is(CustomerStatus.CLIENT_PENDING));
assertThat(existingPartialClient.getStatus(), is(CustomerStatus.CLIENT_PARTIAL));
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class CustomerTrxnDetailEntityIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
userContext = TestUtils.makeUser();
OfficeBO office = IntegrationTestObjectMother.sampleBranchOffice();
PersonnelBO testUser = IntegrationTestObjectMother.testUser();
weeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday().build();
IntegrationTestObjectMother.saveMeeting(weeklyMeeting);
center = new CenterBuilder().with(weeklyMeeting).withName("Center").with(office).withLoanOfficer(testUser).build();
IntegrationTestObjectMother.createCenter(center, weeklyMeeting);
group = new GroupBuilder().withMeeting(weeklyMeeting).withName("Group").withOffice(office).withLoanOfficer(testUser).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(group, weeklyMeeting);
client = new ClientBuilder().withMeeting(weeklyMeeting).withName("Client 1").withOffice(office).withLoanOfficer(testUser).withParentCustomer(group).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(client, weeklyMeeting);
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class ClientStatusChangeIntegrationTest method givenGroupIsInCancelledStateShouldNotPassValidationWhenTryingToTranistionClientToActive.
@Test
public void givenGroupIsInCancelledStateShouldNotPassValidationWhenTryingToTranistionClientToActive() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
GroupBO existingCancelledGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_CANCELLED).withParentCustomer(existingCenter).formedBy(existingUser).build();
IntegrationTestObjectMother.createGroup(existingCancelledGroup, existingMeeting);
ClientBO existingPartialClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_PARTIAL).withParentCustomer(existingCancelledGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingPartialClient, existingMeeting);
existingCancelledGroup = this.customerDao.findGroupBySystemId(existingCancelledGroup.getGlobalCustNum());
existingPartialClient = this.customerDao.findClientBySystemId(existingPartialClient.getGlobalCustNum());
existingPartialClient.setUserContext(TestUtils.makeUser());
CustomerStatusFlag customerStatusFlag = null;
CustomerNoteEntity customerNote = new CustomerNoteEntity("go active", new Date(), existingPartialClient.getPersonnel(), existingPartialClient);
// exercise test
try {
customerService.updateClientStatus(existingPartialClient, existingPartialClient.getStatus(), CustomerStatus.CLIENT_ACTIVE, customerStatusFlag, customerNote);
fail("should fail validation");
} catch (CustomerException expected) {
assertThat(expected.getKey(), is(ClientConstants.ERRORS_GROUP_CANCELLED));
assertThat(existingPartialClient.getStatus(), is(CustomerStatus.CLIENT_PARTIAL));
}
}
Aggregations