### Question:
CallerData { public static StackTraceElement[] extract(Throwable t, String fqnOfInvokingClass, final int maxDepth, List<String> frameworkPackageList) { if (t == null) { return null; } StackTraceElement[] steArray = t.getStackTrace(); StackTraceElement[] callerDataArray; int found = LINE_NA; for (int i = 0; i < steArray.length; i++) { if (isInFrameworkSpace(steArray[i].getClassName(), fqnOfInvokingClass, frameworkPackageList)) { found = i + 1; } else { if (found != LINE_NA) { break; } } } if (found == LINE_NA) { return EMPTY_CALLER_DATA_ARRAY; } int availableDepth = steArray.length - found; int desiredDepth = maxDepth < (availableDepth) ? maxDepth : availableDepth; callerDataArray = new StackTraceElement[desiredDepth]; for (int i = 0; i < desiredDepth; i++) { callerDataArray[i] = steArray[found + i]; } return callerDataArray; }  static StackTraceElement[] extract(Throwable t,
                                            String fqnOfInvokingClass, final int maxDepth,
                                            List<String> frameworkPackageList); static StackTraceElement naInstance(); static final String NA; static final int LINE_NA; static final String CALLER_DATA_NA; static final StackTraceElement[] EMPTY_CALLER_DATA_ARRAY; }### Answer:
@Test public void testBasic() { Throwable t = new Throwable(); StackTraceElement[] steArray = t.getStackTrace(); StackTraceElement[] cda = CallerData.extract(t, CallerDataTest.class.getName(), 50, null); assertNotNull(cda); assertTrue(cda.length > 0); assertEquals(steArray.length - 1, cda.length); }
@Test public void testDeferredProcessing() { StackTraceElement[] cda = CallerData.extract(new Throwable(), "com.inexistent.foo", 10, null); assertNotNull(cda); assertEquals(0, cda.length); }