use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CustomerStatusUpdateTest method throwsCheckedExceptionWhenCenterTransitionsToInActiveStateAndFailsValidation.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenCenterTransitionsToInActiveStateAndFailsValidation() throws Exception {
// setup
OfficeBO office = new OfficeBuilder().withGlobalOfficeNum("xxx-9999").build();
UserContext userContext = TestUtils.makeUser();
CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().with(CustomerStatus.CENTER_INACTIVE).build();
// stubbing
when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(mockedCenter);
when(mockedCenter.getOffice()).thenReturn(office);
when(mockedCenter.getCustomerStatus()).thenReturn(new CustomerStatusEntity(CustomerStatus.CENTER_ACTIVE));
doThrow(new CustomerException(CustomerConstants.CENTER_STATE_CHANGE_EXCEPTION)).when(mockedCenter).validateChangeToInActive();
// exercise test
customerService.updateCustomerStatus(userContext, customerStatusUpdate);
// verification
verify(mockedCenter).validateChangeToInActive();
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupCreationTest method throwsCheckedExceptionWhenGroupNameIsTakenForOfficeAlready.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenGroupNameIsTakenForOfficeAlready() throws Exception {
// setup
CenterBO parent = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).build();
GroupBO stubbedGroup = new GroupBuilder().withName("already-exists-group").withParentCustomer(parent).formedBy(anyLoanOfficer()).build();
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stubbing
doThrow(new CustomerException(CustomerConstants.ERRORS_DUPLICATE_CUSTOMER)).when(customerDao).validateGroupNameIsNotTakenForOffice(anyString(), anyShort());
// exercise test
customerService.createGroup(stubbedGroup, meeting, accountFees);
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupTransferToCenterServiceTest method validatesReceivingCenterWhenTransferingGroup.
@Test(expected = CustomerException.class)
public void validatesReceivingCenterWhenTransferingGroup() throws Exception {
// setup
CenterBO toCenter = new CenterBuilder().build();
// stubbing
doThrow(new CustomerException(CustomerConstants.INVALID_PARENT)).when(group).validateReceivingCenter(toCenter);
// exercise test
customerService.transferGroupTo(group, toCenter);
// verification
verify(group).validateReceivingCenter(toCenter);
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupTransferToCenterServiceTest method validatesNoActiveAccountExistWhenTransferingGroup.
@Test(expected = CustomerException.class)
public void validatesNoActiveAccountExistWhenTransferingGroup() throws Exception {
// setup
CenterBO toCenter = new CenterBuilder().build();
// stubbing
doThrow(new CustomerException(CustomerConstants.ERRORS_HAS_ACTIVE_ACCOUNT)).when(group).validateNoActiveAccountsExist();
// exercise test
customerService.transferGroupTo(group, toCenter);
// verification
verify(group).validateNoActiveAccountsExist();
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class ClientCreationTest method throwsCheckedExceptionWhenValidationForDuplicateNameOrGovernmentId.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenValidationForDuplicateNameOrGovernmentId() throws Exception {
String displayName = "Test Name";
Date dob = new Date();
String govtId = "44354323543";
// setup
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
List<SavingsOfferingBO> noSavings = new ArrayList<SavingsOfferingBO>();
// stubbing
Mockito.when(mockedClient.getDisplayName()).thenReturn(displayName);
Mockito.when(mockedClient.getDateOfBirth()).thenReturn(dob);
Mockito.when(mockedClient.getGovernmentId()).thenReturn(govtId);
doThrow(new CustomerException(CustomerConstants.DUPLICATE_GOVT_ID_EXCEPTION)).when(customerDao).validateClientForDuplicateNameOrGovtId(displayName, dob, govtId);
// exercise test
customerService.createClient(mockedClient, meeting, accountFees, noSavings);
// verify
verify(customerDao).validateClientForDuplicateNameOrGovtId(mockedClient.getDisplayName(), mockedClient.getDateOfBirth(), mockedClient.getGovernmentId());
}
Aggregations