@Test(dataProvider = "tokensProvider") public void testValidateString(List<String> tokens, String input, boolean expectedPass) { setupTokens(tokens); try { validator.validate(input); Assert.assertTrue(expectedPass); } catch(StringValidationException e) { Assert.assertFalse(expectedPass); } }
@Override public void validate(String input) { if(tokens == null) return; logger.info("Verifying input [{}] contains tokens: [{}]", input, String.join(",", tokens)); if(!tokens.stream().allMatch(token -> StringUtils.containsIgnoreCase(input, token))) throw new StringValidationException(String.format("Input [%1$s] is missing a required token.", input)); }
TokenStringValidator implements StringValidator { @Override public void validate(String input) { if(tokens == null) return; logger.info("Verifying input [{}] contains tokens: [{}]", input, String.join(",", tokens)); if(!tokens.stream().allMatch(token -> StringUtils.containsIgnoreCase(input, token))) throw new StringValidationException(String.format("Input [%1$s] is missing a required token.", input)); } }
TokenStringValidator implements StringValidator { @Override public void validate(String input) { if(tokens == null) return; logger.info("Verifying input [{}] contains tokens: [{}]", input, String.join(",", tokens)); if(!tokens.stream().allMatch(token -> StringUtils.containsIgnoreCase(input, token))) throw new StringValidationException(String.format("Input [%1$s] is missing a required token.", input)); } TokenStringValidator(Collection<String> tokens); }
TokenStringValidator implements StringValidator { @Override public void validate(String input) { if(tokens == null) return; logger.info("Verifying input [{}] contains tokens: [{}]", input, String.join(",", tokens)); if(!tokens.stream().allMatch(token -> StringUtils.containsIgnoreCase(input, token))) throw new StringValidationException(String.format("Input [%1$s] is missing a required token.", input)); } TokenStringValidator(Collection<String> tokens); @Override void validate(String input); }
TokenStringValidator implements StringValidator { @Override public void validate(String input) { if(tokens == null) return; logger.info("Verifying input [{}] contains tokens: [{}]", input, String.join(",", tokens)); if(!tokens.stream().allMatch(token -> StringUtils.containsIgnoreCase(input, token))) throw new StringValidationException(String.format("Input [%1$s] is missing a required token.", input)); } TokenStringValidator(Collection<String> tokens); @Override void validate(String input);  }