Class RestApiInterface

java.lang.Object
core.apiCore.interfaces.RestApiInterface

public class RestApiInterface
extends Object
  • Field Details

  • Constructor Details

    • RestApiInterface

      public RestApiInterface()
  • Method Details

    • 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: