### Question:
ThriftUtils { public static Class<?> getThriftRootClass(Class<?> generatedChildClass) { Class<?> clazz = generatedChildClass.getDeclaringClass(); if (clazz == null){ clazz = generatedChildClass; } try { getClassByName(clazz, "Iface"); } catch (Exception ex) { throw new ThriftRuntimeException( "Class was not generated by thrift compiler " + generatedChildClass.getName(), ex ); } return clazz; }  static Class<?> getClassByName(Class<?> root, String name); static Class<?> getThriftRootClass(Class<?> generatedChildClass); static boolean parseBoolean(String val); static String getThriftServiceName(Class<?> generatedChildClass, Optional<String> subServiceName); static String getThriftServiceName(Class<?> generatedChildClass); static String getThriftFullServiceName(Class<?> generatedChildClass, Optional<String> subServiceName); static String getThriftFullServiceName(Class<?> generatedChildClass); static boolean isApplicationLevelException(Throwable ex); static String getHostName(); static CompletableFuture<T> firstSuccess(Stream<CompletableFuture<T>> futures); static boolean empty(String str); static long parseLong(byte[] bytes); static long parseLong(byte[] bytes, int offset); static final String QIWI_APP_HOST_NAME; }### Answer:
@Test(groups = "unit") public void getThriftRootClass() throws Exception { assertEquals(ThriftUtils.getThriftRootClass(SecondServer.Iface.class), SecondServer.class); assertEquals(ThriftUtils.getThriftRootClass(SecondServer.class), SecondServer.class); }
@Test(groups = "unit", expectedExceptions = ThriftRuntimeException.class) public void getThriftRootClassErr() throws Exception { ThriftUtils.getThriftRootClass(MapResult.class); }