@Test public void testValidatePropertyWithLocalFileURI(){ Map<String,String> propertyMap = new HashMap<String, String>(); propertyMap.put(PropertyValidator.WEBHDFS_URL,"file: ViewInstanceDefinition instanceDefinition = getInstanceDef(propertyMap); ValidationResult result = new PropertyValidator().validateProperty(PropertyValidator.WEBHDFS_URL,instanceDefinition,null); assertEquals(result.getClass(), PropertyValidator.InvalidPropertyValidationResult.class); assertEquals(result.isValid(),false); assertEquals(result.getDetail(),"Must be valid URL"); }
@Override public ValidationResult validateProperty(String property, ViewInstanceDefinition viewInstanceDefinition, ValidationContext validationContext) { ClusterType clusterType = viewInstanceDefinition.getClusterType(); if (clusterType == ClusterType.LOCAL_AMBARI || clusterType == ClusterType.REMOTE_AMBARI) { return ValidationResult.SUCCESS; } if (property.equals(WEBHDFS_URL)) { String webhdfsUrl = viewInstanceDefinition.getPropertyMap().get(WEBHDFS_URL); if (!ValidatorUtils.validateHdfsURL(webhdfsUrl)) { LOG.error("Invalid webhdfs.url = {}", webhdfsUrl); return new InvalidPropertyValidationResult(false, "Must be valid URL"); } } return ValidationResult.SUCCESS; }
PropertyValidator implements Validator { @Override public ValidationResult validateProperty(String property, ViewInstanceDefinition viewInstanceDefinition, ValidationContext validationContext) { ClusterType clusterType = viewInstanceDefinition.getClusterType(); if (clusterType == ClusterType.LOCAL_AMBARI || clusterType == ClusterType.REMOTE_AMBARI) { return ValidationResult.SUCCESS; } if (property.equals(WEBHDFS_URL)) { String webhdfsUrl = viewInstanceDefinition.getPropertyMap().get(WEBHDFS_URL); if (!ValidatorUtils.validateHdfsURL(webhdfsUrl)) { LOG.error("Invalid webhdfs.url = {}", webhdfsUrl); return new InvalidPropertyValidationResult(false, "Must be valid URL"); } } return ValidationResult.SUCCESS; } }
PropertyValidator implements Validator { @Override public ValidationResult validateProperty(String property, ViewInstanceDefinition viewInstanceDefinition, ValidationContext validationContext) { ClusterType clusterType = viewInstanceDefinition.getClusterType(); if (clusterType == ClusterType.LOCAL_AMBARI || clusterType == ClusterType.REMOTE_AMBARI) { return ValidationResult.SUCCESS; } if (property.equals(WEBHDFS_URL)) { String webhdfsUrl = viewInstanceDefinition.getPropertyMap().get(WEBHDFS_URL); if (!ValidatorUtils.validateHdfsURL(webhdfsUrl)) { LOG.error("Invalid webhdfs.url = {}", webhdfsUrl); return new InvalidPropertyValidationResult(false, "Must be valid URL"); } } return ValidationResult.SUCCESS; }  }
PropertyValidator implements Validator { @Override public ValidationResult validateProperty(String property, ViewInstanceDefinition viewInstanceDefinition, ValidationContext validationContext) { ClusterType clusterType = viewInstanceDefinition.getClusterType(); if (clusterType == ClusterType.LOCAL_AMBARI || clusterType == ClusterType.REMOTE_AMBARI) { return ValidationResult.SUCCESS; } if (property.equals(WEBHDFS_URL)) { String webhdfsUrl = viewInstanceDefinition.getPropertyMap().get(WEBHDFS_URL); if (!ValidatorUtils.validateHdfsURL(webhdfsUrl)) { LOG.error("Invalid webhdfs.url = {}", webhdfsUrl); return new InvalidPropertyValidationResult(false, "Must be valid URL"); } } return ValidationResult.SUCCESS; }  @Override ValidationResult validateInstance(ViewInstanceDefinition viewInstanceDefinition, ValidationContext validationContext); @Override ValidationResult validateProperty(String property, ViewInstanceDefinition viewInstanceDefinition, ValidationContext validationContext); }
PropertyValidator implements Validator { @Override public ValidationResult validateProperty(String property, ViewInstanceDefinition viewInstanceDefinition, ValidationContext validationContext) { ClusterType clusterType = viewInstanceDefinition.getClusterType(); if (clusterType == ClusterType.LOCAL_AMBARI || clusterType == ClusterType.REMOTE_AMBARI) { return ValidationResult.SUCCESS; } if (property.equals(WEBHDFS_URL)) { String webhdfsUrl = viewInstanceDefinition.getPropertyMap().get(WEBHDFS_URL); if (!ValidatorUtils.validateHdfsURL(webhdfsUrl)) { LOG.error("Invalid webhdfs.url = {}", webhdfsUrl); return new InvalidPropertyValidationResult(false, "Must be valid URL"); } } return ValidationResult.SUCCESS; }  @Override ValidationResult validateInstance(ViewInstanceDefinition viewInstanceDefinition, ValidationContext validationContext); @Override ValidationResult validateProperty(String property, ViewInstanceDefinition viewInstanceDefinition, ValidationContext validationContext); static final String WEBHDFS_URL; }