use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class SavingsCloseTest method setupForEachTest.
@Before
public void setupForEachTest() {
client = new ClientBuilder().active().buildForUnitTests();
savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").withMaxWithdrawalAmount(TestUtils.createMoney("400")).appliesToClientsOnly().buildForUnitTests();
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class SavingsCloseTest method whenClosingAccountShouldPostInterestWhenRemainingSavingsBalanceIsLessThanAmountBeingWithdrawn.
@Test
public void whenClosingAccountShouldPostInterestWhenRemainingSavingsBalanceIsLessThanAmountBeingWithdrawn() {
Money remainingBalance = TestUtils.createMoney("100");
savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(remainingBalance).build();
Money withdrawalAtCloseAmount = TestUtils.createMoney("105.56");
AccountPaymentEntity payment = new AccountPaymentEntityBuilder().with(savingsAccount).with(withdrawalAtCloseAmount).build();
AccountNotesEntity notes = new AccountNotesEntityBuilder().build();
CustomerBO customer = new ClientBuilder().buildForUnitTests();
PersonnelBO loggedInUser = new PersonnelBuilder().build();
// pre verification
assertTrue(savingsAccount.getAccountPayments().isEmpty());
// exercise test
savingsAccount.closeAccount(payment, notes, customer, loggedInUser);
// verification
assertFalse(savingsAccount.getAccountPayments().isEmpty());
assertThat(savingsAccount.getAccountPayments().size(), is(2));
AccountPaymentEntity interestPayment = savingsAccount.getAccountPayments().get(0);
assertThat(interestPayment.getAmount(), is(TestUtils.createMoney("5.56")));
AccountPaymentEntity withdrawalPayment = savingsAccount.getAccountPayments().get(1);
assertThat(withdrawalPayment.getAmount(), is(TestUtils.createMoney("105.56")));
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class SavingsCloseTest method whenClosingAccountShouldCreateStatusChangeHistoryForClosure.
@Test
public void whenClosingAccountShouldCreateStatusChangeHistoryForClosure() {
Money remainingBalance = TestUtils.createMoney("100");
savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(remainingBalance).build();
AccountPaymentEntity payment = new AccountPaymentEntityBuilder().with(savingsAccount).with(remainingBalance).build();
AccountNotesEntity notes = new AccountNotesEntityBuilder().build();
CustomerBO customer = new ClientBuilder().buildForUnitTests();
PersonnelBO loggedInUser = new PersonnelBuilder().build();
// pre verification
assertThat(savingsAccount.getAccountStatusChangeHistory().size(), is(1));
// exercise test
savingsAccount.closeAccount(payment, notes, customer, loggedInUser);
// verification
assertThat(savingsAccount.getAccountStatusChangeHistory().size(), is(2));
AccountStatusChangeHistoryEntity closure = savingsAccount.getAccountStatusChangeHistory().get(1);
assertThat(closure.getAccount(), is((AccountBO) savingsAccount));
assertTrue(closure.getOldStatus().isInState(AccountState.SAVINGS_ACTIVE));
assertTrue(closure.getNewStatus().isInState(AccountState.SAVINGS_CLOSED));
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class SavingsAdjustmentTest method setupForEachTest.
@Before
public void setupForEachTest() {
client = new ClientBuilder().active().buildForUnitTests();
savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToClientsOnly().buildForUnitTests();
}
use of org.mifos.domain.builders.ClientBuilder in project head by mifos.
the class CenterStatusChangeIntegrationTest method givenCenterIsInactiveAndAssignedLoanOfficerIsInactiveShouldNotPassValidationWhenTryingToTranistionClientToActive.
@Test
public void givenCenterIsInactiveAndAssignedLoanOfficerIsInactiveShouldNotPassValidationWhenTryingToTranistionClientToActive() throws Exception {
// setup
CenterBO existingCenter = new CenterBuilder().with(existingMeeting).withName("Center-IntegrationTest").with(existingOffice).withLoanOfficer(existingLoanOfficer).withUserContext().build();
existingCenter.updateCustomerStatus(CustomerStatus.CENTER_INACTIVE);
IntegrationTestObjectMother.createCenter(existingCenter, existingMeeting);
existingLoanOfficer = this.personnelDao.findPersonnelById(existingLoanOfficer.getPersonnelId());
updatePersonnel(existingLoanOfficer, PersonnelLevel.LOAN_OFFICER, PersonnelStatus.INACTIVE, existingOffice);
GroupBO existingPartialGroup = new GroupBuilder().withName("newGroup").withStatus(CustomerStatus.GROUP_PARTIAL).withParentCustomer(existingCenter).formedBy(existingUser).build();
IntegrationTestObjectMother.createGroup(existingPartialGroup, existingMeeting);
ClientBO existingPartialClient = new ClientBuilder().withStatus(CustomerStatus.CLIENT_PARTIAL).withParentCustomer(existingPartialGroup).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(existingPartialClient, existingMeeting);
StaticHibernateUtil.flushAndClearSession();
existingCenter = this.customerDao.findCenterBySystemId(existingCenter.getGlobalCustNum());
existingCenter.setUserContext(TestUtils.makeUser());
existingPartialGroup = this.customerDao.findGroupBySystemId(existingPartialGroup.getGlobalCustNum());
existingPartialClient = this.customerDao.findClientBySystemId(existingPartialClient.getGlobalCustNum());
existingPartialClient.setUserContext(TestUtils.makeUser());
CustomerStatusFlag customerStatusFlag = null;
CustomerNoteEntity customerNote = new CustomerNoteEntity("go active", new Date(), existingCenter.getPersonnel(), existingCenter);
// exercise test
try {
customerService.updateCenterStatus(existingCenter, CustomerStatus.CENTER_ACTIVE, customerStatusFlag, customerNote);
fail("should fail validation");
} catch (CustomerException expected) {
assertThat(expected.getKey(), is(CustomerConstants.CUSTOMER_LOAN_OFFICER_INACTIVE_EXCEPTION));
assertThat(existingCenter.getStatus(), is(CustomerStatus.CENTER_INACTIVE));
}
}
Aggregations