From the course: Java: Automated API Testing with REST Assured
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Deserializing response body - Java Tutorial
From the course: Java: Automated API Testing with REST Assured
Deserializing response body
- [Instructor] Just as we use Java classes to model the body of an API request, we can do the same for the body of a response. This is known as deserializing. Let's make a GET call to obtain a single product. So we'll make a new Test, and let's call this one getDeserializedProduct. And we'll specify our endpoint. And let's get right into the call, so we can say given. And let's use a query parameter to specify the id. So we'll say given the id is, and let's just use 2, we've used that product before. Okay, now let's make the call. So given this query parameter, when, we say get on this endpoint. Now, usually, right here we would specify then, and that would give us a response in a form that would allow us to verify the body as JSON or XML. However, in this chapter, we want to get the response returned as a Java object. So instead of calling then, we're going to make a call to a method called as. And inside of as,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Anatomy of a response2m 1s
-
(Locked)
Verifying status code of a response2m 20s
-
(Locked)
Accessing response body1m 35s
-
(Locked)
Verifying fields of response5m 50s
-
(Locked)
Verifying complex response bodies7m 37s
-
(Locked)
Verifying response header2m 52s
-
(Locked)
Deserializing response body7m 54s
-
(Locked)
Challenge: Verify API response33s
-
(Locked)
Solution: Verify API response1m 55s
-
(Locked)