I want to send a post request in my test using the format:
RequestSpecification requestSpecification = RestAssured.given()
.contentType(ContentType.JSON)
.body(taskDetailsFormSubmission);
actor.attemptsTo(
Post.to(path).with(requestSpecification)
);
I am creating a RequestSpecification and parsing a JSON file in one of my directories.
The problem however is that with() only accepts the type RestQueryFunction. Looking at the interface:
public interface RestQueryFunction extends Function<RequestSpecification,RequestSpecification> {}
I'm just not really sure how to apply the RequestSpecification to the POST request.
Function<RequestSpecification,RequestSpecification>is a case ofFunction<T,R>java functional interface.The method
with()requiresRestQueryFunctionmeans you have to provide an implementation ofRestQueryFunctionwhich might be a class, anonymous class or lambda expression. It follows the rule:You could try