### Question:
ConsentValidationService { public Set<TppMessageInformation> buildWarningMessages(CreateConsentReq request) { Set<TppMessageInformation> warnings = new HashSet<>(); warnings.addAll(tppUriHeaderValidator.buildWarningMessages(request.getTppRedirectUri())); warnings.addAll(tppNotificationDataValidator.buildWarningMessages(request.getTppNotificationData())); return warnings; }  ValidationResult validateConsentOnCreate(CreateConsentReq request, PsuIdData psuIdData); ValidationResult validateConsentOnGettingStatusById(AisConsent consent); ValidationResult validateConsentOnDelete(AisConsent consent); ValidationResult validateConsentOnGettingById(AisConsent consent); ValidationResult validateConsentAuthorisationOnCreate(CreateConsentAuthorisationObject createConsentAuthorisationObject); ValidationResult validateConsentPsuDataOnUpdate(AisConsent consent, UpdateConsentPsuDataReq request); ValidationResult validateConsentAuthorisationOnGettingById(AisConsent consent); ValidationResult validateConsentAuthorisationScaStatus(AisConsent consent, String authorisationId); Set<TppMessageInformation> buildWarningMessages(CreateConsentReq request);  }### Answer:
@Test void buildWarningMessages_emptySet() { Set<TppMessageInformation> emptySet = new HashSet<>(); CreateConsentReq createConsentReq = new CreateConsentReq(); when(tppUriHeaderValidator.buildWarningMessages(any())) .thenReturn(emptySet); when(tppNotificationDataValidator.buildWarningMessages(any())) .thenReturn(emptySet); Set<TppMessageInformation> actual = service.buildWarningMessages(createConsentReq); assertEquals(actual, emptySet); verify(tppUriHeaderValidator, times(1)).buildWarningMessages(any()); verify(tppNotificationDataValidator, times(1)).buildWarningMessages(any()); }
@Test void buildWarningMessages_warningsFromUriHeaderValidator() { Set<TppMessageInformation> emptySet = new HashSet<>(); Set<TppMessageInformation> uriHeaderValidatorSet = new HashSet<>(); uriHeaderValidatorSet.add(TppMessageInformation.buildWarning(INVALID_DOMAIN_MESSAGE)); CreateConsentReq createConsentReq = new CreateConsentReq(); when(tppUriHeaderValidator.buildWarningMessages(any())) .thenReturn(uriHeaderValidatorSet); when(tppNotificationDataValidator.buildWarningMessages(any())) .thenReturn(emptySet); Set<TppMessageInformation> actual = service.buildWarningMessages(createConsentReq); assertEquals(actual, uriHeaderValidatorSet); verify(tppUriHeaderValidator, times(1)).buildWarningMessages(any()); verify(tppNotificationDataValidator, times(1)).buildWarningMessages(any()); }
@Test void buildWarningMessages_warningsNotificationDataValidator() { Set<TppMessageInformation> emptySet = new HashSet<>(); Set<TppMessageInformation> notificationDataValidatorSet = new HashSet<>(); notificationDataValidatorSet.add(TppMessageInformation.buildWarning(INVALID_DOMAIN_MESSAGE)); CreateConsentReq createConsentReq = new CreateConsentReq(); when(tppUriHeaderValidator.buildWarningMessages(any())) .thenReturn(emptySet); when(tppNotificationDataValidator.buildWarningMessages(any())) .thenReturn(notificationDataValidatorSet); Set<TppMessageInformation> actual = service.buildWarningMessages(createConsentReq); assertEquals(actual, notificationDataValidatorSet); verify(tppUriHeaderValidator, times(1)).buildWarningMessages(any()); verify(tppNotificationDataValidator, times(1)).buildWarningMessages(any()); }