use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupValidationTest method formedByPersonnelMustBeAssigned.
@Test
public void formedByPersonnelMustBeAssigned() {
group = new GroupBuilder().withName("group-On-center").withParentCustomer(center).formedBy(null).build();
try {
group.validate();
fail("should throw customer exception as personnel that fomed group must exist when creating group.");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.INVALID_FORMED_BY));
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CustomerStatusUpdateTest method throwsCheckedExceptionWhenVersionOfCustomerForUpdateIsDifferentToPersistedCustomerVersion.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenVersionOfCustomerForUpdateIsDifferentToPersistedCustomerVersion() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
CustomerStatusUpdate customerStatusUpdate = new CustomerStatusUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(customerStatusUpdate.getCustomerId())).thenReturn(mockedCenter);
doThrow(new CustomerException(Constants.ERROR_VERSION_MISMATCH)).when(mockedCenter).validateVersion(anyInt());
// exercise test
customerService.updateCustomerStatus(userContext, customerStatusUpdate);
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupCreationTest method throwsCheckedExceptionWhenGroupValidationFails.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenGroupValidationFails() throws Exception {
// setup
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stubbing
doThrow(new CustomerException(CustomerConstants.ERRORS_SPECIFY_NAME)).when(mockedGroup).validate();
// exercise test
customerService.createGroup(mockedGroup, meeting, accountFees);
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class ClientServiceFacadeWebTier method transferClientToGroup.
@Override
public String transferClientToGroup(Integer groupId, String clientGlobalCustNum, Integer previousClientVersionNo) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
ClientBO client;
try {
client = this.customerService.transferClientTo(userContext, groupId, clientGlobalCustNum, previousClientVersionNo);
return client.getGlobalCustNum();
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CustomerServiceFacadeWebTier method search.
@Override
public CustomerSearch search(String searchString) throws ApplicationException {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
if (searchString == null) {
throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
}
String normalisedSearchString = org.mifos.framework.util.helpers.SearchUtils.normalizeSearchString(searchString);
if (normalisedSearchString.equals("")) {
throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
}
String officeId = userContext.getBranchId().toString();
String officeName = this.officeDao.findOfficeDtoById(userContext.getBranchId()).getName();
PersonnelBO loggedInUser = personnelDao.findPersonnelById(userContext.getId());
QueryResult searchResult = customerDao.search(normalisedSearchString, loggedInUser);
return new CustomerSearch(searchResult, searchString, officeId, officeName);
}
Aggregations