### Question:
GroupLogValidator implements AnnotationUsageValidator<Set<T>> { Map<String, List<T>> groupAnnotationsByLogger(Method method, Set<T> annotations) { return annotations.stream() .collect(groupingBy(annotation -> { String loggerName = AnnotationAttribute.LOGGER.extract(annotation); return loggerNames.entrySet().stream() .filter(entry -> entry.getValue().contains(loggerName)) .findFirst() .map(Map.Entry::getKey) .orElseThrow(() -> { if (loggerName.isEmpty()) { return new AnnotationUsageException(method, "Primary logger not found among candidates", "Annotate the needed logger by '@Primary' or specify the logger name explicitly", annotation); } return new AnnotationUsageException(method, format("Unknown logger '%s'", loggerName), "Use correct bean name or alias to specify 'logger'", annotation); }); })); } GroupLogValidator(Map<String, Set<String>> loggerNames); @Override void validate(Method method, Set<T> target);  }### Answer:
@Test(expected = AnnotationUsageException.class) public void groupAnnotationsByLoggerUnknownLogger() { Map<String, Set<String>> loggerNames = singletonMap("logger", new HashSet<>(asList("logger", ""))); TestGroupLogValidator groupLogValidator = new TestGroupLogValidator(loggerNames); Log log = synthesizeAnnotation(singletonMap("logger", "unknown"), Log.class, null); Log log1 = synthesizeAnnotation(singletonMap("logger", "unknown1"), Log.class, null); Set<Log> annotations = new HashSet<>(asList(log, log1)); groupLogValidator.groupAnnotationsByLogger(method, annotations); }
@Test(expected = AnnotationUsageException.class) public void groupAnnotationsByLoggerEmptyLogger() { Map<String, Set<String>> loggerNames = singletonMap("logger", singleton("logger")); TestGroupLogValidator groupLogValidator = new TestGroupLogValidator(loggerNames); Log log = synthesizeAnnotation(singletonMap("logger", ""), Log.class, null); Log log1 = synthesizeAnnotation(singletonMap("logger", ""), Log.class, null); Set<Log> annotations = new HashSet<>(asList(log, log1)); groupLogValidator.groupAnnotationsByLogger(method, annotations); }