use of edu.cornell.kfs.concur.businessobjects.ValidationResult in project cu-kfs by CU-CommunityApps.
the class ConcurAccountValidationServiceImpl method checkMissingOrInactive.
private ValidationResult checkMissingOrInactive(Inactivatable inactivatableObject, String missingMessage, String inactiveMessage) {
ValidationResult validationResult = new ValidationResult();
if (inactivatableObject == null || inactivatableObject.toString().isEmpty()) {
validationResult.setValid(false);
validationResult.addMessage(missingMessage);
} else if (!inactivatableObject.isActive()) {
validationResult.setValid(false);
validationResult.addMessage(inactiveMessage);
}
return validationResult;
}
use of edu.cornell.kfs.concur.businessobjects.ValidationResult in project cu-kfs by CU-CommunityApps.
the class ConcurAccountValidationServiceImpl method checkRequiredAccountInfo.
public ValidationResult checkRequiredAccountInfo(String chartOfAccountsCode, String accountNumber, String objectCode, boolean objectCodeRequired) {
ValidationResult validationResult = new ValidationResult();
if (chartOfAccountsCode == null || chartOfAccountsCode.isEmpty()) {
validationResult.setValid(false);
validationResult.addMessage(MessageFormat.format(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_REQUIRED), ConcurConstants.AccountingStringFieldNames.CHART));
}
if (accountNumber == null || accountNumber.isEmpty()) {
validationResult.setValid(false);
validationResult.addMessage(MessageFormat.format(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_REQUIRED), ConcurConstants.AccountingStringFieldNames.ACCOUNT_NUMBER));
}
if (objectCodeRequired && (objectCode == null || objectCode.isEmpty())) {
validationResult.setValid(false);
validationResult.addMessage(MessageFormat.format(configurationService.getPropertyValueAsString(KFSKeyConstants.ERROR_REQUIRED), ConcurConstants.AccountingStringFieldNames.OBJECT_CODE));
}
return validationResult;
}
use of edu.cornell.kfs.concur.businessobjects.ValidationResult in project cu-kfs by CU-CommunityApps.
the class ConcurAccountValidationServiceTest method isAccountNull.
@Test
public void isAccountNull() {
ValidationResult validationResult = concurAccountValidationService.checkAccount(ConcurAccountValidationTestConstants.VALID_CHART, null);
String accountErrorMessageString = ConcurUtils.formatStringForErrorMessage(ConcurConstants.AccountingStringFieldNames.ACCOUNT_NUMBER, ConcurAccountValidationTestConstants.VALID_CHART, null);
Assert.assertFalse("Validation was expected to fail but returned true", validationResult.isValid());
Assert.assertEquals("Error message was expected for null account number", MessageFormat.format(concurAccountValidationService.getConfigurationService().getPropertyValueAsString(KFSKeyConstants.ERROR_EXISTENCE), accountErrorMessageString) + KFSConstants.NEWLINE, validationResult.getErrorMessagesAsOneFormattedString());
}
use of edu.cornell.kfs.concur.businessobjects.ValidationResult in project cu-kfs by CU-CommunityApps.
the class ConcurAccountValidationServiceTest method isSubAccountNull.
@Test
public void isSubAccountNull() {
ValidationResult validationResult = concurAccountValidationService.checkSubAccount(ConcurAccountValidationTestConstants.VALID_CHART, ConcurAccountValidationTestConstants.VALID_ACCT_NBR, null);
Assert.assertTrue("Validation was expected to pass", validationResult.isValid());
}
use of edu.cornell.kfs.concur.businessobjects.ValidationResult in project cu-kfs by CU-CommunityApps.
the class ConcurAccountValidationServiceTest method isAccountBad.
@Test
public void isAccountBad() {
ValidationResult validationResult = concurAccountValidationService.checkAccount(ConcurAccountValidationTestConstants.VALID_CHART, ConcurAccountValidationTestConstants.BAD_ACCT_NBR);
String accountErrorMessageString = ConcurUtils.formatStringForErrorMessage(ConcurConstants.AccountingStringFieldNames.ACCOUNT_NUMBER, ConcurAccountValidationTestConstants.VALID_CHART, ConcurAccountValidationTestConstants.BAD_ACCT_NBR);
Assert.assertFalse("Validation was expected to fail but returned true", validationResult.isValid());
Assert.assertEquals("Error message was expected for bad account number", MessageFormat.format(concurAccountValidationService.getConfigurationService().getPropertyValueAsString(KFSKeyConstants.ERROR_EXISTENCE), accountErrorMessageString) + KFSConstants.NEWLINE, validationResult.getErrorMessagesAsOneFormattedString());
}
Aggregations