use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class CustomerAccountCreationTest method customerAccountIsNotCreatedWithCustomerSchedulesWhenAssociatedCustomerIsNotActive.
@Test
public void customerAccountIsNotCreatedWithCustomerSchedulesWhenAssociatedCustomerIsNotActive() throws Exception {
// setup
accountFees = new ArrayList<AccountFeesEntity>();
customer = new CenterBuilder().inActive().build();
// exercise test
customerAccount = CustomerAccountBO.createNew(customer, accountFees, customerMeeting, applicableCalendarEvents);
// verification
assertThat(customerAccount.getAccountActionDates().isEmpty(), is(true));
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class GroupTransferToCenterServiceTest method rollsbackTransactionOnException.
@Test(expected = RuntimeException.class)
public void rollsbackTransactionOnException() throws Exception {
// setup
CenterBO toCenter = new CenterBuilder().build();
// stubbing
when(group.isDifferentBranch(toCenter.getOffice())).thenReturn(false);
when(group.getUserContext()).thenReturn(TestUtils.makeUser());
doThrow(new RuntimeException()).when(customerDao).save(group);
// exercise test
customerService.transferGroupTo(group, toCenter);
// verification
verify(hibernateTransaction).rollbackTransaction();
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class GroupTransferToCenterServiceTest method validatesGroupNameIsNotAlreadyTakenWhenTransferingGroupToDifferentOffice.
@Test(expected = CustomerException.class)
public void validatesGroupNameIsNotAlreadyTakenWhenTransferingGroupToDifferentOffice() throws Exception {
// setup
CenterBO toCenter = new CenterBuilder().build();
// stubbing
when(group.isDifferentBranch(toCenter.getOffice())).thenReturn(true);
doThrow(new CustomerException(CustomerConstants.ERRORS_DUPLICATE_CUSTOMER)).when(customerDao).validateGroupNameIsNotTakenForOffice(anyString(), eq(toCenter.getOfficeId()));
// exercise test
customerService.transferGroupTo(group, toCenter);
// verification
verify(customerDao).validateGroupNameIsNotTakenForOffice(anyString(), eq(toCenter.getOfficeId()));
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class GroupTransferToCenterServiceTest method transfersGroupToReceivingCenter.
@Test
public void transfersGroupToReceivingCenter() throws Exception {
// setup
CenterBO toCenter = new CenterBuilder().build();
// stubbing
when(group.isDifferentBranch(toCenter.getOffice())).thenReturn(false);
when(group.getUserContext()).thenReturn(TestUtils.makeUser());
// exercise test
customerService.transferGroupTo(group, toCenter);
// verification
verify(group).transferTo(toCenter);
}
use of org.mifos.domain.builders.CenterBuilder in project head by mifos.
the class SavingsScheduleIntegrationTest method createClientSavingsAccount.
public void createClientSavingsAccount() throws Exception {
meeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(expectedFirstDepositDate).build();
IntegrationTestObjectMother.saveMeeting(meeting);
center = new CenterBuilder().with(meeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter(center, meeting);
group = new GroupBuilder().withMeeting(meeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(group, meeting);
client = new ClientBuilder().withMeeting(meeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(client, meeting);
savingsProduct = new SavingsProductBuilder().mandatory().appliesToClientsOnly().buildForIntegrationTests();
HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
List<Holiday> holidays = holidayDao.findAllHolidaysThisYearAndNext(client.getOfficeId());
savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(client).with(holidays).build();
IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
}
Aggregations