Deserialization – How to convert JSON to Map using Jackson API

HOME

This tutorial shows how to convert JSON to JAVA map using Jackson’s data binding. In the previous tutorials, I have explained converting Java Objects/Arrays to JSON String using Jackson API. You can refer below tutorials.

Serialization – How to create JSON Payload from Java Object – Jackson API

Deserialization – How to convert JSON to Java Object using Jackson API

How to create JSON Array Payload using POJO – Jackson API

How to create Nested JSON Object using POJO – Jackson API

To start with, we need to add Jackson Maven Dependency to the POM. Always add the latest version of Jackson dependency to your project.

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.13.0</version>
</dependency

Deserialization converts a stream of bytes into a Java object that we can use in code.

We use Jackson’s ObjectMapper, as we did for serialization, using readValue() to process the input. Also, note our use of Jackson’s TypeReference, which we’ll use in all of our deserialization examples to describe the type of our destination Map.

   @Test
	public void DeserializationMapTest() throws JsonProcessingException {

		String employeeString = 
                     "{\r\n" 
                    + "  \"firstName\" : \"Deserialization\",\r\n"
				    + "  \"lastName\" : \"Test\",\r\n" 
                    + "  \"age\" : 25,\r\n" 
                    + "  \"salary\" : 50000.0,\r\n"
				    + "  \"designation\" : \"Manager\",\r\n" 
                    + "  \"contactNumber\" : \"+918882211111\",\r\n"
				    + "  \"emailId\" : \"abc@test.com\",\r\n" 
                    + "  \"gender\" : \"female\",\r\n"
				    + "  \"maritalStatus\" : \"single\"\r\n" 
                    + " }";

		Map<String, String> resultMap = new HashMap<String, String>();
		ObjectMapper mapper = new ObjectMapper();

		// Converting a JSON to Java Map
		try {
			resultMap = mapper.readValue(employeeString, new TypeReference<HashMap<String, String>>() {
			});
		} catch (JsonMappingException e) {
			e.printStackTrace();
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}

		System.out.println("Output Map :" + resultMap);
	}

Output

We can get the JSON from a file and convert it to a Hash Map too. Below is an example of the same.

   @Test
	public void PayloadFromFile() {

		String userDir = System.getProperty("user.dir");
		ObjectMapper mapper = new ObjectMapper();

		// Converting Employee JSON string to Employee class object
		Map<String, Object> empMap;
		try {
			empMap = mapper.readValue(new File(userDir + "\\src\\test\\resources\\JSONFromMap.json"),
					new TypeReference<Map<String, Object>>() {
					});

			System.out.println("Gender : " + empMap.get("gender"));
			System.out.println("DOB : " + empMap.get("DOB"));
			System.out.println("Name : " + empMap.get("name"));
			System.out.println("ContactNumber : " + empMap.get("contactNumber"));
			System.out.println("SkillSet : " + empMap.get("skillset"));
		} catch (StreamReadException e) {
			e.printStackTrace();
		} catch (DatabindException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

Output

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Serialization – How to convert Map to JSON string using Jackson API

HOME

This tutorial shows how to convert Java map to JSON string using Jackson’s data binding. In the previous tutorials, I have explained converting Java Objects/Arrays to JSON String using Jackson API. You can refer to the below tutorials.

Serialization – How to create JSON Payload from Java Object – Jackson API

How to create JSON Array Payload using POJO – Jackson API

How to create Nested JSON Object using POJO – Jackson API

To start off, add the latest Jackson dataformat Maven dependency to the project.

<dependency>
    <groupId>com.fasterxml.jackson.dataformat</groupId>
    <artifactId>jackson-dataformat-xml</artifactId>
    <version>2.13.0</version>
</dependency>

Sample JSON

{
  "skillset" : [ 
                 "Java",
                 "Teradata",
                 "Python", 
                 "Power BI" 
               ],
  "gender" : "female",
  "DOB" : "12-02-1985",
  "name" : "Vibha Singh",
  "contactNumber" : "+919999988822",
  "employeeId" : "10342256",
  "location" : "Dublin",
  "emailId" : "abc@test.com",
  "salary" : "75000.0"
}

First, we will populate a Map, then convert them into JSON and later write that JSON to a file.

	@Test
	public void SerializationMapTest() {

		ObjectMapper mapper = new ObjectMapper();
		Map<String, Object> inputMap = new HashMap<String, Object>();

		inputMap.put("employeeId", "10342256");
		inputMap.put("name", "Vibha Singh");
		inputMap.put("DOB", "12-02-1985");
		inputMap.put("salary", "75000.0");
		inputMap.put("location", "Dublin");
		inputMap.put("contactNumber", "+919999988822");
		inputMap.put("emailId", "abc@test.com");
		inputMap.put("gender", "female");

		List<String> skillset = new ArrayList<String>();

		skillset.add("Java");
		skillset.add("Teradata");
		skillset.add("Python");
		skillset.add("Power BI");

		inputMap.put("skillset", skillset);

		// Converting map to a JSON payload as string
		try {
			String employeePrettyJson = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(inputMap);
			System.out.println(employeePrettyJson);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}

		String userDir = System.getProperty("user.dir");

        //Writing JSON on a file
		try {
			mapper.writerWithDefaultPrettyPrinter()
					.writeValue(new File(userDir + "\\src\\test\\resources\\JSONFromMap.json"), inputMap);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}

Output

As mentioned above, the new JSON is saved in a file and placed under src/test/resources.

Below is the file with JSON.

Congratulations, we are done. We have successfully created a JSON using HashMap.

Rest Assured – How to test JSON Request using Jackson API

HOME

This tutorial focuses on the testing of a REST API (with JSON payload). We will use Jackson API to serialize the request.

It is suggested to go through these tutorials to understand about creating a JSON Object Payload using POJO (Plain Old Java Object).

How to create JSON Object Payload using POJO – Jackson API

How to create JSON Array Payload using POJO – Jackson API

How to create Nested JSON Object using POJO – Jackson API

To start with, we need to add Jackson Maven Dependency to the POM. Always add the latest version of Jackson dependency to your project.

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.13.0</version>
</dependency>

This dependency will also transitively add the following libraries to the classpath:

  1. jackson-annotations
  2. jackson-core

In the below example, let us assume that we need to create a new Employee (POST Request) .To start with, we need to create POJO class of the JSON payload (EmployeeDetails). This POJO class should contain the data members corresponding to the JSON nodes and their corresponding getter and setter methods.

public class EmployeeDetails {

	// private variables or data members of pojo class
	private String name;
	private double salary;
	private int age;

    // Getter and Setters
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public double getSalary() {
		return salary;
	}

	public void setSalary(double salary) {
		this.salary = salary;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

}

Now that we have our POJO class we can start writing some REST Assured Serialization tests!

Let’s start with REST Assured Serialization with JSON. I want to send a POST request to my EmployeeDetails API that will add a new Employee to the database. I will send a POJO of the employee in the request body. This is what the code looks like in the test class:

	@Test
	public void createEmployee() {

		// Create an object of POJO class
		EmployeeDetails emp = new EmployeeDetails();
		emp.setName("Vibha");
		emp.setSalary(75000);
		emp.setAge(30);

		// Converting a Java class object to a JSON payload as string
		ObjectMapper mapper = new ObjectMapper();
		String employeePrettyJson = null;
		try {
			employeePrettyJson = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(emp);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}
		System.out.println("Request");
		System.out.println(employeePrettyJson);
		System.out.println("=========================================");
		System.out.println("Response");

		// GIVEN
		given().baseUri("http://dummy.restapiexample.com/api").contentType(ContentType.JSON).body(emp)

				// WHEN
				.when().post("/v1/create")

				// THEN
				.then().assertThat().statusCode(200).body("data.name", equalTo("Vibha"))
				.body("message", equalTo("Successfully! Record has been added.")).log().body();

	}
}

If you want to see the structure of Request, then add the below in the test code.

ObjectMapper mapper = new ObjectMapper();
String employeePrettyJson = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(emp);
System.out.println(employeePrettyJson);

REST Assured Serialization with Jackson handled all the serialization work for us. Great! See this has become so simple with the help of Jackson API.

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Serialization – How to create JSON Payload from Java Object – Jackson API

HOME

In this tutorial, I will explain the creation of JSON Object Payload with the help of POJO (Plain Old Java Object).

What is POJO?

POJO stands for Plain Old Java Object. It is a very simple object and it has no bound or we can say that it has no restrictions other than the Java language specification. Also, it does not require any classpath.

A big advantage of POJO is it increases the readability and reusability of our project code and developers find it easy when understanding the code. Also, POJO is easy to write and anyone can understand them easily.

Now let’s deep dive into some technical terms about the POJO. Below are a few points about the POJO are:

  1. A POJO should not have to extend prespecified classes.
  2. Secondly, a POJO should not have implemented any prespecified interface.
  3. Lastly, POJO should not contain prespecified annotations

A POJO class can follow some rules for better usability. These rules are:-

  1. Each variable should be declared as private just to restrict direct access.
  2. Each variable which needs to be accessed outside class may have a getter or a setter or both methods. If value of a field is stored after some calculations then we must not have any setter method for that.
  3. It Should have a default public constructor.
  4. Can override toString(), hashcode and equals() methods.

POJO classes are extensively used for creating JSON and XML payloads for API.

In the below example, let me create a simple JSON with some nodes which is actually a 1:1 mapping i.e. each key has a single value, and the type of values is mixed.

{
  "firstName" : "Vibha",
  "lastName" : "Singh",
  "age" : 30,
  "salary" : 75000.0,
  "designation" : "Manager",
  "contactNumber" : "+91999996712",
  "emailId" : "abc123@test.com"
}

Let us create variables in the POJO class now for the above JSON. Now, a class name Employee will be created with the private data members as mentioned in the above JSON. Since we have created all variables as private, then there should be a way to manipulate or retrieve these data. So we create the corresponding getter and setter methods for these data members.

It is very tedious to create getter and setter methods for all the data members for big JSON strings.  Every IDE gives you a shortcut to generate getter and setter methods.  Here, I am using Eclipse and creating these getter and setter methods.

Select all the data members and Right-click on the page. Then select Source and then select Generate Getter and Setter methods.

This opens a new screen as shown below.

You can select the data member for which you want to create the getter and setter method. I want to create the getter and setter methods for all the data members, so click on Select All and then click on the Generate Button. This will generate the getter and setter methods for all the data members.

Below is the sample code of the Employee table, which contains the data members needed for Employee JSON and their corresponding getter and setter methods.

public class Employee {

	// private variables or data members of POJO class
	private String firstName;
	private String lastName;
	private int age;
	private double salary;
	private String designation;
	private String contactNumber;
	private String emailId;

	// Getter and setter methods
	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	public double getSalary() {
		return salary;
	}

	public void setSalary(double salary) {
		this.salary = salary;
	}

	public String getDesignation() {
		return designation;
	}

	public void setDesignation(String designation) {
		this.designation = designation;
	}
	
	public String getContactNumber() {
		return contactNumber;
	}

	public void setContactNumber(String contactNumber) {
		this.contactNumber = contactNumber;
	}

	public String getEmailId() {
		return emailId;
	}

	public void setEmailId(String emailId) {
		this.emailId = emailId;
	}

}

Using the above POJO class, you can create any number of custom Employee objects and each object can be converted into a JSON Object and Each JSON object can be parsed into Employee POJO.

We will create a JSON object from POJO and vice versa now, which is generally called serialization and deserialization using Jackson APIs.

Serialization – Serialization is a process where you convert an Instance of a Class (Object of a class) into a Byte Stream. Here, we are converting Employee class object to JSON representation or Object

Deserialization – It is the reverse of serializing. In this process, we will read the Serialized byte stream from the file and convert it back into the Class instance representation. Here, we are converting a JSON Object to an Employee class object.

We are using Jackson API for Serialization and Deserialization. So, add the Jackson dependency to the project.

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.13.0</version>
</dependency>

What is ObjectMapper ?

ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Plain Old Java Objects), or to and from a general-purpose JSON Tree Model (JsonNode), as well as related functionality for performing conversions. It is also highly customizable to work both with different styles of JSON content and to support more advanced object concepts such as polymorphism and object identity.

Now, let us create a Test Class to show Serialization.

public class EmployeeTest {

	@Test
	public void serializationTest()  {

		Employee employee = new Employee();
		employee.setFirstName("Vibha");
		employee.setLastName("Singh");
		employee.setAge(30);
		employee.setSalary(75000);
		employee.setDesignation("Manager");

		// Converting a Java class object to a JSON payload as string
		ObjectMapper mapper = new ObjectMapper();
		String employeeJson = mapper.writeValueAsString(employee);
		String employeePrettyJson = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(employee);
		System.out.println(employeeJson);
		System.out.println(employeePrettyJson);
   }
}try {
			String employeeJson = mapper.writeValueAsString(employee);
			System.out.println(employeeJson);
			String employeePrettyJson = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(employee);
			System.out.println(employeePrettyJson);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}	
	}

Here, ObjectMapper from fasterxml.jackson.databind is used for Serialization.

writeValueAsString() is a method that can be used to serialize any Java value as a String.

writerWithDefaultPrettyPrinter() is used to pretty-print the JSON output. It is a Factory method for constructing ObjectWriter that will serialize objects using the default pretty printer for indentation.

I hope this has helped to clear your doubts regarding POJO and how to create JSON Object using POJO.

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

How to create JSON Array Request Body

HOME

In the last tutorial, I explained  How to test POST JSON Object request using Java Map in Rest Assured . In this tutorial, I will create a request body using JSON Array in Rest Assured. This request body can be used for POST or PUT operations.

What is JSONArray?

JSONArray represents an immutable JSON array (an ordered sequence of zero or more values). It also provides an unmodifiable list view of the values in the array.

  1. JSON array can store multiple value types. The values in a JSONArray can be of the following types: JsonObject, JsonArray, JsonString, JsonNumber, JsonValue.TRUE, JsonValue.FALSE, and JsonValue.NULL.

2. The array index begins with 0.

3. The square brackets [ ] are used to declare the JSON array.

An API may accept a JSON Array payload as a request body. Imagine, we want to add employee details of more than one employee in the below example. In this case, we can pass multiple JSON objects within a JSON array. I have explained 2 ways to create JSON Object – map or JsonObject. Refer to any one of the tutorials to get to know about the creation of JSON Object.

To create a JSON Array, we need to add a maven dependency, as shown below.

<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20210307</version>
</dependency>  

JSONObject is imported from package:-

import org.json.JSONObject;

JSONArray is imported from package:-

import org.json.JSONArray;

Below is an example of JSONArray.

How to create JSONArray Request Body or payload?

  1. Create a JSON Object and add the first employee details.
  2. Create another JSON Object and add second guest details
  3. Create a JSONArray.
  4. Add both JSON Objects to JSONArray.

Below is an example of creating a request from JSONArray with multiple JSON Objects.  I am using a logger just to print the JSON body in the Console. 

public class RequestBodyAsJSONArrayDemo {

	@Test
	public void passBodyAsJsonArrayDemo() {

		// JSON Object for first employee
		JSONObject data1 = new JSONObject();

		data1.put("employee_name", "ObjectTest");
		data1.put("profile_image", "test1.png");
		data1.put("employee_age", "30");
		data1.put("employee_salary", "11111");

		// JSON Object for second employee
		JSONObject data2 = new JSONObject();

		data2.put("employee_name", "MapTest");
		data2.put("profile_image", "test2.png");
		data2.put("employee_age", "20");
		data2.put("employee_salary", "99999");

		// Creating JSON array to add both JSON objects
		JSONArray array = new JSONArray();
		array.put(data1);
		array.put(data2);

		// Send the request		
        RestAssured.given()
                          .contentType(ContentType.JSON)
                          .body(array.toString())
                          .log().all()
				
				.when()
                       .post("http://dummy.restapiexample.com/api/v1/create")
				
				.then()
                      .assertThat().statusCode(200)
                      .body("message", equalTo("Successfully! Record has been added."))
				      .log().all();
	}
}

Below is the execution screenshot.

Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!! Cheers!!

How to test POST JSON Object request using Java Map in Rest Assured

HOME

In the last tutorial, I have explained How to test POST request from JSON Object in Rest Assured where request body is built in JSONObject. In this tutorial, I will create a Request body using JSON Object in Rest Assured. 

We can create a JSON Object using a Map in Java. A JSON Object is a key-value pair and can be easily created using a Java Map. A Map in Java also represents a collection of key-value pairs.

I have created a simple Java map and filled it with the values that represent JSON properties.

	@Test
	public void passBodyAsMap() {
		Map<String, String> map = new HashMap<String, String>();
		map.put("employee_name", "MapTest");
		map.put("employee_salary", "99999");
		map.put("employee_age", "30");
		map.put("profile_image", "test.png");
		RestAssured.given()
                          .contentType(ContentType.JSON)
                          .body(map)
                          .log().all()
				
				   .when()
                         .post("http://dummy.restapiexample.com/api/v1/create")
				
				   .then()
                         .assertThat().statusCode(200)
                         .body("data.employee_name", equalTo("MapTest"))
				         .body("data.employee_age", equalTo("30"))
                         .body("data.employee_salary", equalTo("99999"))
				         .body("message", equalTo("Successfully! Record has been added.")).log().all();
	}

The Request body as well as response body will look as shown below:-

Above one is a simple JSON Request Body. Lets take an example of Complex Request Body or nested Request Body as shown below.

@Test
	public void passBodyAsMultipleMap() {
		// First JSON Object using Hash Map
		Map<String, Object> data = new HashMap<String, Object>();
		data.put("employee_name", "MapTest");
		data.put("profile_image", "test.png");
		// Second JSON Object using Hash Map
		Map<String, String> msg = new HashMap<String, String>();
		msg.put("updated_message", "Details of New Resource");
		msg.put("employee_age", "30");
		data.put("details", msg);
		data.put("employee_salary", "99999");
		RestAssured.given().contentType(ContentType.JSON).body(data).log().all()
				// WHEN
				.when().post("http://dummy.restapiexample.com/api/v1/create")
				// THEN
				.then().assertThat().statusCode(200).body("data.employee_name", equalTo("MapTest"))
				.body("data.details.updated_message", equalTo("Details of New Resource"))
				.body("data.details.employee_age", equalTo("30")).body("data.employee_salary", equalTo("99999"))
				.body("message", equalTo("Successfully! Record has been added.")).log().all();
	}
}

The Request body as well as response body will look as shown below image. First part is the body of request and second part is the response provided by API.

Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

How to test POST request from JSON Object in Rest Assured

HOME

In the last tutorial, I have explained How to test POST Request using Rest Assured where request body is in String Format. In this tutorial, I will create a Request body using JSON Object in Rest Assured. This request body can be used for POST or PUT operations.

First, setup a basic Rest Assured Maven Project by clicking here and Gradle project by clicking here.

In the previous post, you must have observed that I had hard-coded the JSON request body in a string format. It is not a good practice if you have the dynamic payload or want to create a payload at run time or parameterized one. It is always recommended to create a payload in such a way that you can easily maintain, manage, update, and retrieve values from it. This can be achieved by JSONObject or JSONArray.

JSONObject is an unordered collection of key and value pairs, resembling Java’s native Map implementations. JSON stores data as a key-value pair. Key is left side and value is the right side and a semicolon is used to separate both. One key-value pair is separated from another key-value pair using comma (,).

The internal form is an object having to get and opt methods for accessing the values by name and put methods for adding or replacing values by name. The values can be any of these types: Boolean, JSONArray, JSONObject, Number, String, or the JSONObject.NULL object.

To create a request body using JSON Object, we need to add a maen dependency.

<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20210307</version>
</dependency>   

JSONObject is imported from package:-

import org.json.JSONObject;

JSONObject exposes an API similar to Java’s Map interface. Below is an example of creating a request from JSON Object. Here, Id is auto-generated attribute. We are using the put() method and supply the key and value as an argument. I am using a logger just to print the JSON body in the Console. 

@Test
	public void passBodyAsJsonObject() {

		JSONObject data = new JSONObject();

		data.put("employee_name", "MapTest");
		data.put("profile_image", "test.png");
		data.put("employee_age", "30");
		data.put("employee_salary", "11111");

		
		RestAssured.given()
                      .contentType(ContentType.JSON)
                      .body(data.toString())
                      .log().all()
			
				  .when()
                      .post("http://dummy.restapiexample.com/api/v1/create")
				
				  .then()
                       .assertThat().statusCode(200)
                       .body("data.employee_name", equalTo("MapTest"))
				       .body("data.employee_age", equalTo("30"))
                       .body("data.employee_salary", equalTo("11111"))
				       .body("data.profile_image", equalTo("test.png"))
				       .body("message", equalTo("Successfully! Record has been added."))
                       .log().all();

	}

The Request body will look as shown below:-

The texts produced by the toString() methods strictly conform to the JSON syntax rules.

 .body(data.toString())

Above one is a simple JSON Request Body. Lets take an example of Complex Request Body or nested Request Body.

We need to create two JSONObject here. One will hold overall key-value pairs and another JSONObject will hold only employee_details key-value pairs. 

Below is the example which shows how to create a complex JSON request body using JSONObject.

@Test
	public void passBodyAsJsonObjectDemo() {
        
        //First JSONObject
		JSONObject data = new JSONObject();

		data.put("profile_image", "test.png");
        
        //Second JSONObject
		JSONObject detail = new JSONObject();

		detail.put("updated_message", "Details of New Resource");
		detail.put("employee_age", "30");

		data.put("employee_details", detail);

		data.put("employee_name", "MapTest");
		data.put("employee_salary", "11111");

		
		RestAssured.given()
                         .contentType(ContentType.JSON)
                         .body(data.toString())
                         .log().all()
				
				    .when()
                          .post("http://dummy.restapiexample.com/api/v1/create")
				
				    .then()
                           .assertThat().statusCode(200)
                           .body("data.employee_name", equalTo("MapTest"))
				           .body("data.employee_details.employee_age", equalTo("30"))
				           .body("data.employee_details.updated_message", equalTo("Details of New Resource"))
				           .body("data.employee_salary", equalTo("11111")).body("data.profile_image", equalTo("test.png"))
				          .body("message", equalTo("Successfully! Record has been added."))
                          .log().all();
	}
}

The Request body will look as shown below:-

We are done. Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!

Rest Assured Tutorials

HOME

RestAssured is a Java-based library that is used to test RESTful Web Services. REST-assured was designed to simplify the testing and validation of REST APIs and is highly influenced by testing techniques used in dynamic languages such as Ruby and Groovy.

Chapter 1 Introduction to Rest Assured
Chapter 2 Setup Basic REST Assured Maven Project In Eclipse IDE
Chapter 3 How to test GET Request using Rest Assured
Chapter 4 How to test POST Request using Rest Assured
Chapter 5 How to test PUT Request using Rest Assured
Chapter 6 How to test DELETE Request using Rest Assured
Chapter 7 How to test POST request from JSON Object in Rest Assured
Chapter 8 How to test POST JSON Object request using Java Map in Rest Assured
Chapter 9 How to create JSON Array Request Body
Chapter 10 Assertion of JSON in Rest Assured using Hamcrest
Chapter 11 Extraction from JSON in Rest Assured
Chapter 12 How To Send A JSON/XML File As Payload To Request using Rest Assured
Chapter 13 Logging in Rest Assured

JSON Manipulation

Gradle

Chapter 1 Setup Basic REST Assured Gradle Project In Eclipse IDE

Frameworks

Chapter 1 Integration of REST Assured with TestNG
Chapter 2 Serenity BDD with Cucumber and Rest Assured
Chapter 3 Serenity BDD with Cucumber and Rest Assured in Gradle
Chapter 4 How To Create Gradle Project with Cucumber to test Rest API
Chapter 5 Rest API Test in Cucumber BDD