I have the following JSON String:
[
{
"id": 23425,
"mailboxGroupId": 6659,
"statusCode": "ACTIVE"
},
{
"id": 23425,
"groupId": 6659,
"statusCode": "INACTIVE"
}
]
I want to deserialize it into a list of two objects of Kotlin data class type:
val myList: List<Foo> = Gson().fromJson(response, ArrayList<Foo>().javaClass)
Next, I need to compare with AssertJ these two objects and assert that all fields except for statusCode
are equal:
assertThat(myList.first()).isEqualToIgnoringGivenFields(myList.last(), "statusCode")
But when I run the test, I get an assertion error:
Expecting values:
<.....>
in fields:
<["root", "entrySet", "values"]>
Looks like Gson adds "root", "entrySet", "values"
during the deserialization, but I can't understand how can I exclude them?
Or I don't need to exclude them and just need to change my assertion?