### Question:
TransactionReportAcceptHeaderValidator { public ValidationResult validate(String acceptHeader) { if (StringUtils.isNotBlank(acceptHeader)) { List<String> supportedTransactionApplicationTypes = aspspProfileServiceWrapper.getSupportedTransactionApplicationTypes(); if (!isAtLeastOneAcceptHeaderSupported(supportedTransactionApplicationTypes, acceptHeader)) { return ValidationResult.invalid(ErrorType.AIS_406, REQUESTED_FORMATS_INVALID); } } return ValidationResult.valid(); }  ValidationResult validate(String acceptHeader);  }### Answer:
@Test void validate_success() { when(aspspProfileServiceWrapper.getSupportedTransactionApplicationTypes()).thenReturn(aspspSettings.getAis() .getTransactionParameters() .getSupportedTransactionApplicationTypes()); ValidationResult actual = validator.validate(MediaType.APPLICATION_JSON_VALUE); assertTrue(actual.isValid()); }
@Test void validate_error() { when(aspspProfileServiceWrapper.getSupportedTransactionApplicationTypes()).thenReturn(aspspSettings.getAis() .getTransactionParameters() .getSupportedTransactionApplicationTypes()); ValidationResult actual = validator.validate(MediaType.APPLICATION_PDF_VALUE); assertTrue(actual.isNotValid()); assertEquals(REQUESTED_FORMATS_INVALID_ERROR, actual.getMessageError()); }
@Test void validate_isAtLeastOneAcceptHeaderSupported() { when(aspspProfileServiceWrapper.getSupportedTransactionApplicationTypes()).thenReturn(aspspSettings.getAis() .getTransactionParameters() .getSupportedTransactionApplicationTypes()); ValidationResult actual = validator.validate("application/xml, application/json"); assertTrue(actual.isValid()); }
@Test void validate_isAtLeastOneAcceptHeaderSupported_extraBlanks() { when(aspspProfileServiceWrapper.getSupportedTransactionApplicationTypes()).thenReturn(aspspSettings.getAis() .getTransactionParameters() .getSupportedTransactionApplicationTypes()); ValidationResult actual = validator.validate(" application/xml,application/json "); assertTrue(actual.isValid()); }
@Test void validate_isAtLeastOneAcceptHeaderSupported_ignoreCaseSensitive() { when(aspspProfileServiceWrapper.getSupportedTransactionApplicationTypes()).thenReturn(aspspSettings.getAis() .getTransactionParameters() .getSupportedTransactionApplicationTypes()); ValidationResult actual = validator.validate("APPLICATION/XML,APPLICATION/JSON"); assertTrue(actual.isValid()); }
@Test void validate_acceptHeaderIsNotPresented_success() { ValidationResult actual = validator.validate(null); assertTrue(actual.isValid()); actual = validator.validate(""); assertTrue(actual.isValid()); }