use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupCustAction method search.
@Override
@TransactionDemarcate(joinToken = true)
public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
GroupCustActionForm actionForm = (GroupCustActionForm) form;
UserContext userContext = getUserContext(request);
ActionForward actionForward = super.search(mapping, form, request, response);
String searchString = actionForm.getSearchString();
if (searchString == null) {
if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
request.setAttribute(Constants.INPUT, CenterConstants.INPUT_SEARCH_TRANSFERGROUP);
} else {
request.setAttribute(Constants.INPUT, null);
}
throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
}
addSeachValues(searchString, userContext.getBranchId().toString(), new OfficeBusinessService().getOffice(userContext.getBranchId()).getOfficeName(), request);
final String normalizedSearchString = SearchUtils.normalizeSearchString(searchString);
if (normalizedSearchString.equals("")) {
if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
request.setAttribute(Constants.INPUT, CenterConstants.INPUT_SEARCH_TRANSFERGROUP);
} else {
request.setAttribute(Constants.INPUT, null);
}
throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
}
boolean searchForAddingClientsToGroup = (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_ADD_CLIENTS_TO_GROUPS));
GroupSearchResultsDto searchResult = this.customerServiceFacade.searchGroups(searchForAddingClientsToGroup, normalizedSearchString, userContext.getId());
SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, searchResult.getSearchResults(), request);
if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
return mapping.findForward(ActionForwards.transferSearch_success.toString());
} else if (searchForAddingClientsToGroup) {
SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, searchResult.getSearchForAddingClientToGroupResults(), request);
return mapping.findForward(ActionForwards.addGroupSearch_success.toString());
} else {
return actionForward;
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CenterCreationTest method throwsCheckedExceptionWhenCenterMeetingAndFeesFailValidation.
@Test(expected = BusinessRuleException.class)
public void throwsCheckedExceptionWhenCenterMeetingAndFeesFailValidation() throws Exception {
// setup
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stubbing
doThrow(new CustomerException(CustomerConstants.ERRORS_SPECIFY_MEETING)).when(mockedCenter).validateMeetingAndFees(accountFees);
// exercise test
customerService.createCenter(mockedCenter, meeting, accountFees);
// verification
verify(mockedCenter).validateMeetingAndFees(accountFees);
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CenterCreationTest method throwsCheckedExceptionWhenCenterValidationFails.
@Test(expected = BusinessRuleException.class)
public void throwsCheckedExceptionWhenCenterValidationFails() throws Exception {
// setup
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
// stubbing
doThrow(new CustomerException(CustomerConstants.ERRORS_SPECIFY_NAME)).when(mockedCenter).validate();
// exercise test
customerService.createCenter(mockedCenter, meeting, accountFees);
// verification
verify(mockedCenter).validate();
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CenterUpdateTest method throwsCheckedExceptionWhenVersionOfCenterForUpdateIsDifferentToPersistedCenterVersion.
@Test(expected = CustomerException.class)
public void throwsCheckedExceptionWhenVersionOfCenterForUpdateIsDifferentToPersistedCenterVersion() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
CenterUpdate centerUpdate = new CenterUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(centerUpdate.getCustomerId())).thenReturn(mockedCenter);
doThrow(new CustomerException(Constants.ERROR_VERSION_MISMATCH)).when(mockedCenter).validateVersion(centerUpdate.getVersionNum());
// exercise test
customerService.updateCenter(userContext, centerUpdate);
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class ClientIntegrationTest method testFailureCreateActiveClientWithoutMeeting.
@Test
public void testFailureCreateActiveClientWithoutMeeting() throws Exception {
try {
ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "", "last", "");
clientNameDetailDto.setNames(ClientRules.getNameSequence());
ClientNameDetailDto spouseNameDetailView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
spouseNameDetailView.setNames(ClientRules.getNameSequence());
ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
client = new ClientBO(TestUtils.makeUser(), clientNameDetailDto.getDisplayName(), CustomerStatus.fromInt(new Short("3")), null, null, null, null, null, null, personnel, officeBo, null, personnel, null, null, null, null, YesNoFlag.NO.getValue(), clientNameDetailDto, spouseNameDetailView, clientPersonalDetailDto, null);
Assert.fail();
} catch (CustomerException ce) {
Assert.assertNull(client);
Assert.assertEquals(CustomerConstants.INVALID_MEETING, ce.getKey());
}
}
Aggregations