use of com.thinkbiganalytics.policy.validation.LookupValidator in project kylo by Teradata.
the class CleanseAndValidateRowTest method invalidStandardizeAndValidate.
@Test
public void invalidStandardizeAndValidate() {
String fieldName = "field1";
List<BaseFieldPolicy> policies = new ArrayList<>();
policies.add(new SimpleRegexReplacer("(?i)foo", "bar"));
policies.add(new LookupValidator("blah"));
policies.add(new SimpleRegexReplacer("(?i)bar", "test"));
policies.add(new LookupValidator("aatestaa"));
FieldPolicy fieldPolicy = FieldPolicyBuilder.newBuilder().addPolicies(policies).tableName("emp").fieldName(fieldName).feedFieldName(fieldName).build();
HCatDataType fieldDataType = HCatDataType.createFromDataType(fieldName, "string");
StandardizationAndValidationResult result = validator.standardizeAndValidateField(fieldPolicy, "aafooaa", fieldDataType, new HashMap<Class, Class>());
assertEquals("aabaraa", result.getFieldValue());
assertNotEquals(StandardDataValidator.VALID_RESULT, result.getFinalValidationResult());
}
use of com.thinkbiganalytics.policy.validation.LookupValidator in project kylo by Teradata.
the class TestValidationTransformation method testLookupValidator.
@Test
public void testLookupValidator() {
String lookupList = "one,two,three";
LookupValidator validator = new LookupValidator(lookupList);
FieldValidationRule uiModel = ValidatorAnnotationTransformer.instance().toUIModel(validator);
LookupValidator convertedValidator = fromUI(uiModel, LookupValidator.class);
Assert.assertEquals(lookupList, convertedValidator.getLookupList());
for (String value : StringUtils.split(lookupList, ",")) {
Assert.assertTrue(value, convertedValidator.getLookupValues().contains(value));
}
}
use of com.thinkbiganalytics.policy.validation.LookupValidator in project kylo by Teradata.
the class CleanseAndValidateRowTest method nullValueStandardizeAndValidate.
@Test
public void nullValueStandardizeAndValidate() {
String fieldName = "field1";
List<BaseFieldPolicy> policies = new ArrayList<>();
policies.add(new SimpleRegexReplacer("(?i)foo", "bar"));
policies.add(new LookupValidator("blah"));
policies.add(new SimpleRegexReplacer("(?i)bar", "test"));
policies.add(new LookupValidator("aatestaa"));
FieldPolicy fieldPolicy = FieldPolicyBuilder.newBuilder().addPolicies(policies).tableName("emp").fieldName(fieldName).feedFieldName(fieldName).build();
HCatDataType fieldDataType = HCatDataType.createFromDataType(fieldName, "string");
StandardizationAndValidationResult result = validator.standardizeAndValidateField(fieldPolicy, null, fieldDataType, new HashMap<Class, Class>());
assertEquals(StandardDataValidator.VALID_RESULT, result.getFinalValidationResult());
}
use of com.thinkbiganalytics.policy.validation.LookupValidator in project kylo by Teradata.
the class CleanseAndValidateRowTest method standardizeAndValidate.
@Test
public void standardizeAndValidate() {
String fieldName = "field1";
List<BaseFieldPolicy> policies = new ArrayList<>();
policies.add(new SimpleRegexReplacer("(?i)foo", "bar"));
policies.add(new LookupValidator("aabaraa"));
policies.add(new SimpleRegexReplacer("(?i)bar", "test"));
policies.add(new LookupValidator("aatestaa"));
FieldPolicy fieldPolicy = FieldPolicyBuilder.newBuilder().addPolicies(policies).tableName("emp").fieldName(fieldName).feedFieldName(fieldName).build();
HCatDataType fieldDataType = HCatDataType.createFromDataType(fieldName, "string");
StandardizationAndValidationResult result = validator.standardizeAndValidateField(fieldPolicy, "aafooaa", fieldDataType, new HashMap<Class, Class>());
assertEquals(result.getFieldValue(), "aatestaa");
assertEquals(StandardDataValidator.VALID_RESULT, result.getFinalValidationResult());
}
Aggregations