UrlCollectionValidator implements ConstraintValidator<UrlCollection, List<String>> { @Override public boolean isValid(List<String> urls, ConstraintValidatorContext context) { if (urls == null || urls.isEmpty()) { return true; } for (String url : urls) { if (!urlValidator.isValid(url)) { return false; } } return true; }  @Override void initialize(UrlCollection target); @Override boolean isValid(List<String> urls, ConstraintValidatorContext context);  }
@Test public void testEmptyUrlCollection() { assertTrue(validator.isValid(Collections.<String>emptyList(), null)); }
@Test public void testValidUrlCollection() { List<String> validUrlCollection = ImmutableList.of( "https: "https: "https: "https: "https: ); assertTrue(validator.isValid(validUrlCollection, null)); }
@Test public void testInvalidUrlCollection() { List<String> invalidUrlCollection = ImmutableList.of( "https: "www.googleapis.com/auth/taskqueue", "127.0.0.1"); assertFalse(validator.isValid(invalidUrlCollection, null)); }