Crud operation examples uisng Rest assured
package CrudOperationExamples;
import static io.restassured.RestAssured.given;
import java.io.File;
import org.testng.annotations.Test;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
public class GetReqTest {
@Test
public void getAllStudent(){
RestAssured.baseURI = "http://localhost";
RestAssured.port = 8080;
RestAssured.basePath = "/student";
//We can filter our get request using 2 methods . By changing the basePath.Like we want to get data of only student with id 10. We can do
//something like this
// RestAssured.basePath = "/student/10";
//We can also get a list of all students like this
RestAssured.basePath = "/student/list";
//But the way we set basePath above. That is not recommended way. The recommended way to do it the one below. That is pass the filter
//arguments in get method of req
Response response = given().contentType(ContentType.JSON).header("X","Y").log().all().get("/list?programme=Computer Science&limit=2");
response.prettyPrint();
}
}