### Question:
LogErrorsValidator extends GroupLogValidator<Log.error> { @Override public void validate(Method method, Set<Log.error> target) throws AnnotationUsageException { groupAnnotationsByLogger(method, target).entrySet().stream() .filter(entry -> entry.getValue().size() > 1) .forEach(entry -> { List<Log.error> logErrors = entry.getValue(); long filterCount = logErrors.stream() .map(error -> errorFilterFactory.buildErrorFilter(error.ofType(), error.exclude())) .collect(toSet()) .size(); if (logErrors.size() > filterCount) { throw new AnnotationUsageException(method, format("Duplicated error filters with 'logger = %s' on the method", entry.getKey()), "Optimize error filters or specify a different logger names"); } }); target.forEach(logError -> logErrorValidator.validate(method, logError)); } LogErrorsValidator(Map<String, Set<String>> loggerNames,
                              LogErrorValidator logErrorValidator); @Override void validate(Method method, Set<Log.error> target);  }### Answer:
@Test(expected = AnnotationUsageException.class) public void validate() { Map<String, Set<String>> loggerNames = singletonMap("logger", new HashSet<>(asList("logger", ""))); LogErrorValidator logErrorValidator = new LogErrorValidator(new AliasedPrinterResolver(emptyMap(), emptyMap())); LogErrorsValidator logErrorsValidator = new LogErrorsValidator(loggerNames, logErrorValidator); Map<String, Object> ofType = singletonMap("ofType", new Class<?>[]{StringIndexOutOfBoundsException.class, ArrayIndexOutOfBoundsException.class}); Log.error logError = synthesizeAnnotation(ofType, Log.error.class, null); Map<String, Object> ofType1 = singletonMap("ofType", new Class<?>[]{ArrayIndexOutOfBoundsException.class, StringIndexOutOfBoundsException.class}); Log.error logError1 = synthesizeAnnotation(ofType1, Log.error.class, null); Set<Log.error> target = new HashSet<>(asList(logError, logError1)); logErrorsValidator.validate(method, target); }
@Test public void isTransitive() { Map<String, Set<String>> loggerNames = singletonMap("logger", new HashSet<>(asList("logger", ""))); LogErrorValidator logErrorValidator = mock(LogErrorValidator.class); LogErrorsValidator logErrorsValidator = new LogErrorsValidator(loggerNames, logErrorValidator); Map<String, Object> ofType = singletonMap("ofType", new Class<?>[]{Throwable.class}); Log.error logError = synthesizeAnnotation(ofType, Log.error.class, null); Map<String, Object> ofType1 = singletonMap("ofType", new Class<?>[]{Exception.class}); Log.error logError1 = synthesizeAnnotation(ofType1, Log.error.class, null); Set<Log.error> target = new HashSet<>(asList(logError, logError1)); logErrorsValidator.validate(method, target); verify(logErrorValidator).validate(method, logError); verify(logErrorValidator).validate(method, logError1); }