RuntimeProvider { public static StackTraceElement getCallerStackTraceElement(final int depth) { return normalizeClassName(dialect.getCallerStackTraceElement(depth + 1)); } private  RuntimeProvider(); static boolean isAndroid(); static ClassLoader getClassLoader(); static String getDefaultWriter(); static long getProcessId(); static Timestamp getStartTime(); static String getCallerClassName(final int depth); static String getCallerClassName(final String loggerClassName); static StackTraceElement getCallerStackTraceElement(final int depth); static StackTraceElement getCallerStackTraceElement(final String loggerClassName); static Timestamp createTimestamp(); static TimestampFormatter createTimestampFormatter(final String pattern, final Locale locale);  }
@Test public void callerStackTraceElementByIndex() { assertThat(RuntimeProvider.getCallerStackTraceElement(1)).isEqualTo(new Throwable().getStackTrace()[0]); }
@Test public void callerStackTraceElementBySuccessor() { String className = RuntimeProvider.class.getName(); assertThat(RuntimeProvider.getCallerStackTraceElement(className)).isEqualTo(new Throwable().getStackTrace()[0]); }
@Test public void anonymousCallerStackTraceElement() { new Object() { { StackTraceElement currentElement = new Throwable().getStackTrace()[0]; StackTraceElement fetchedElement = RuntimeProvider.getCallerStackTraceElement(1); assertThat(fetchedElement.getClassName()).isEqualTo(RuntimeProviderTest.class.getName()); assertThat(fetchedElement.getMethodName()).isEqualTo(currentElement.getMethodName()); assertThat(fetchedElement.getFileName()).isEqualTo(currentElement.getFileName()); assertThat(fetchedElement.getLineNumber()).isEqualTo(currentElement.getLineNumber() + 1); } }; }