### Question:
EcoNewsDtoRequestValidator implements ConstraintValidator<ValidEcoNewsDtoRequest, AddEcoNewsDtoRequest> { @Override public boolean isValid(AddEcoNewsDtoRequest value, ConstraintValidatorContext context) { if (value.getSource() != null && !value.getSource().isEmpty()) { isUrlValid(value.getSource()); } List<String> tags = value.getTags(); if (tags.isEmpty() || tags.size() > ValidationConstants.MAX_AMOUNT_OF_TAGS) { throw new WrongCountOfTagsException(ErrorMessage.WRONG_COUNT_OF_TAGS_EXCEPTION); } return true; }  @Override void initialize(ValidEcoNewsDtoRequest constraintAnnotation); @Override boolean isValid(AddEcoNewsDtoRequest value, ConstraintValidatorContext context);  }### Answer:
@Test void isValidTrueTest() { AddEcoNewsDtoRequest request = getAddEcoNewsDtoRequest(); request.setSource("https: assertTrue(validator.isValid(request, null)); }
@Test void isValidWrongCountOfTagsExceptionTest() { AddEcoNewsDtoRequest request = getAddEcoNewsDtoRequest(); request.setTags(Collections.emptyList()); request.setSource("https: assertThrows(WrongCountOfTagsException.class, () -> validator.isValid(request, null)); }
@Test void isValidInvalidURLExceptionTest() { AddEcoNewsDtoRequest request = getAddEcoNewsDtoRequest(); request.setSource("/eco-lavca.ua/https:/"); assertThrows(InvalidURLException.class, () -> validator.isValid(request, null)); }