JsonUtils { public static Set<String> getTransientFields(Class<?> aClass) { Set<String> transientFields = new HashSet<>(); Class<?> superClass = aClass; while (superClass != null && superClass != Object.class) { for (Field field : superClass.getDeclaredFields()) { if (Modifier.isTransient(field.getModifiers()) || field.isAnnotationPresent(JsonTransient.class)) { transientFields.add(field.getName()); } } superClass = superClass.getSuperclass(); } return transientFields; } private  JsonUtils(); static String getJsonString(String string); static boolean isKnownType(Class<?> clazz); static Types getType(Object o); static Types getType(Class<?> clazz); static Set<String> getTransientFields(Class<?> aClass); @SuppressWarnings({"unchecked"}) static T createProxy(Class<T> anInterface);  }
@Test public void getsListOfTransientFieldsFromClass() { Set<String> transientFields = JsonUtils.getTransientFields(BeanWithTransientField.class); transientFields = filterFieldsInsertedByJacocoFrameworkDuringInstrumentation(transientFields); assertEquals(newHashSet("transientField", "jsonTransientField"), transientFields); }
@Test public void getsListOfTransientFieldsFromSuperClass() { Set<String> transientFields = JsonUtils.getTransientFields(ExtensionOfBeanWithTransientField.class); transientFields = filterFieldsInsertedByJacocoFrameworkDuringInstrumentation(transientFields); assertEquals(newHashSet("transientField", "jsonTransientField"), transientFields); }