1

I am testing a REST API that creates a resource and returns a status of 201 Created and the location of the new resource in both the body and the Location header. I would like to assert that these are equal using the MockMvc DSL.

I know how to write a condition for a header:

.andExpect(header().string(LOCATION, value))

and how to write one for JsonPath:

.andExpect(jsonPath("$.data.links.self.href"), equalTo(value))

but I don't see a way in the DSL to perform a capture and compare them to each other. I know that I can supply an arbitrary lambda, but is there a built-in expression for this use case?

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152

0 Answers0