use of com.thinkbiganalytics.policy.validation.CharacterValidator in project kylo by Teradata.
the class CleanseAndValidateRowTest method mixedStandardizeAndValidate.
@Test
public void mixedStandardizeAndValidate() {
String fieldValue = "TeSt_fiELd";
String fieldName = "field1";
List<BaseFieldPolicy> policies = new ArrayList<>();
policies.add(UppercaseStandardizer.instance());
policies.add(new CharacterValidator("UPPERCASE"));
policies.add(LowercaseStandardizer.instance());
policies.add(new CharacterValidator("LOWERCASE"));
policies.add(UppercaseStandardizer.instance());
policies.add(new CharacterValidator("UPPERCASE"));
policies.add(LowercaseStandardizer.instance());
policies.add(new CharacterValidator("LOWERCASE"));
FieldPolicy fieldPolicy = FieldPolicyBuilder.newBuilder().addPolicies(policies).tableName("emp").fieldName(fieldName).feedFieldName(fieldName).build();
HCatDataType fieldDataType = HCatDataType.createFromDataType(fieldName, "string");
StandardizationAndValidationResult result = validator.standardizeAndValidateField(fieldPolicy, fieldValue, fieldDataType, new HashMap<Class, Class>());
assertEquals(StandardDataValidator.VALID_RESULT, result.getFinalValidationResult());
assertEquals("test_field", result.getFieldValue());
}
Aggregations