BindLoggersAnnotatedWithResource implements TypeListener { @VisibleForTesting Set<Field> getLoggerFieldsAnnotatedWithResource(Class<?> declaredType) { Set<Field> fields = Sets.newHashSet(); Class<?> type = declaredType; while (type != null) { fields.addAll(Arrays.asList(type.getDeclaredFields())); type = type.getSuperclass(); } return filter(fields, new LoggerFieldsAnnotatedWithResource()); } @Inject  BindLoggersAnnotatedWithResource(LoggerFactory loggerFactory); void hear(TypeLiteral<I> injectableType,
                         TypeEncounter<I> encounter);  }
@Test public void testGetLoggerFieldsAnnotatedWithResourceNoLogger() { Set<Field> fields = blawr.getLoggerFieldsAnnotatedWithResource(this.getClass()); assertEquals(fields.size(), 0); }
@Test public void testGetLoggerFieldsAnnotatedWithResourceOneLogger() { Set<Field> fields = blawr.getLoggerFieldsAnnotatedWithResource(A.class); assertEquals(fields.size(), 1); }
@Test public void testGetLoggerFieldsAnnotatedWithResourceTwoLoggers() { Set<Field> fields = blawr.getLoggerFieldsAnnotatedWithResource(D.class); assertEquals(fields.size(), 2); }