use of gov.ca.cwds.rest.exception.BusinessValidationException in project api-core by ca-cwds.
the class R03855Test method testMaxAgeInvalid.
@Test
public void testMaxAgeInvalid() throws Exception {
PlacementHome placementHome = new PlacementHome();
placementHome.setAgeToNo((short) 27);
try {
runBusinessValidation(placementHome);
fail();
} catch (BusinessValidationException e) {
assert e.getValidationDetailsList().stream().anyMatch(issueDetails -> issueDetails.getCode().equals("R-03855"));
}
}
use of gov.ca.cwds.rest.exception.BusinessValidationException in project cals-api by ca-cwds.
the class RFA1aFormService method submitApplication.
/**
* There is using XA Transaction
*/
private void submitApplication(Long formId, RFAApplicationStatus newStatus) throws NotSupportedException, SystemException, DroolsException {
RFA1aFormDTO expandedFormDTO = getExpandedFormDTO(formId);
performSubmissionValidation(expandedFormDTO);
// Start transaction here
UserTransaction userTransaction = new UserTransactionImp();
userTransaction.setTransactionTimeout(3600);
userTransaction.begin();
PlacementHome storedPlacementHome = null;
try {
storedPlacementHome = storePlaceMentHome(expandedFormDTO);
updateFormAfterPlacementHomeCreation(formId, storedPlacementHome.getIdentifier(), newStatus);
userTransaction.commit();
} catch (BusinessValidationException e) {
userTransaction.rollback();
LOG.error("Can not create Placement Home because of BusinessValidationException", e);
throw e;
} catch (UnauthorizedException e) {
userTransaction.rollback();
LOG.error("Can not create Placement Home because of UnauthorizedException", e);
throw e;
} catch (Exception e) {
try {
userTransaction.rollback();
} catch (Exception re) {
LOG.warn(re.getMessage(), re);
}
StringBuilder sb = new StringBuilder();
sb.append(e.getMessage());
sb.append('\n');
Throwable cause = e.getCause();
while (cause != null) {
sb.append(" Cause: ");
sb.append(cause.getMessage());
sb.append('\n');
cause = cause.getCause();
}
LOG.error("Can not create Placement Home: \n", e);
throw new SystemException(sb.toString());
}
}
use of gov.ca.cwds.rest.exception.BusinessValidationException in project cals-api by ca-cwds.
the class RFA1aFormService method performSubmissionValidation.
private void performSubmissionValidation(RFA1aFormDTO formDTO) throws DroolsException {
Validator validator = environment.getValidator();
Optional.ofNullable(validator.validate(formDTO)).ifPresent(violations -> {
if (!violations.isEmpty()) {
throw new ConstraintViolationException(violations);
}
});
Set<IssueDetails> detailsList = droolsService.performBusinessRules(createConfiguration(), formDTO);
if (!detailsList.isEmpty()) {
throw new BusinessValidationException(detailsList);
}
}
Aggregations