Class PrintUtils
java.lang.Object
ru.vyarus.dropwizard.guice.test.util.PrintUtils
Utilities for test console reports formatting.
- Since:
- 12.02.2025
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatMetric(double time) Time assumed to come from metrics snapshot.static StringformatMetric(double time, TimeUnit unit) Formats time, obtained from metrics snapshot to target unit.static StringformatMs(long nanos, int precision) Format nano value in milliseconds with required precision (decimal numbers).static StringgetPerformanceReportSeparator(org.junit.jupiter.api.extension.ExtensionContext context) Universal header string for performance reports in test to clearly identify current context.static StringThis is the same string as shown in the default Object.toString (@hash part).static Stringms(long nanos) static StringRender duration in milliseconds (2 decimal signs precision).static StringrenderTime(Duration overall, Duration increase) Render duration together with increase indication: overall time (increase since last report).static String[]toStringArguments(Object[] args, int maxLength) Converts arguments to string.static StringtoStringValue(Object value, int maxLength) Converts any value (object) to string.
-
Method Details
-
identity
This is the same string as shown in the default Object.toString (@hash part).- Parameters:
object- object to get identity for- Returns:
- object identity string
-
toStringArguments
Converts arguments to string.- Parameters:
args- argumentsmaxLength- maximum string length to keep (longer strings get truncated)- Returns:
- string representation of incoming arguments
-
toStringValue
Converts any value (object) to string. Rules: - Primitive values, number and booleans stored as is - String values could be truncated - Objects represented as ObjectType@instanceHash - null is "null"- Parameters:
value- value to convert to stringmaxLength- maximum string length to keep- Returns:
- string representation for the object
-
renderTime
Render duration together with increase indication: overall time (increase since last report).- Parameters:
overall- overall duration (including increase) (could be null)increase- increase since last report (could be null)- Returns:
- string representation for suration
-
ms
Render duration in milliseconds (2 decimal signs precision).- Parameters:
duration- duration- Returns:
- string representation
-
ms
- Parameters:
nanos- time in nanoseconds- Returns:
- string representation
-
formatMs
Format nano value in milliseconds with required precision (decimal numbers).- Parameters:
nanos- value in nanosecondsprecision- required precision (decimal numbers)- Returns:
- formatted value
-
formatMetric
Time assumed to come from metrics snapshot.- Parameters:
time- time to format- Returns:
- string representation (in ms)
-
formatMetric
Formats time, obtained from metrics snapshot to target unit.- Parameters:
time- time to formatunit- target unit- Returns:
- string representation (in selected unit)
-
getPerformanceReportSeparator
public static String getPerformanceReportSeparator(org.junit.jupiter.api.extension.ExtensionContext context) Universal header string for performance reports in test to clearly identify current context.- Parameters:
context- junit context- Returns:
- performance report header
-