}
}
private boolean hasBeenCaughtByMockitoProxy() {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
StackTraceFilter filter = new StackTraceFilter();
/*
* We loop through all stack trace elements and see if it's "bad". Bad
* means that the stack trance is cluttered with Mockito proxy
* invocations which is why we know that the invocation has been caught
* by the proxy if isBad returns true.
*/
for (StackTraceElement stackTraceElement : stackTrace) {
if (filter.isBad(stackTraceElement)) {
return true;
}
}
return false;
}