amoss
amoss copied to clipboard
Implement isACalloutMock().expects().body().setTo( Object ), JSON serializing before check
Implement the following construct:
isACalloutMock()
...
.expects()
.body().setTo( Object )
And, potentially
isACalloutMock()
...
.expects()
.body().contains( Object )
Both would do a JSON Serialize on the Object, and then use a string comparison to check if the resulting body matches.
Also consider
isACalloutMock()
...
.expects()
.body().hasProperty( String ).setTo( String )
and
isACalloutMock()
...
.expects()
.body().hasProperty( String ).setTo( Object )
As well as similar with contains.
Would do construct a JSON property match and then compare with the string.
E.g.
.body().hasProperty( 'thing' ).setTo( 'value' )** would look for"thing": "value".body().hasProperty( 'thing' ).setTo( object )** would look for something along the lines of"thing": {"objectthing":"objectvalue"}