Sorry if these are noob questions, I've only been using Java and Rest-Assured for the past few days, so my understanding of the underlying Java might not be very solid (I come from a background of Python and C++, still in University).
Is there already a global RestAssured object when I compile, or am I supposed to create my own? AKA, which should I be doing?
//modifies some global object that lives the entire duration of the code lifetime
OR
Request foo = new Response;
//Now that I think about it, this probably is what actually happens...
Do all the methods modify the original object, or do they return a modified copy? (Do I need to keep reassigning a response object back to itself when I call a method on it?)
Request foo;
foo = foo.given().header("headerName1", "headerValue1");
OR
foo.given().header("headerName1", "headerValue1"); // modifies the original?
What exactly do the methods given() and when() and then() do? Do they return a different object type? What I think might be happening is this:
auto foo = RestAssured.port(80); //port() returns a request object
//any method called on foo at this point
//returns a copy of the original request object modified in some way
//(aka changing the default port or URI)
auto foo2 = foo.when().get(/login").param("paramName1", "paramValue1");
//As soon as when() method is invoked on foo, it turns into a response object (is this right?)
//now that foo2 is a response object, you can call methods like statuscode(200) on it, which will
//either throw an exception if the statuscode doesn't match 200, or return itself.
If my assumptions are correct above, then what exactly do the then(), given(), and when() methods do? Are they just syntactic sugar (first time I've encountered this term, actually)?
I assume it doesn't do anything, because after method get(), the returned object is already of class Response. Is there even a difference between Request and Response objects?
Or are they the same class type?