Class PrintUtils
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.test.util.PrintUtils
-
public final class PrintUtils extends java.lang.ObjectUtilities for test console reports formatting.- Since:
- 12.02.2025
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringformatMetric(double time)Time assumed to come from metrics snapshot.static java.lang.StringformatMetric(double time, java.util.concurrent.TimeUnit unit)Formats time, obtained from metrics snapshot to target unit.static java.lang.StringformatMs(long nanos, int precision)Format nano value in milliseconds with required precision (decimal numbers).static java.lang.StringgetPerformanceReportSeparator(org.junit.jupiter.api.extension.ExtensionContext context)Universal header string for performance reports in test to clearly identify current context.static java.lang.Stringidentity(java.lang.Object object)This is the same string as shown in the default Object.toString (@hash part).static java.lang.Stringms(long nanos)static java.lang.Stringms(java.time.Duration duration)Render duration in milliseconds (2 decimal signs precision).static java.lang.StringrenderTime(java.time.Duration overall, java.time.Duration increase)Render duration together with increase indication: overall time (increase since last report).static java.lang.String[]toStringArguments(java.lang.Object[] args, int maxLength)Converts arguments to string.static java.lang.StringtoStringValue(java.lang.Object value, int maxLength)Converts any value (object) to string.
-
-
-
Method Detail
-
identity
public static java.lang.String identity(java.lang.Object object)
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
public static java.lang.String[] toStringArguments(java.lang.Object[] args, int maxLength)Converts arguments to string.- Parameters:
args- argumentsmaxLength- maximum string length to keep (longer strings get truncated)- Returns:
- string representation of incoming arguments
-
toStringValue
public static java.lang.String toStringValue(java.lang.Object value, int maxLength)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
public static java.lang.String renderTime(java.time.Duration overall, java.time.Duration increase)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
public static java.lang.String ms(java.time.Duration duration)
Render duration in milliseconds (2 decimal signs precision).- Parameters:
duration- duration- Returns:
- string representation
-
ms
public static java.lang.String ms(long nanos)
- Parameters:
nanos- time in nanoseconds- Returns:
- string representation
-
formatMs
public static java.lang.String formatMs(long nanos, int precision)Format nano value in milliseconds with required precision (decimal numbers).- Parameters:
nanos- value in nanosecondsprecision- required precision (decimal numbers)- Returns:
- formatted value
-
formatMetric
public static java.lang.String formatMetric(double time)
Time assumed to come from metrics snapshot.- Parameters:
time- time to format- Returns:
- string representation (in ms)
-
formatMetric
public static java.lang.String formatMetric(double time, java.util.concurrent.TimeUnit unit)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 java.lang.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
-
-