use of org.mifos.domain.builders.PersonnelBuilder in project head by mifos.
the class GroupValidationTest method givenReceivingCenterIsNullShouldFailValidation.
@Test
public void givenReceivingCenterIsNullShouldFailValidation() {
PersonnelBO formedBy = new PersonnelBuilder().build();
group = new GroupBuilder().withName("group-On-center").withParentCustomer(center).formedBy(formedBy).build();
CenterBO toCenter = null;
try {
group.validateReceivingCenter(toCenter);
fail("givenReceivingCenterIsNullShouldThrowCustomerException");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.INVALID_PARENT));
}
}
use of org.mifos.domain.builders.PersonnelBuilder in project head by mifos.
the class PersonnelDaoHibernateIntegrationTest method shouldFindAppUserWithNoRolesByUsername.
@Test
public void shouldFindAppUserWithNoRolesByUsername() {
OfficeBO office = IntegrationTestObjectMother.sampleBranchOffice();
PersonnelBO userWithNoRoles = new PersonnelBuilder().withUsername("noRoles").asLoanOfficer().with(office).build();
IntegrationTestObjectMother.createPersonnel(userWithNoRoles);
// exercise test
MifosUser user = personnelDao.findAuthenticatedUserByUsername("noRoles");
// verification
assertNotNull(user);
}
use of org.mifos.domain.builders.PersonnelBuilder in project head by mifos.
the class SavingsPostInterestTest method whenPostingInterestASavingsAcitvityIsAddedWithCorrectDetails.
@Test
public void whenPostingInterestASavingsAcitvityIsAddedWithCorrectDetails() {
// setup
InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
DateTime activationDate = new DateTime().withDate(2010, 7, 20);
DateTime nextInterestPostingDate = new DateTime().withDate(2010, 7, 31);
savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withNextInterestPostingDateOf(nextInterestPostingDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
// pre verification
assertThat(new LocalDate(savingsAccount.getNextIntPostDate()), is(nextInterestPostingDate.toLocalDate()));
InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().from(nextInterestPostingDate.toLocalDate()).to(nextInterestPostingDate.toLocalDate()).with(calculationPeriod).build();
PersonnelBO createdBy = new PersonnelBuilder().build();
// exercise
savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
// verification
List<SavingsActivityEntity> savingsActivityityDetails = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
SavingsActivityEntity interestPostingActivity = savingsActivityityDetails.get(0);
assertThat(interestPostingActivity.getAccount(), is((AccountBO) savingsAccount));
assertThat(interestPostingActivity.getActivity().getId(), is(AccountActionTypes.SAVINGS_INTEREST_POSTING.getValue()));
assertThat(interestPostingActivity.getAmount(), is(TestUtils.createMoney("100")));
assertThat(datePartOf(interestPostingActivity.getTrxnCreatedDate()), is(nextInterestPostingDate.toLocalDate()));
}
use of org.mifos.domain.builders.PersonnelBuilder in project head by mifos.
the class SavingsPostInterestTest method whenPostingInterestSavingsAccountBalanceIsUpdatedWithAmountToBePosted.
@Test
public void whenPostingInterestSavingsAccountBalanceIsUpdatedWithAmountToBePosted() {
// setup
InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
DateTime activationDate = new DateTime().withDate(2010, 7, 20);
savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
// pre verification
assertThat(savingsAccount.getSavingsBalance(), is(TestUtils.createMoney("0")));
InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().with(calculationPeriod).build();
PersonnelBO createdBy = new PersonnelBuilder().build();
// exercise
savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
// verification
assertThat(savingsAccount.getSavingsBalance(), is(TestUtils.createMoney("100")));
}
use of org.mifos.domain.builders.PersonnelBuilder in project head by mifos.
the class SavingsCloseTest method whenClosingAccountShouldSetStatusAsClosed.
@Test
public void whenClosingAccountShouldSetStatusAsClosed() {
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();
// exercise test
savingsAccount.closeAccount(payment, notes, customer, loggedInUser);
// verification
assertTrue(savingsAccount.getAccountState().isInState(AccountState.SAVINGS_CLOSED));
}
Aggregations