Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Conversation

BlasiusSecundus
Copy link

GraphQLResponse and GraphQLTestTemplate now use the ObjectMapper bean
from the tested application.

The get methods now use the object mapper to convert the variable to
the specified type. Formerly they used vanilla JsonPath library methods
that may produce unexpected results. E. g. given the following response
body:

{"data": {"test": 2}}

a call to get("$.data.test") would result in an
ClassCastException, which is usually not the desired behaviour.

It was also very restrictive on data types: only "native" JSON types
were supported (e. g. int, boolean, String).

Furthermore it seems to have issues with more complex classes, like
POJOs and may return null.

Several test cases were added to ensure correct behaviour. Some of
these tests would fail with the previous version.

GraphQLResponse and GraphQLTestTemplate now use the ObjectMapper bean
from the tested application.

The `get` methods now use the object mapper to convert the variable to
the specified type. Formerly they used vanilla JsonPath library methods
that may produce unexpected results. E. g. given the following response
body:

`{"data": {"test": 2}}`

a call to `get("$.data.test")` would result in an
`ClassCastException`, which is usually not the desired behaviour.

It was also very restrictive on data types: only "native" JSON types
were supported (e. g. int, boolean, String).

Furthermore it seems to have issues with more complex classes, like
POJOs and may return `null`.

Several test cases were added to ensure correct behaviour. Some of
these tests would fail with the previous version.
@oliemansm oliemansm merged commit 1f22207 into graphql-java-kickstart:master Feb 25, 2020
@oliemansm
Copy link
Member

Thanks for the contribution!

@BlasiusSecundus BlasiusSecundus deleted the feature/test-response-improvements-vol-2 branch September 26, 2020 04:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants