Package io.micronaut.test.typepollution
Class ThresholdFocusListener
java.lang.Object
io.micronaut.test.typepollution.ThresholdFocusListener
- All Implemented Interfaces:
FocusListener
FocusListener
implementation that counts and tracks all focus events, including stack
traces. At the end of the test, checkThresholds(long)
can be used to verify that no
concrete class exceeded a given focus event threshold.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkThresholds
(long threshold) Check whether the number of focus events exceeded the given threshold for any concrete class.void
Called on every focus event, potentially concurrently.
-
Constructor Details
-
ThresholdFocusListener
public ThresholdFocusListener()
-
-
Method Details
-
onFocus
Description copied from interface:FocusListener
Called on every focus event, potentially concurrently.- Specified by:
onFocus
in interfaceFocusListener
- Parameters:
concreteType
- The concrete type that was checkedinterfaceType
- The interface type that the concrete type was type checked against
-
checkThresholds
public boolean checkThresholds(long threshold) Check whether the number of focus events exceeded the given threshold for any concrete class. If this is the case, this method also prints a human-readable report on all type checking stack traces for the concrete type toSystem.out
.- Parameters:
threshold
- The number of events that should not be exceeded- Returns:
false
iff any concrete class was type checked too often
-