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 TypeMethodDescriptionbooleancheckThresholds(long threshold) Check whether the number of focus events exceeded the given threshold for any concrete class.voidCalled on every focus event, potentially concurrently.
-
Constructor Details
-
ThresholdFocusListener
public ThresholdFocusListener()
-
-
Method Details
-
onFocus
Description copied from interface:FocusListenerCalled on every focus event, potentially concurrently.- Specified by:
onFocusin 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:
falseiff any concrete class was type checked too often
-