hi Hardy,
I can easily test the custom validators. Code example.
Code:
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
ActProvisionBeforeOutcomeValidator actProvisionBeforeOutcomeValidator =
factory.getConstraintValidatorFactory().getInstance(ActProvisionBeforeOutcomeValidator.class);
actProvisionBeforeOutcomeValidator.setReviewEventTypeDao(reviewEventTypeDao); // dao classes mocked
actProvisionBeforeOutcomeValidator.setReviewOutcomeDao(reviewOutcomeDao);
boolean isValid = actProvisionBeforeOutcomeValidator.isValid(event, null);
Now I need want to test the @ScriptAssert on my entity class in isolation from the custom validators.
Code:
@ScriptAssert.List({
@ScriptAssert(
lang = "javascript",
script = "_this.eventCompleted == 'Y' ? _this.dateEventCompleted != null : true",
message = "The date must be entered for a completed event.")
... lots more @ScriptAssert follow ...
What is the best way to get a handle on this ScriptAssert so I can unit test it? The below does not work and I would not expect to work as we have a list of script asserts.
Code:
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
ScriptAssertValidator scriptAssertValidator =
factory.getConstraintValidatorFactory().getInstance(ScriptAssertValidator.class);
boolean isValid = scriptAssertValidator.isValid(event, null);
thanks,
Ralph