All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.restup.test.ApiResponse Maven / Gradle / Ivy

package com.github.restup.test;

import java.util.Map;
import org.hamcrest.Matcher;
import com.github.restup.test.resource.Contents;
import com.github.restup.test.resource.RelativeTestResource;

public interface ApiResponse {

    static Builder builder() {
        return new Builder();
    }


    default H getHeader(String key) {
        for (Map.Entry e : getHeaders().entrySet()) {
            if (key.equalsIgnoreCase(e.getKey())) {
                return e.getValue();
            }
        }
        return null;
    }
    
    int getStatus();

    Map getHeaders();

    Contents getBody();

    static class Builder extends AbstractApiRequestBuilder> {

        private int status;

        public Builder status(int status) {
            this.status = status;
            return me();
        }

        @Override
        protected String getTestDir() {
            return RelativeTestResource.RESPONSES;
        }

        public ApiResponse> build() {
            return new BasicApiResponse<>(status, getHeaders(), getBody());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy