Skip to content

Rest Docs 2.0.0 - JsonAttribute Not Found becaus of changed JsonFieldProcessor#foundMatch() behaviour #492

Closed
@AnnaMaus86

Description

@AnnaMaus86

Hi there,

we recently upgraded to Rest Docs 2.0.0 from 1.1.2.

The behaviour of JsonFieldProcessor#foundMatch() has changed, so that some json-attributes are marked as missing (although) present (according to 1.1.2 #foundMatch()).

The reason is that in 1.1.2 it was sufficient when the searched json-attribute (key) is present in the processingContext#getPayload() map. Just 'true' was returned then.

But in 2.0.0 the #foundMatch() method combine certain MatchTypes (in my case MatchType.ABSENT with MatchType.NON_NULL) when the searched json-attribute (key) is present in the processingContext#getPayload() map.

So the foundMatch() method finally returns the value MatchType.MIXED.
BUT JsonFieldProcessor#fieldFound() only returns true the resulting MatchType is MatchType.NON_NULL or MatchType.NULL.

It looks like a bug to me.

My Testdata:
Travesed JSON (Debug-Output):
[ {id=18},
{id=19, myArray=[ {mySearchedAttribute=someValue, formular=B} ]},
{id=20} ]

I searched for:
fieldWithPath("[].myArray[].mySearchedAttribute").

Maybe it has something to do with the fact that 'myArray' is only present in the second Array-Element (I didn't mark the fieldWithPath as optional as in my UnitTest it shall occure in the response).
But it was okay in RestDocs 1.1.2.

Any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions