Class ReportPortalRestAssuredLoggingFilter
- java.lang.Object
-
- com.epam.reportportal.formatting.AbstractHttpFormatter<ReportPortalRestAssuredLoggingFilter>
-
- com.epam.reportportal.restassured.ReportPortalRestAssuredLoggingFilter
-
- All Implemented Interfaces:
io.restassured.filter.Filter,io.restassured.filter.OrderedFilter
public class ReportPortalRestAssuredLoggingFilter extends com.epam.reportportal.formatting.AbstractHttpFormatter<ReportPortalRestAssuredLoggingFilter> implements io.restassured.filter.OrderedFilter
REST Assured Request/Response logging filter for Report Portal.The filter intercept and logs all Requests and Responses issued by REST Assured into Report Portal in Markdown format, including multipart requests. It recognizes payload types and attach them in corresponding manner: image types will be logged as images with thumbnails, binary types will be logged as entry attachments, text types will be formatted and logged in Markdown code blocks.
Basic usage:
RestAssured.filters(new ReportPortalRestAssuredLoggingFilter(42, LogLevel.INFO));
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringNULL_RESPONSEprotected java.util.function.Function<com.epam.reportportal.formatting.http.entities.Param,java.lang.String>paramConverter
-
Constructor Summary
Constructors Constructor Description ReportPortalRestAssuredLoggingFilter(int filterOrder, com.epam.reportportal.listeners.LogLevel defaultLogLevel)Create an ordered REST Assured filter with the log level.ReportPortalRestAssuredLoggingFilter(int filterOrder, com.epam.reportportal.listeners.LogLevel defaultLogLevel, java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> headerConvertFunction, java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> partHeaderConvertFunction)Create an ordered REST Assured filter with the log level and header converters.ReportPortalRestAssuredLoggingFilter(int filterOrder, com.epam.reportportal.listeners.LogLevel defaultLogLevel, java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> headerConvertFunction, java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> partHeaderConvertFunction, java.util.function.Function<com.epam.reportportal.formatting.http.entities.Cookie,java.lang.String> cookieConvertFunction)Create an ordered REST Assured filter with the log level and different converters.ReportPortalRestAssuredLoggingFilter(int filterOrder, com.epam.reportportal.listeners.LogLevel defaultLogLevel, java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> headerConvertFunction, java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> partHeaderConvertFunction, java.util.function.Function<com.epam.reportportal.formatting.http.entities.Cookie,java.lang.String> cookieConvertFunction, java.util.function.Function<java.lang.String,java.lang.String> uriConverterFunction)Create an ordered REST Assured filter with the log level and different converters.zReportPortalRestAssuredLoggingFilter(int filterOrder, com.epam.reportportal.listeners.LogLevel defaultLogLevel, java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> headerConvertFunction, java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> partHeaderConvertFunction, java.util.function.Function<com.epam.reportportal.formatting.http.entities.Cookie,java.lang.String> cookieConvertFunction, java.util.function.Function<java.lang.String,java.lang.String> uriConverterFunction, java.util.function.Function<com.epam.reportportal.formatting.http.entities.Param,java.lang.String> paramConverter)Create an ordered REST Assured filter with the log level and different converters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReportPortalRestAssuredLoggingFilteraddRequestFilter(java.util.function.Predicate<io.restassured.specification.FilterableRequestSpecification> requestFilter)Add a request filter to the filter.io.restassured.response.Responsefilter(io.restassured.specification.FilterableRequestSpecification requestSpec, io.restassured.specification.FilterableResponseSpecification responseSpec, io.restassured.filter.FilterContext ctx)intgetOrder()
-
-
-
Field Detail
-
NULL_RESPONSE
public static final java.lang.String NULL_RESPONSE
- See Also:
- Constant Field Values
-
paramConverter
protected final java.util.function.Function<com.epam.reportportal.formatting.http.entities.Param,java.lang.String> paramConverter
-
-
Constructor Detail
-
ReportPortalRestAssuredLoggingFilter
public ReportPortalRestAssuredLoggingFilter(int filterOrder, @Nonnull com.epam.reportportal.listeners.LogLevel defaultLogLevel, @Nullable java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> headerConvertFunction, @Nullable java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> partHeaderConvertFunction, @Nullable java.util.function.Function<com.epam.reportportal.formatting.http.entities.Cookie,java.lang.String> cookieConvertFunction, @Nullable java.util.function.Function<java.lang.String,java.lang.String> uriConverterFunction, @Nullable java.util.function.Function<com.epam.reportportal.formatting.http.entities.Param,java.lang.String> paramConverter)Create an ordered REST Assured filter with the log level and different converters.- Parameters:
filterOrder- if you have different filters which modify requests on fly this parameter allows you to control the order when Report Portal logger will be called, and therefore log or don't log some data.defaultLogLevel- log level on which REST Assured requests/responses will appear on Report PortalheaderConvertFunction- if you want to preprocess your HTTP Headers before they appear on Report Portal provide this custom function for the class, default function formats it like that:header.getName() + ": " + header.getValue()partHeaderConvertFunction- the same as fot HTTP Headers, but for parts in Multipart requestcookieConvertFunction- the same as 'headerConvertFunction' param but for Cookies, default function formats Cookies withtoStringmethoduriConverterFunction- the same as 'headerConvertFunction' param but for URI, default function returns URI "as is"paramConverter- the same as 'headerConvertFunction' param but for Web Form Params, default function returnsparam.getName() + ": " + param.getValue()
-
ReportPortalRestAssuredLoggingFilter
public ReportPortalRestAssuredLoggingFilter(int filterOrder, @Nonnull com.epam.reportportal.listeners.LogLevel defaultLogLevel, @Nullable java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> headerConvertFunction, @Nullable java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> partHeaderConvertFunction, @Nullable java.util.function.Function<com.epam.reportportal.formatting.http.entities.Cookie,java.lang.String> cookieConvertFunction, @Nullable java.util.function.Function<java.lang.String,java.lang.String> uriConverterFunction)Create an ordered REST Assured filter with the log level and different converters.z- Parameters:
filterOrder- if you have different filters which modify requests on fly this parameter allows you to control the order when Report Portal logger will be called, and therefore log or don't log some data.defaultLogLevel- log level on which REST Assured requests/responses will appear on Report PortalheaderConvertFunction- if you want to preprocess your HTTP Headers before they appear on Report Portal provide this custom function for the class, default function formats it like that:header.getName() + ": " + header.getValue()partHeaderConvertFunction- the same as fot HTTP Headers, but for parts in Multipart requestcookieConvertFunction- the same as 'headerConvertFunction' param but for Cookies, default function formats Cookies withtoStringmethoduriConverterFunction- the same as 'headerConvertFunction' param but for URI, default function returns URI "as is"
-
ReportPortalRestAssuredLoggingFilter
public ReportPortalRestAssuredLoggingFilter(int filterOrder, @Nonnull com.epam.reportportal.listeners.LogLevel defaultLogLevel, @Nullable java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> headerConvertFunction, @Nullable java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> partHeaderConvertFunction, @Nullable java.util.function.Function<com.epam.reportportal.formatting.http.entities.Cookie,java.lang.String> cookieConvertFunction)Create an ordered REST Assured filter with the log level and different converters.- Parameters:
filterOrder- if you have different filters which modify requests on fly this parameter allows you to control the order when Report Portal logger will be called, and therefore log or don't log some data.defaultLogLevel- log level on which REST Assured requests/responses will appear on Report PortalheaderConvertFunction- if you want to preprocess your HTTP Headers before they appear on Report Portal provide this custom function for the class, default function formats it like that:header.getName() + ": " + header.getValue()partHeaderConvertFunction- the same as fot HTTP Headers, but for parts in Multipart requestcookieConvertFunction- the same as 'headerConvertFunction' param but for Cookies, default function formats Cookies withtoStringmethod
-
ReportPortalRestAssuredLoggingFilter
public ReportPortalRestAssuredLoggingFilter(int filterOrder, @Nonnull com.epam.reportportal.listeners.LogLevel defaultLogLevel, @Nullable java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> headerConvertFunction, @Nullable java.util.function.Function<com.epam.reportportal.formatting.http.entities.Header,java.lang.String> partHeaderConvertFunction)Create an ordered REST Assured filter with the log level and header converters.- Parameters:
filterOrder- if you have different filters which modify requests on fly this parameter allows you to control the order when Report Portal logger will be called, and therefore log or don't log some data.defaultLogLevel- log level on which REST Assured requests/responses will appear on Report PortalheaderConvertFunction- if you want to preprocess your HTTP Headers before they appear on Report Portal provide this custom function for the class, default function formats it like that:header.getName() + ": " + header.getValue()partHeaderConvertFunction- the same as fot HTTP Headers, but for parts in Multipart request
-
ReportPortalRestAssuredLoggingFilter
public ReportPortalRestAssuredLoggingFilter(int filterOrder, @Nonnull com.epam.reportportal.listeners.LogLevel defaultLogLevel)Create an ordered REST Assured filter with the log level.- Parameters:
filterOrder- if you have different filters which modify requests on fly this parameter allows you to control the order when Report Portal logger will be called, and therefore log or don't log some data.defaultLogLevel- log level on which REST Assured requests/responses will appear on Report Portal
-
-
Method Detail
-
getOrder
public int getOrder()
- Specified by:
getOrderin interfaceio.restassured.filter.OrderedFilter
-
filter
public io.restassured.response.Response filter(io.restassured.specification.FilterableRequestSpecification requestSpec, io.restassured.specification.FilterableResponseSpecification responseSpec, io.restassured.filter.FilterContext ctx)- Specified by:
filterin interfaceio.restassured.filter.Filter
-
addRequestFilter
@Nonnull public ReportPortalRestAssuredLoggingFilter addRequestFilter(@Nonnull java.util.function.Predicate<io.restassured.specification.FilterableRequestSpecification> requestFilter)
Add a request filter to the filter.The filter is used to determine whether the request should be logged or not. If the filter returns
true, the request will be skipped, otherwise it will be logged.- Parameters:
requestFilter- the request filter- Returns:
- the filter instance
-
-