amoss icon indicating copy to clipboard operation
amoss copied to clipboard

Implement isACalloutMock().expects().body().setTo( Object ), JSON serializing before check

Open bobalicious opened this issue 4 years ago • 0 comments

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"}

bobalicious avatar Aug 03 '21 07:08 bobalicious