Reputation: 145
I am trying to write a test for patch end point using rest assured mock mvc. But i am not able to create an object of jsonmerge patch to place in the body of the mock.below is the end point for which i need to wrote the test
@PatchMapping(path = "/{orderId}", consumes = "application/merge-patch+json")
public OrderDTO updateOrder(@PathVariable Long orderId, @RequestBody
JsonMergePatchImpl patchRequest){
return facade.patchOrder(orderId,patchRequest);
}
and following is what i'm trying but not able to figure out
Mockito.when(facade.patchOrder(any(),any())).thenReturn(orderDTO);
OrderDTO actual=given()
.contentType(MediaType.APPLICATION_JSON_VALUE)
.body()
.accept("application/merge-patch+json")
.when()
.patch(BASE_URL+"/"+1l)
.then()
.assertThat()
.statusCode(200).extract().as(OrderDTO.class);
My problem is i am not able to create an object for jsonmerge patch , and what to put in as content type
Upvotes: 1
Views: 800
Reputation: 204
You can specify contentType as String:
.contentType("application/merge-patch+json")
Upvotes: 1