### Question:
Util { @Nonnull public static Class findRootEnclosingClass(@Nonnull final Class clazz) { Class curr = clazz; while (true) { Class declaringClass = curr.getEnclosingClass(); if (declaringClass != null) { curr = declaringClass; } else { return curr; } } }  @Nonnull static String stripCrLf(@Nonnull final String text); @Nonnull static Class findRootEnclosingClass(@Nonnull final Class clazz);  }### Answer:
@Test public void findRootEnclosingClass() throws Exception { assertThat(Util.findRootEnclosingClass(UtilTest.class)).isSameAs(UtilTest.class); }
@Test public void findRootEnclosingClassForAnonymousClass() throws Exception { Class<? extends Object> internalClass = new Object() { }.getClass(); assertThat(Util.findRootEnclosingClass(internalClass)).isSameAs(UtilTest.class); }
@Test public void findRootEnclosingClassForInternalClass() throws Exception { assertThat(Util.findRootEnclosingClass(InternalClass.class)).isSameAs(UtilTest.class); }