New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: run http server tck against Micronaut Serialization Jackson #617
Conversation
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
import org.junit.platform.suite.api.SuiteDisplayName; | ||
|
||
@Suite | ||
@ExcludeClassNamePatterns("io.micronaut.http.server.tck.tests.constraintshandler.ControllerConstraintHandlerTest") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a weird test, it relies on a NonNull parameter being set to null and then failing later in constraint validation, which works with jackson-databind (doesnt care about NonNull) but not serde. serde's behavior is fine here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't a weird test. It describes a scenario many users will anticipate to work. Myself included. You create a controller with a POJO with the nullability annotations. The POJO describes the valid payload of your endpoint. The person invoking the API does not supply a valid JSON. You expect the object to be populated with the available information and the validation submission to be triggered so that you can handle the ConstraintViolationException
. What are you working on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NonNull is not a validation annotation though, it is more fundamental and is checked at a different stage than validation annotations. I see your point, but we can't throw ConstraintViolationException from serde, it's not even on the compile path. And we made the explicit choice to check for null in serde.
Consider it from a different angle. If the JSON included {\"username\":{},\"password\":\"secret\"}
(entirely wrong type for username), then both jackson-databind and serde will fail with not-a-ConstraintViolationException. Serde just extends this same behavior to null (or in this case missing fields). The line between a type error and a constraint error has to be drawn somewhere, and serde (intentionally) checks nulls.
@yawkat can you a approve or request changes? |
see: #616 and micronaut-projects/micronaut-core#10023