18
18
19
19
import com .epam .reportportal .formatting .AbstractHttpFormatter ;
20
20
import com .epam .reportportal .formatting .http .converters .DefaultCookieConverter ;
21
+ import com .epam .reportportal .formatting .http .converters .DefaultFormParamConverter ;
21
22
import com .epam .reportportal .formatting .http .converters .DefaultHttpHeaderConverter ;
22
23
import com .epam .reportportal .formatting .http .converters .DefaultUriConverter ;
23
24
import com .epam .reportportal .formatting .http .entities .Cookie ;
24
25
import com .epam .reportportal .formatting .http .entities .Header ;
26
+ import com .epam .reportportal .formatting .http .entities .Param ;
25
27
import com .epam .reportportal .listeners .LogLevel ;
26
28
import com .epam .reportportal .restassured .support .HttpEntityFactory ;
27
29
import com .epam .reportportal .service .ReportPortal ;
@@ -67,6 +69,8 @@ public class ReportPortalRestAssuredLoggingFilter extends AbstractHttpFormatter<
67
69
68
70
private final int order ;
69
71
72
+ protected final Function <Param , String > paramConverter ;
73
+
70
74
/**
71
75
* Create an ordered REST Assured filter with the log level and different converters.
72
76
*
@@ -82,14 +86,48 @@ public class ReportPortalRestAssuredLoggingFilter extends AbstractHttpFormatter<
82
86
* formats Cookies with <code>toString</code> method
83
87
* @param uriConverterFunction the same as 'headerConvertFunction' param but for URI, default function returns
84
88
* URI "as is"
89
+ * @param paramConverter the same as 'headerConvertFunction' param but for Web Form Params, default function returns
90
+ * <code>param.getName() + ": " + param.getValue()</code>
85
91
*/
86
92
public ReportPortalRestAssuredLoggingFilter (int filterOrder , @ Nonnull LogLevel defaultLogLevel ,
87
93
@ Nullable Function <Header , String > headerConvertFunction , @ Nullable Function <Header , String > partHeaderConvertFunction ,
88
- @ Nullable Function <Cookie , String > cookieConvertFunction , @ Nullable Function <String , String > uriConverterFunction ) {
94
+ @ Nullable Function <Cookie , String > cookieConvertFunction , @ Nullable Function <String , String > uriConverterFunction ,
95
+ @ Nullable Function <Param , String > paramConverter ) {
89
96
super (defaultLogLevel , headerConvertFunction , partHeaderConvertFunction , cookieConvertFunction , uriConverterFunction );
97
+ this .paramConverter = paramConverter != null ? paramConverter : DefaultFormParamConverter .INSTANCE ;
90
98
order = filterOrder ;
91
99
}
92
100
101
+ /**
102
+ * Create an ordered REST Assured filter with the log level and different converters.z
103
+ *
104
+ * @param filterOrder if you have different filters which modify requests on fly this parameter allows
105
+ * you to control the order when Report Portal logger will be called, and therefore
106
+ * log or don't log some data.
107
+ * @param defaultLogLevel log level on which REST Assured requests/responses will appear on Report Portal
108
+ * @param headerConvertFunction if you want to preprocess your HTTP Headers before they appear on Report Portal
109
+ * provide this custom function for the class, default function formats it like
110
+ * that: <code>header.getName() + ": " + header.getValue()</code>
111
+ * @param partHeaderConvertFunction the same as fot HTTP Headers, but for parts in Multipart request
112
+ * @param cookieConvertFunction the same as 'headerConvertFunction' param but for Cookies, default function
113
+ * formats Cookies with <code>toString</code> method
114
+ * @param uriConverterFunction the same as 'headerConvertFunction' param but for URI, default function returns
115
+ * URI "as is"
116
+ */
117
+ public ReportPortalRestAssuredLoggingFilter (int filterOrder , @ Nonnull LogLevel defaultLogLevel ,
118
+ @ Nullable Function <Header , String > headerConvertFunction , @ Nullable Function <Header , String > partHeaderConvertFunction ,
119
+ @ Nullable Function <Cookie , String > cookieConvertFunction , @ Nullable Function <String , String > uriConverterFunction ) {
120
+ this (
121
+ filterOrder ,
122
+ defaultLogLevel ,
123
+ headerConvertFunction ,
124
+ partHeaderConvertFunction ,
125
+ cookieConvertFunction ,
126
+ uriConverterFunction ,
127
+ DefaultFormParamConverter .INSTANCE
128
+ );
129
+ }
130
+
93
131
/**
94
132
* Create an ordered REST Assured filter with the log level and different converters.
95
133
*
@@ -178,6 +216,7 @@ public Response filter(FilterableRequestSpecification requestSpec, FilterableRes
178
216
uriConverter ,
179
217
myHeaderConverter ,
180
218
cookieConverter ,
219
+ paramConverter ,
181
220
getContentPrettifiers (),
182
221
partHeaderConverter ,
183
222
getBodyTypeMap ()
0 commit comments