@Test public void testInvalidWhenPathExists() { Validation v = new IfPathExistsValidation("hello", Validations.single().allowedValues("hello", 3)); ValidationResult vr = v.validate(ConfigFactory.parseString("hello = 2")); assertEquals(vr.getValidity(), Validity.INVALID); }
@Override public ValidationResult validate(Config config) { if (config.hasPath(ifPath)) { return thenValidation.validate(config); } else { return new ValidationResult(this, Validity.VALID, "Conditional configuration '" + ifPath + "' does not exist, so it was not required that the validation (" + thenValidation + ") be checked"); } }
IfPathExistsValidation implements Validation { @Override public ValidationResult validate(Config config) { if (config.hasPath(ifPath)) { return thenValidation.validate(config); } else { return new ValidationResult(this, Validity.VALID, "Conditional configuration '" + ifPath + "' does not exist, so it was not required that the validation (" + thenValidation + ") be checked"); } } }
IfPathExistsValidation implements Validation { @Override public ValidationResult validate(Config config) { if (config.hasPath(ifPath)) { return thenValidation.validate(config); } else { return new ValidationResult(this, Validity.VALID, "Conditional configuration '" + ifPath + "' does not exist, so it was not required that the validation (" + thenValidation + ") be checked"); } } IfPathExistsValidation(String ifPath, Validation thenValidation); }
IfPathExistsValidation implements Validation { @Override public ValidationResult validate(Config config) { if (config.hasPath(ifPath)) { return thenValidation.validate(config); } else { return new ValidationResult(this, Validity.VALID, "Conditional configuration '" + ifPath + "' does not exist, so it was not required that the validation (" + thenValidation + ") be checked"); } } IfPathExistsValidation(String ifPath, Validation thenValidation); @Override ValidationResult validate(Config config); @Override String toString(); @Override Set<String> getKnownPaths(); }
IfPathExistsValidation implements Validation { @Override public ValidationResult validate(Config config) { if (config.hasPath(ifPath)) { return thenValidation.validate(config); } else { return new ValidationResult(this, Validity.VALID, "Conditional configuration '" + ifPath + "' does not exist, so it was not required that the validation (" + thenValidation + ") be checked"); } } IfPathExistsValidation(String ifPath, Validation thenValidation); @Override ValidationResult validate(Config config); @Override String toString(); @Override Set<String> getKnownPaths();  }