Interface ApiConfig

All Known Implementing Classes:
Api

public interface ApiConfig
Interface that defines helper configuration methods for helper operations. Validates that all required methods are implemented.
  • Method Summary

    Modifier and Type
    Method
    Description
    Remove global headers
    Remove global query parameters
    Returns and logs (at INFO level) a human-readable summary of all resolved configuration values.
    setBasicAuth(String username, String password)
    Sets Basic authentication
    Sets Bearer authentication
    setContentType(io.restassured.http.ContentType contentType)
    Set content type manually ContentType
    Set content type JSON
    Set content type XML
    setHeader(String key, Object value)
    Add or updates header globally (add to previously set)
    Set headers globally (overwrite previously set)
    setLogging(boolean enable)
    Enables or disables logging manually (debug log level will print logs anyway!)
    setMaxResponseMsAssert(int maxResponseMs)
    Set maxResponseTimeout (does not break the connection - only assert)
    Unset all authentications
    Set content type absent
    Set query parameters globally (overwrite previously set)
    setTimeoutMs(int maxTimeoutMs)
    Set max request timeout(connection/read)
    withHeader(String key, Object value)
    Add header for one next request (global headers will be ignored) use for specific request can be used multiple times to add multiple headers after request global headers are taken into account again
    withHeaders(Map<String,Object> queryParams)
    Add headers for one next request (global headers will be ignored) use for specific request after request global headers are taken into account again
    Add query parameter once for next request (global query parameters will be ignored) use before specific request can be used multiple times to add multiple query parameters after request global query parameter are taken into account again
    Add query parameters once for next request (global query parameters will be ignored) use before specific request after request global query parameter are taken into account again
  • Method Details

    • setContentTypeXml

      Api setContentTypeXml()
      Set content type XML
      Returns:
      this instance for method chaining
    • setContentTypeJson

      Api setContentTypeJson()
      Set content type JSON
      Returns:
      this instance for method chaining
    • setContentType

      Api setContentType(io.restassured.http.ContentType contentType)
      Set content type manually ContentType
      Parameters:
      contentType - ContentType:
      • ContentType.ANY
      • ContentType.TEXT
      • ContentType.JSON
      • ContentType.XML
      • ContentType.HTML
      • ContentType.URLENC
      • ContentType.BINARY
      • ContentType.MULTIPART
      Returns:
      this instance for method chaining
    • setMaxResponseMsAssert

      Api setMaxResponseMsAssert(int maxResponseMs)
      Set maxResponseTimeout (does not break the connection - only assert)
      Parameters:
      maxResponseMs - assert ms for max response time
      Returns:
      this instance for method chaining
      Throws:
      AssertionError - if response time greater
    • setTimeoutMs

      Api setTimeoutMs(int maxTimeoutMs)
      Set max request timeout(connection/read)

      Drop connection on timeout is up

      Parameters:
      maxTimeoutMs - max ms for connection/read
      Returns:
      this instance for method chaining
    • setNoContentType

      Api setNoContentType()
      Set content type absent
      Returns:
      this instance for method chaining
    • setLogging

      Api setLogging(boolean enable)
      Enables or disables logging manually (debug log level will print logs anyway!)
      Parameters:
      enable - true=request/response logging (Allure on always!)
      Returns:
      this instance for method chaining
    • setHeader

      Api setHeader(String key, Object value)
      Add or updates header globally (add to previously set)
      Parameters:
      key - header key
      value - header value
      Returns:
      this instance for method chaining
    • setHeaders

      Api setHeaders(Map<String,Object> headers)
      Set headers globally (overwrite previously set)
      Parameters:
      headers - Map (key, value)
      Returns:
      this instance for method chaining
    • cleanSetHeaders

      Api cleanSetHeaders()
      Remove global headers
      Returns:
      this instance for method chaining
    • setQueryParams

      Api setQueryParams(Map<String,Object> queryParams)
      Set query parameters globally (overwrite previously set)
      Parameters:
      queryParams - Map (key, value)
      Returns:
      this instance for method chaining
    • cleanSetQueryParams

      Api cleanSetQueryParams()
      Remove global query parameters
      Returns:
      this instance for method chaining
    • setBearerAuth

      Api setBearerAuth(String token)
      Sets Bearer authentication
      Parameters:
      token - String with token
      Returns:
      this instance for method chaining
    • setBasicAuth

      Api setBasicAuth(String username, String password)
      Sets Basic authentication
      Parameters:
      username - String with username
      password - String with password
      Returns:
      this instance for method chaining
    • setNoAuth

      Api setNoAuth()
      Unset all authentications
      Returns:
      this instance for method chaining
    • withHeader

      Api withHeader(String key, Object value)
      Add header for one next request (global headers will be ignored)
      • use for specific request
      • can be used multiple times to add multiple headers
      • after request global headers are taken into account again
      Parameters:
      key - header key
      value - header value
      Returns:
      this instance for method chaining
    • withHeaders

      Api withHeaders(Map<String,Object> queryParams)
      Add headers for one next request (global headers will be ignored)
      • use for specific request
      • after request global headers are taken into account again
      Parameters:
      queryParams - Map (key, value)
      Returns:
      this instance for method chaining
    • withQueryParam

      Api withQueryParam(String key, Object value)
      Add query parameter once for next request (global query parameters will be ignored)
      • use before specific request
      • can be used multiple times to add multiple query parameters
      • after request global query parameter are taken into account again
      Parameters:
      key - parameter key
      value - parameter value
      Returns:
      this instance for method chaining
    • withQueryParams

      Api withQueryParams(Map<String,Object> queryParams)
      Add query parameters once for next request (global query parameters will be ignored)
      • use before specific request
      • after request global query parameter are taken into account again
      Parameters:
      queryParams - Map (key, value)
      Returns:
      this instance for method chaining
    • getConfigSummary

      String getConfigSummary()
      Returns and logs (at INFO level) a human-readable summary of all resolved configuration values.

      The summary includes values loaded from the YAML configuration file as well as any fields overridden programmatically after construction. Optional fields that were not present in the configuration and resolved via default values may also be included.

      Returns:
      String with summary