You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parameters in a default method in a Micronaut Data repository are not validated. This doesn't happen with other methods defined in the interface that Micronaut implements.
@Unrollvoid'test "findSensorById(#id)" triggers ConstraintViolationException'() {
when:
sensorRepository.findSensorById(id)
then:
def e = thrown(ConstraintViolationException)
e.constraintViolations.collect { it.propertyPath.toString() }.any { it.contains(field) }
e.constraintViolations.collect { it.message }.any { it.contains(errorMessage) }
where:
id | field | errorMessage
null | 'findSensorById.id' | 'must not be null'
}
Expected Behaviour
The test should pass.
Actual Behaviour
The test fails with:
Expected exception of type 'javax.validation.ConstraintViolationException', but no exception was thrown
Expected exception of type 'javax.validation.ConstraintViolationException', but no exception was thrown
at org.spockframework.lang.SpecInternals.checkExceptionThrown(SpecInternals.java:80)
at org.spockframework.lang.SpecInternals.thrownImpl(SpecInternals.java:67)
at mn.data.defmethod.SensorRepositoryConstraintsSpec.test "findSensorById(#id)" triggers ConstraintViolationException(SensorRepositoryConstraintsSpec.groovy:22)
Please note that if from the default method I call another method like findById then the test fails with the following error referencing findById instead of the original method.
e.constraintViolations.collect { it.propertyPath.toString() }.any { it.contains(field) }
| | | |
| | [findById.id] false
| [io.micronaut.validation.validator.DefaultValidator$DefaultConstraintViolation@202479c0]
javax.validation.ConstraintViolationException: findById.id: must not be null
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Parameters in a
default
method in a Micronaut Data repository are not validated. This doesn't happen with other methods defined in the interface that Micronaut implements.Steps to Reproduce
Entity and DTO:
Micronaut Data interface:
Spock Test:
Expected Behaviour
The test should pass.
Actual Behaviour
The test fails with:
Please note that if from the default method I call another method like
findById
then the test fails with the following error referencingfindById
instead of the original method.Environment Information
Example Application
https://github.com/ilopmar/mn-data-default-method-validation
The text was updated successfully, but these errors were encountered: