3030import com .epam .reportportal .service .step .StepReporter ;
3131import com .epam .reportportal .utils .files .ByteSource ;
3232import com .epam .reportportal .utils .http .ContentType ;
33-
34- import javax .annotation .Nonnull ;
35- import javax .annotation .Nullable ;
36- import java .util .*;
33+ import jakarta .annotation .Nonnull ;
34+ import jakarta .annotation .Nullable ;
35+
36+ import java .time .Instant ;
37+ import java .util .Collections ;
38+ import java .util .HashMap ;
39+ import java .util .Map ;
40+ import java .util .Optional ;
3741import java .util .function .Function ;
3842
3943import static com .epam .reportportal .formatting .http .Constants .BODY_TYPE_MAP ;
@@ -55,18 +59,7 @@ public abstract class AbstractHttpFormatter<SELF extends AbstractHttpFormatter<S
5559 protected final Function <String , String > uriConverter ;
5660
5761 private Map <String , Function <String , String >> contentPrettifiers = DEFAULT_PRETTIFIERS ;
58-
59- /**
60- * @deprecated Use {@link #getContentPrettifiers()} instead
61- */
62- @ Deprecated
63- protected Map <String , Function <String , String >> contentPrettiers = contentPrettifiers ;
64-
65- /**
66- * @deprecated Use {@link #getBodyTypeMap()} instead
67- */
68- @ Deprecated
69- protected Map <String , BodyType > bodyTypeMap = BODY_TYPE_MAP ;
62+ private Map <String , BodyType > bodyTypeMap = BODY_TYPE_MAP ;
7063
7164 /**
7265 * Create a formatter with the specific log level and converters.
@@ -93,26 +86,26 @@ protected AbstractHttpFormatter(@Nonnull LogLevel defaultLogLevel, @Nullable Fun
9386
9487 protected void attachAsBinary (@ Nullable String message , @ Nullable byte [] attachment , @ Nonnull String contentType ) {
9588 if (attachment == null ) {
96- ReportPortal .emitLog (message , logLevel , Calendar . getInstance (). getTime ());
89+ ReportPortal .emitLog (message , logLevel , Instant . now ());
9790 } else {
9891 ReportPortal .emitLog (
9992 new ReportPortalMessage (ByteSource .wrap (attachment ), contentType , message ),
10093 logLevel ,
101- Calendar . getInstance (). getTime ()
94+ Instant . now ()
10295 );
10396 }
10497 }
10598
10699 protected void logMultiPartRequest (@ Nonnull HttpRequestFormatter formatter ) {
107- Date currentDate = Calendar . getInstance (). getTime ();
100+ Instant currentDate = Instant . now ();
108101 String headers = formatter .formatHeaders () + formatter .formatCookies ();
109102 if (!headers .isEmpty ()) {
110103 ReportPortal .emitLog (headers , logLevel , currentDate );
111104 }
112105
113- Date myDate = currentDate ;
106+ Instant myDate = currentDate ;
114107 for (HttpPartFormatter part : formatter .getMultipartBody ()) {
115- myDate = new Date ( myDate .getTime () + 1 );
108+ myDate = myDate .plusMillis ( 1 );
116109 HttpPartFormatter .PartType partType = part .getType ();
117110 switch (partType ) {
118111 case TEXT :
@@ -128,11 +121,11 @@ protected void emitLog(HttpFormatter formatter) {
128121 BodyType type = formatter .getType ();
129122 switch (type ) {
130123 case NONE :
131- ReportPortal .emitLog (formatter .formatHead (), logLevel , Calendar . getInstance (). getTime ());
124+ ReportPortal .emitLog (formatter .formatHead (), logLevel , Instant . now ());
132125 break ;
133126 case TEXT :
134127 case FORM :
135- ReportPortal .emitLog (formatter .formatAsText (), logLevel , Calendar . getInstance (). getTime ());
128+ ReportPortal .emitLog (formatter .formatAsText (), logLevel , Instant . now ());
136129 break ;
137130 case BINARY :
138131 attachAsBinary (
@@ -149,7 +142,7 @@ protected void emitLog(HttpFormatter formatter) {
149142 sr .ifPresent (StepReporter ::finishPreviousStep );
150143 break ;
151144 default :
152- ReportPortal .emitLog ("Unknown entity type: " + type .name (), LogLevel .ERROR .name (), Calendar . getInstance (). getTime ());
145+ ReportPortal .emitLog ("Unknown entity type: " + type .name (), LogLevel .ERROR .name (), Instant . now ());
153146 }
154147 }
155148
@@ -165,7 +158,7 @@ protected void emitLog(HttpFormatter formatter) {
165158 @ SuppressWarnings ("unchecked" )
166159 @ Nonnull
167160 public SELF setBodyTypeMap (@ Nonnull Map <String , BodyType > typeMap ) {
168- this .bodyTypeMap = Collections . unmodifiableMap ( new HashMap <>( typeMap ) );
161+ this .bodyTypeMap = Map . copyOf ( typeMap );
169162 return (SELF ) this ;
170163 }
171164
@@ -195,26 +188,9 @@ public Map<String, BodyType> getBodyTypeMap() {
195188 @ Nonnull
196189 public SELF setContentPrettifiers (@ Nonnull Map <String , Function <String , String >> contentPrettifiers ) {
197190 this .contentPrettifiers = Collections .unmodifiableMap (new HashMap <>(contentPrettifiers ));
198- this .contentPrettiers = this .contentPrettifiers ;
199191 return (SELF ) this ;
200192 }
201193
202- /***
203- * Set the content prettifiers for the formatter.
204- * <p>
205- * Content prettifiers are used to format the content of the request/response before logging it. The prettifiers are applied to the
206- * content based on the content type.
207- *
208- * @param contentPrettifiers a map with the content type as a key and the prettifier function as a value
209- * @return the formatter instance
210- * @deprecated Use {@link #setContentPrettifiers(Map)} instead
211- */
212- @ Deprecated
213- @ Nonnull
214- public SELF setContentPrettiers (@ Nonnull Map <String , Function <String , String >> contentPrettifiers ) {
215- return setContentPrettifiers (contentPrettifiers );
216- }
217-
218194 /**
219195 * Get the content prettifiers for the formatter.
220196 * <p>
0 commit comments