### Question:
HeadersLengthValidatorImpl extends AbstractHeaderValidatorImpl implements ConsentHeaderValidator, PaymentHeaderValidator { @Override public MessageError validate(Map<String, String> inputHeaders, MessageError messageError) { for (Map.Entry<String, String> header : inputHeaders.entrySet()) { if (isHeaderExceedsLength(header)) { errorBuildingService.enrichMessageError(messageError, TppMessageInformation.of(FORMAT_ERROR_OVERSIZE_HEADER, header.getKey(), headerMaxLengths.get(header.getKey()))); } } return messageError; } @Autowired  HeadersLengthValidatorImpl(ErrorBuildingService errorBuildingService); @Override MessageError validate(Map<String, String> inputHeaders, MessageError messageError);  }### Answer:
@Test void validate_allLengthsAreCorrect() { HeadersLengthValidatorImpl.headerMaxLengths.forEach((header, length) -> headers.put(header, StringUtils.repeat(ONE_CHAR, length))); validator.validate(headers, messageError); assertTrue(messageError.getTppMessages().isEmpty()); }
@Test void validate_allLengthsAreExceeded() { HeadersLengthValidatorImpl.headerMaxLengths.forEach((header, length) -> headers.put(header, StringUtils.repeat(ONE_CHAR, length + 1))); validator.validate(headers, messageError); assertFalse(messageError.getTppMessages().isEmpty()); assertEquals(headers.size(), messageError.getTppMessages().size()); messageError.getTppMessages().forEach(message -> assertEquals(MessageCategory.ERROR, message.getCategory())); messageError.getTppMessages().forEach(message -> assertEquals(MessageErrorCode.FORMAT_ERROR_OVERSIZE_HEADER, message.getMessageErrorCode())); }