### Question:
TransactionListBodyValidatorImpl extends AbstractBodyValidatorImpl implements TransactionListBodyValidator { @Override public MessageError validate(HttpServletRequest request, MessageError messageError) { String acceptHeader = request.getHeader(HttpHeaders.ACCEPT); if (StringUtils.isNotBlank(acceptHeader)) { String bookingStatus = request.getParameter(BOOKING_STATUS_PARAM); if (BookingStatus.INFORMATION.getValue().equals(bookingStatus) && !MediaType.APPLICATION_JSON_VALUE.equals(acceptHeader)) { errorBuildingService.enrichMessageError(messageError, TppMessageInformation.of(MessageErrorCode.REQUESTED_FORMATS_INVALID)); } } return messageError; } @Autowired  TransactionListBodyValidatorImpl(ErrorBuildingService errorBuildingService, Xs2aObjectMapper xs2aObjectMapper); @Override MessageError validate(HttpServletRequest request, MessageError messageError);  }### Answer:
@Test void validate_successForAnyBookingStatusWhenJson() { request.addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE); for (BookingStatus bookingStatus : BookingStatus.values()) { request.setParameter(TransactionListBodyValidatorImpl.BOOKING_STATUS_PARAM, bookingStatus.getValue()); transactionListBodyValidatorImpl.validate(request, messageError); assertTrue(messageError.getTppMessages().isEmpty()); } }
@Test void validate_requestedFormatInvalidError() { request.addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML_VALUE); request.setParameter(TransactionListBodyValidatorImpl.BOOKING_STATUS_PARAM, BookingStatus.INFORMATION.getValue()); transactionListBodyValidatorImpl.validate(request, messageError); assertFalse(messageError.getTppMessages().isEmpty()); assertEquals(MessageErrorCode.REQUESTED_FORMATS_INVALID, messageError.getTppMessage().getMessageErrorCode()); }
@Test void validate_successWithOtherBookingStatuses() { request.addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML_VALUE); for (BookingStatus bookingStatus : BookingStatus.values()) { if (BookingStatus.INFORMATION != bookingStatus) { request.setParameter(TransactionListBodyValidatorImpl.BOOKING_STATUS_PARAM, bookingStatus.getValue()); transactionListBodyValidatorImpl.validate(request, messageError); assertTrue(messageError.getTppMessages().isEmpty()); } } }
@Test void validate_noAcceptHeader() { transactionListBodyValidatorImpl.validate(request, messageError); assertTrue(messageError.getTppMessages().isEmpty()); }