Search in sources :

Example 1 with ApiPair

use of ru.sbtqa.tag.api.repository.ApiPair in project page-factory-2 by sbtqa.

the class EndpointEntry method send.

public void send() {
    reflection.applyAnnotations(FromResponse.class);
    reflection.applyAnnotations(Query.class);
    reflection.applyAnnotations(Stashed.class);
    reflection.applyAnnotations(Mutator.class);
    String url = PathUtils.unite(host.isEmpty() ? PROPERTIES.getBaseURI() : PlaceholderUtils.replaceTemplatePlaceholders(host), path);
    RequestSpecification request = buildRequest();
    Response response;
    switch(method) {
        case GET:
            response = request.get(url);
            break;
        case POST:
            response = request.post(url);
            break;
        case PUT:
            response = request.put(url);
            break;
        case PATCH:
            response = request.patch(url);
            break;
        case DELETE:
            response = request.delete(url);
            break;
        case OPTIONS:
            response = request.options(url);
            break;
        case HEAD:
            response = request.head(url);
            break;
        default:
            throw new UnsupportedOperationException("Request method " + method + " is not supported");
    }
    ApiEnvironment.getRepository().add(this.getClass(), new ApiPair(request, response.then().log().all(true)));
}
Also used : ValidatableResponse(io.restassured.response.ValidatableResponse) FromResponse(ru.sbtqa.tag.api.annotation.FromResponse) Response(io.restassured.response.Response) ApiPair(ru.sbtqa.tag.api.repository.ApiPair) RequestSpecification(io.restassured.specification.RequestSpecification)

Aggregations

Response (io.restassured.response.Response)1 ValidatableResponse (io.restassured.response.ValidatableResponse)1 RequestSpecification (io.restassured.specification.RequestSpecification)1 FromResponse (ru.sbtqa.tag.api.annotation.FromResponse)1 ApiPair (ru.sbtqa.tag.api.repository.ApiPair)1