Class TrackersHook.Builder<T>
- java.lang.Object
-
- ru.vyarus.dropwizard.guice.test.track.TrackersHook.Builder<T>
-
- Type Parameters:
T- bean type
- Enclosing class:
- TrackersHook
public class TrackersHook.Builder<T> extends java.lang.ObjectTracker configuration builder.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tracker<T>add()Apply tracker registration.TrackersHook.Builder<T>disableSlowMethodsLogging()Disable slow methods warning (by default, showing methods executed longer than 5 seconds).TrackersHook.Builder<T>keepRawObjects(boolean keepRawObjects)It is more likely that trackers would be used mostly for "call and verify" scenarios where keeping raw arguments makes perfect sense.TrackersHook.Builder<T>maxStringLength(int maxStringLength)Required to keep called method toString rendering readable in case of large strings used.TrackersHook.Builder<T>slowMethods(long maxTime, java.time.temporal.ChronoUnit unit)Print warnings about methods executing longer than the specified threshold.TrackersHook.Builder<T>trace(boolean trace)When enabled, prints called method just after it's execution (with called arguments and returned result).
-
-
-
Constructor Detail
-
Builder
public Builder(java.lang.Class<T> type)
Create builder.- Parameters:
type- service type
-
-
Method Detail
-
trace
public TrackersHook.Builder<T> trace(boolean trace)
When enabled, prints called method just after it's execution (with called arguments and returned result). Not enabled by default to avoid output mess in case when many methods would be called during test.- Parameters:
trace- true to print each method execution- Returns:
- builder instance for chained calls
-
slowMethods
public TrackersHook.Builder<T> slowMethods(long maxTime, java.time.temporal.ChronoUnit unit)
Print warnings about methods executing longer than the specified threshold.- Parameters:
maxTime- slow method thresholdunit- threshold unit- Returns:
- builder instance for chained calls
- See Also:
for disabling slow time logging
-
disableSlowMethodsLogging
public TrackersHook.Builder<T> disableSlowMethodsLogging()
Disable slow methods warning (by default, showing methods executed longer than 5 seconds).- Returns:
- builder instance for chained calls
- See Also:
for changing the default threshold
-
keepRawObjects
public TrackersHook.Builder<T> keepRawObjects(boolean keepRawObjects)
It is more likely that trackers would be used mostly for "call and verify" scenarios where keeping raw arguments makes perfect sense. That's why it's enabled by default.Important: method arguments and the result objects state could be mutable and change after or during method execution (and so be irrelevant for tracks analysis). For such cases, the tracker always holds string representations of method arguments and the result (rendered in method execution time).
It makes sense to disable option if too many method executions appear during the test (e.g., tracker used for performance metrics).
- Parameters:
keepRawObjects- true to keep raw arguments and result objects- Returns:
- builder instance for chained calls
-
maxStringLength
public TrackersHook.Builder<T> maxStringLength(int maxStringLength)
Required to keep called method toString rendering readable in case of large strings used. Note that for non-string objects, an object type with identity hash would be shown (not rely on toString because it would be too much unpredictable).- Parameters:
maxStringLength- maximum length of string in method parameter or returned result- Returns:
- builder instance for chained calls
-
-