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 TypeMethodDescriptionRemove global headersRemove global query parametersReturns and logs (at INFO level) a human-readable summary of all resolved configuration values.setBasicAuth(String username, String password) Sets Basic authenticationsetBearerAuth(String token) Sets Bearer authenticationsetContentType(io.restassured.http.ContentType contentType) Set content type manuallyContentTypeSet content type JSONSet content type XMLAdd or updates header globally (add to previously set)setHeaders(Map<String, Object> headers) 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 authenticationsSet content type absentsetQueryParams(Map<String, Object> queryParams) 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 againwithHeaders(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 againwithQueryParam(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 againwithQueryParams(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
-
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
Set content type manuallyContentType- Parameters:
contentType-ContentType:ContentType.ANYContentType.TEXTContentType.JSONContentType.XMLContentType.HTMLContentType.URLENCContentType.BINARYContentType.MULTIPART
- Returns:
- this instance for method chaining
-
setMaxResponseMsAssert
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
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
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
Add or updates header globally (add to previously set)- Parameters:
key- header keyvalue- header value- Returns:
- this instance for method chaining
-
setHeaders
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
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
Sets Bearer authentication- Parameters:
token- String with token- Returns:
- this instance for method chaining
-
setBasicAuth
Sets Basic authentication- Parameters:
username- String with usernamepassword- String with password- Returns:
- this instance for method chaining
-
setNoAuth
Api setNoAuth()Unset all authentications- Returns:
- this instance for method chaining
-
withHeader
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 keyvalue- header value- Returns:
- this instance for method chaining
-
withHeaders
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
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 keyvalue- parameter value- Returns:
- this instance for method chaining
-
withQueryParams
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
-