### Question:
GroupLogValidator implements AnnotationUsageValidator<Set<T>> { @Override public void validate(Method method, Set<T> target) throws AnnotationUsageException { groupAnnotationsByLogger(method, target).entrySet().stream() .filter(entry -> entry.getValue().size() > 1) .findFirst() .ifPresent(entry -> { throw new AnnotationUsageException(method, format("%s annotations with 'logger = %s' on the method", entry.getValue().size(), entry.getKey()), "Use one annotation per 'logger'"); }); } GroupLogValidator(Map<String, Set<String>> loggerNames); @Override void validate(Method method, Set<T> target);  }### Answer:
@Test(expected = AnnotationUsageException.class) public void validateNameAndPrimary() { Map<String, Set<String>> loggerNames = singletonMap("logger", new HashSet<>(asList("logger", ""))); TestGroupLogValidator groupLogValidator = new TestGroupLogValidator(loggerNames); Log log = synthesizeAnnotation(singletonMap("logger", ""), Log.class, null); Log log1 = synthesizeAnnotation(singletonMap("logger", "logger"), Log.class, null); Set<Log> annotations = new HashSet<>(asList(log, log1)); groupLogValidator.validate(method, annotations); }
@Test(expected = AnnotationUsageException.class) public void validateTwoAliases() { Map<String, Set<String>> loggerNames = singletonMap("logger", new HashSet<>(asList("logger", "alias"))); TestGroupLogValidator groupLogValidator = new TestGroupLogValidator(loggerNames); Log log = synthesizeAnnotation(singletonMap("logger", "logger"), Log.class, null); Log log1 = synthesizeAnnotation(singletonMap("logger", "alias"), Log.class, null); Set<Log> annotations = new HashSet<>(asList(log, log1)); groupLogValidator.validate(method, annotations); }