Java Reference
In-Depth Information
response.contentType == 'application/json'
response.headers.Location ==
"http://localhost:1234/people/${response.data.id}"
when: 'delete the new JSON object'
client.delete(path: response.headers.Location)
then: 'number of stored objects goes down by one'
getAll().size() == old(getAll().size()) - 1
}
Given a JSON object representing a person, a POST request adds it to the system. The re-
turned object holds the status code (201), the content type (application/json), the returned
person object (in the data property), and the URI for the new resource in the Location
header. Deleting the object is done by sending a DELETE request to the new URI and veri-
fying that the total number of stored instances goes down by one.
Updates are done through a PUT request. To ensure that PUT requests are idempotent, the
complete object needs to be specified in the body of the request. This is why PUT requests
aren't normally used for inserts; the client doesn't know the ID of the newly inserted ob-
ject, so POST requests are used for that instead.
The complete test is shown in the next listing.
Search WWH ::




Custom Search