com.epam.http.requests.RestRequest Maven / Gradle / Ivy
package com.epam.http.requests;
import com.epam.http.response.ResponseStatusType;
import com.epam.http.response.RestResponse;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
import static com.epam.http.ExceptionHandler.exception;
import static com.epam.http.JdiHttpSettigns.verifyOkStatus;
import static java.lang.System.currentTimeMillis;
/**
* Created by Roman_Iovlev on 12/19/2016.
*/
public class RestRequest {
public static RestResponse doRequest(
RestMethodTypes methodType, RequestSpecification spec, ResponseStatusType excpecedtStatus) {
Response response;
long time;
try {
time = currentTimeMillis();
response = methodType.method.apply(spec).prettyPeek();
time = currentTimeMillis() - time;
} catch (Exception ex) { throw exception("Request failed"); }
RestResponse resp = new RestResponse(response, time);
if (verifyOkStatus)
resp.isStatus(excpecedtStatus);
return resp;
}
private static String printRS(RequestSpecification rs) {
return rs.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy