use of org.mifos.domain.builders.GroupBuilder in project head by mifos.
the class GroupCreationTest method createsGroupWithCustomerAccount.
@Test
public void createsGroupWithCustomerAccount() throws Exception {
// setup
OfficeBO withOffice = new OfficeBO(new Short("1"), "testOffice", new Integer("1"), new Short("1"));
CenterBO parent = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).with(withOffice).build();
GroupBO stubbedGroup = new GroupBuilder().withName("group").withParentCustomer(parent).formedBy(anyLoanOfficer()).build();
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stub
CalendarEvent upcomingCalendarEvents = new CalendarEventBuilder().build();
when(holidayDao.findCalendarEventsForThisYearAndNext((short) 1)).thenReturn(upcomingCalendarEvents);
when(customerAccountFactory.create(stubbedGroup, accountFees, meeting, upcomingCalendarEvents)).thenReturn(customerAccount);
when(customerAccount.getType()).thenReturn(AccountTypes.CUSTOMER_ACCOUNT);
// exercise test
customerService.createGroup(stubbedGroup, meeting, accountFees);
// verification
assertThat(stubbedGroup.getCustomerAccount(), is(customerAccount));
}
use of org.mifos.domain.builders.GroupBuilder in project head by mifos.
the class GroupCreationTest method rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs.
@Test(expected = MifosRuntimeException.class)
public void rollsbackTransactionClosesSessionAndThrowsRuntimeExceptionWhenExceptionOccurs() throws Exception {
// setup
CenterBO parent = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).build();
GroupBO stubbedGroup = new GroupBuilder().withName("group").withParentCustomer(parent).formedBy(anyLoanOfficer()).build();
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stub
doThrow(new RuntimeException()).when(customerDao).save(stubbedGroup);
// exercise test
customerService.createGroup(stubbedGroup, meeting, accountFees);
// verification
verify(hibernateTransactionHelper).rollbackTransaction();
verify(hibernateTransactionHelper).closeSession();
}
use of org.mifos.domain.builders.GroupBuilder in project head by mifos.
the class GroupTransferToCenterTest method transferingGroupToCenterInDifferentBranchCreatesNewCustomerMovementsForGroupAndChangesGroupStatusFromActiveToOnHold.
@Test
public void transferingGroupToCenterInDifferentBranchCreatesNewCustomerMovementsForGroupAndChangesGroupStatusFromActiveToOnHold() throws Exception {
// setup
OfficeBO fromBranch = new OfficeBuilder().branchOffice().withName("fromBranch").withGlobalOfficeNum("xxx1").build();
CenterBO fromCenter = new CenterBuilder().withName("fromCenter").with(fromBranch).build();
GroupBO groupForTransfer = new GroupBuilder().withParentCustomer(fromCenter).active().build();
OfficeBO receivingBranch = new OfficeBuilder().branchOffice().withName("receivingBranch").withGlobalOfficeNum("xxx2").build();
CenterBO receivingCenter = new CenterBuilder().withName("receivingCenter").with(receivingBranch).build();
// exercise test
groupForTransfer.transferTo(receivingCenter);
// verification
assertThat(groupForTransfer.getStatus().isGroupActive(), is(false));
assertThat(groupForTransfer.getStatus().isGroupOnHold(), is(true));
assertThat(groupForTransfer.countOfCustomerMovements(), is(2));
}
use of org.mifos.domain.builders.GroupBuilder in project head by mifos.
the class GroupTransferToOfficeServiceTest method givenOfficeIsSameAsGroupsOfficeGroupTransferToBranchShouldFailValidation.
@Test
public void givenOfficeIsSameAsGroupsOfficeGroupTransferToBranchShouldFailValidation() {
// setup
OfficeBO office = new OfficeBuilder().build();
CenterBO parent = new CenterBuilder().with(office).build();
GroupBO group = new GroupBuilder().withParentCustomer(parent).build();
// exercise test
try {
customerService.transferGroupTo(group, office);
fail("should fail validation");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_SAME_BRANCH_TRANSFER));
}
}
use of org.mifos.domain.builders.GroupBuilder 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