Package core.apiCore.interfaces
Class RestApiInterface
- java.lang.Object
-
- core.apiCore.interfaces.RestApiInterface
-
public class RestApiInterface extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringAPI_BASE_URLstatic StringAPI_PAGINATION_COUNTERstatic StringAPI_PAGINATION_INCREMENTstatic StringAPI_PAGINATION_MAX_PAGESstatic StringAPI_PAGINATION_PAGES_FROMstatic StringAPI_PAGINATION_STOP_CRITERIAstatic StringAPI_PARAMETER_ENCODINGstatic StringAPI_TIMEOUT_PAGINATION_VALIDATION_ENABLEDstatic StringAPI_USE_RELAXED_HTTPS_VALIDATION
-
Constructor Summary
Constructors Constructor Description RestApiInterface()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static io.restassured.response.Responseevaluate(ServiceObject serviceObject)static voidevaluateOption(ServiceObject serviceObject)sets the header, content type And body based on specificationsstatic io.restassured.response.ResponseevaluatePagination(ServiceObject serviceObject)evaluate pagination format: http://url?page=<@PAGINATION_FROM_1> counter will start from page 1 will iterate through the pages until either: - the expected response criteria is met - max pages are reached.static io.restassured.specification.RequestSpecificationevaluateQueryParameters(ServiceObject serviceObject, io.restassured.specification.RequestSpecification request)evaluate query parameters format: "name=key=value&key2=value2"static ServiceObjectevaluateRequest(ServiceObject serviceObject, io.restassured.specification.RequestSpecification request)static ServiceObjectevaluateRequestAndReceiveResponse(ServiceObject serviceObject)evaluates the request and stores the response in service objectstatic booleanevaluateRequestAndValidatePagination(ServiceObject serviceObject)static io.restassured.response.ResponseevaluateRequestAndValidateResponse(ServiceObject serviceObject)evaluate request and validate response retry until validation timeout period in seconds RetryAfterSecond is based on waiting after the validation round is complete, including wait for response wait periodstatic io.restassured.specification.RequestSpecificationevaluateRequestBody(ServiceObject serviceObject, io.restassured.specification.RequestSpecification request)static io.restassured.specification.RequestSpecificationevaluateRequestHeaders(ServiceObject serviceObject, io.restassured.specification.RequestSpecification request)sets the header, content type And body based on specifications Headers are based on key value, separated by ";" Invalid token: if authorization token exists, replace last values with "invalid", else set to "invalid" we replace parameters per authentication typestatic URLgetBaseUrl()get base url from the configstatic booleangetProxyState()static io.restassured.response.ResponseRestfullApiInterface(ServiceObject serviceObject)interface for restful API callsstatic voidsaveOutBoundValues(ServiceObject serviceObject)static voidsetProxy()set proxy from config file value to use proxy is set at API_AUTO_PROXY_SET We evaluate if we need to use proxy once in test runstatic voidsetTimeout()set connection timeout in millisecondsstatic io.restassured.specification.RequestSpecificationsetURI(ServiceObject serviceObject)sets base uri for api callstatic List<String>validateResponse(ServiceObject serviceObject)static List<String>validateStatusCode(io.restassured.response.Response response, ServiceObject serviceObject)validate status code
-
-
-
Field Detail
-
API_TIMEOUT_PAGINATION_VALIDATION_ENABLED
public static final String API_TIMEOUT_PAGINATION_VALIDATION_ENABLED
- See Also:
- Constant Field Values
-
API_PAGINATION_STOP_CRITERIA
public static final String API_PAGINATION_STOP_CRITERIA
- See Also:
- Constant Field Values
-
API_PAGINATION_MAX_PAGES
public static final String API_PAGINATION_MAX_PAGES
- See Also:
- Constant Field Values
-
API_PAGINATION_PAGES_FROM
public static final String API_PAGINATION_PAGES_FROM
- See Also:
- Constant Field Values
-
API_PAGINATION_INCREMENT
public static final String API_PAGINATION_INCREMENT
- See Also:
- Constant Field Values
-
API_PAGINATION_COUNTER
public static final String API_PAGINATION_COUNTER
- See Also:
- Constant Field Values
-
API_PARAMETER_ENCODING
public static final String API_PARAMETER_ENCODING
- See Also:
- Constant Field Values
-
API_USE_RELAXED_HTTPS_VALIDATION
public static final String API_USE_RELAXED_HTTPS_VALIDATION
- See Also:
- Constant Field Values
-
API_BASE_URL
public static final String API_BASE_URL
- See Also:
- Constant Field Values
-
-
Method Detail
-
RestfullApiInterface
public static io.restassured.response.Response RestfullApiInterface(ServiceObject serviceObject)
interface for restful API calls- Parameters:
serviceObject-- Returns:
-
evaluate
public static io.restassured.response.Response evaluate(ServiceObject serviceObject)
-
evaluateRequestAndValidateResponse
public static io.restassured.response.Response evaluateRequestAndValidateResponse(ServiceObject serviceObject)
evaluate request and validate response retry until validation timeout period in seconds RetryAfterSecond is based on waiting after the validation round is complete, including wait for response wait period- Parameters:
serviceObject-- Returns:
-
evaluatePagination
public static io.restassured.response.Response evaluatePagination(ServiceObject serviceObject)
evaluate pagination format: http://url?page=<@PAGINATION_FROM_1> counter will start from page 1 will iterate through the pages until either: - the expected response criteria is met - max pages are reached. specified by PAGINATION_MAX_PAGES:100 in options - response criteria for max pages is reached. OPTION_PAGINATION_STOP_CRITERIA:.results.id - if the list of responses on a selected page is 0, that means the page has no results, hence, it is the last page- Parameters:
serviceObject-- Returns:
-
evaluateRequestAndValidatePagination
public static boolean evaluateRequestAndValidatePagination(ServiceObject serviceObject)
-
evaluateRequestAndReceiveResponse
public static ServiceObject evaluateRequestAndReceiveResponse(ServiceObject serviceObject)
evaluates the request and stores the response in service object- Parameters:
serviceObject-- Returns:
-
setURI
public static io.restassured.specification.RequestSpecification setURI(ServiceObject serviceObject)
sets base uri for api call- Returns:
-
setTimeout
public static void setTimeout()
set connection timeout in milliseconds
-
setProxy
public static void setProxy()
set proxy from config file value to use proxy is set at API_AUTO_PROXY_SET We evaluate if we need to use proxy once in test run- Throws:
Exception
-
getProxyState
public static boolean getProxyState()
-
validateResponse
public static List<String> validateResponse(ServiceObject serviceObject)
-
saveOutBoundValues
public static void saveOutBoundValues(ServiceObject serviceObject)
-
validateStatusCode
public static List<String> validateStatusCode(io.restassured.response.Response response, ServiceObject serviceObject)
validate status code- Parameters:
response-serviceObject-- Returns:
-
evaluateRequestHeaders
public static io.restassured.specification.RequestSpecification evaluateRequestHeaders(ServiceObject serviceObject, io.restassured.specification.RequestSpecification request)
sets the header, content type And body based on specifications Headers are based on key value, separated by ";" Invalid token: if authorization token exists, replace last values with "invalid", else set to "invalid" we replace parameters per authentication type- Parameters:
serviceObject-- Returns:
-
evaluateQueryParameters
public static io.restassured.specification.RequestSpecification evaluateQueryParameters(ServiceObject serviceObject, io.restassured.specification.RequestSpecification request)
evaluate query parameters format: "name=key=value&key2=value2"- Parameters:
serviceObject-request-- Returns:
-
evaluateRequestBody
public static io.restassured.specification.RequestSpecification evaluateRequestBody(ServiceObject serviceObject, io.restassured.specification.RequestSpecification request)
-
evaluateOption
public static void evaluateOption(ServiceObject serviceObject)
sets the header, content type And body based on specifications- Parameters:
serviceObject-
-
evaluateRequest
public static ServiceObject evaluateRequest(ServiceObject serviceObject, io.restassured.specification.RequestSpecification request)
-
getBaseUrl
public static URL getBaseUrl()
get base url from the config- Returns:
-
-