use of com.thinkbiganalytics.policy.standardization.DefaultValueStandardizer in project kylo by Teradata.
the class TestJsonPolicies method testJson.
@Test
public void testJson() throws IOException {
List<com.thinkbiganalytics.policy.rest.model.FieldPolicy> fieldPolicies = new ArrayList<>();
List<FieldStandardizationRule> standardizationPolicyList = new ArrayList<>();
List<FieldValidationRule> validationRules = new ArrayList<>();
DefaultValueStandardizer defaultValueStandardizer = new DefaultValueStandardizer("My Default");
standardizationPolicyList.add(StandardizationAnnotationTransformer.instance().toUIModel(defaultValueStandardizer));
DateTimeStandardizer dateTimeStandardizer = new DateTimeStandardizer("MM/DD/YYYY", DateTimeStandardizer.OutputFormats.DATETIME_NOMILLIS);
standardizationPolicyList.add(StandardizationAnnotationTransformer.instance().toUIModel(dateTimeStandardizer));
RangeValidator validator = new RangeValidator(10, 20);
validationRules.add(ValidatorAnnotationTransformer.instance().toUIModel(validator));
fieldPolicies.add(new FieldPolicyBuilder("field1").addStandardization(standardizationPolicyList).addValidations(validationRules).build());
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(fieldPolicies);
FieldPoliciesJsonTransformer fieldPolicyTransformer = new FieldPoliciesJsonTransformer(json);
Map<String, com.thinkbiganalytics.policy.FieldPolicy> policyMap = fieldPolicyTransformer.buildPolicies();
com.thinkbiganalytics.policy.FieldPolicy field1Policy = policyMap.get("field1");
Assert.assertEquals(2, field1Policy.getStandardizationPolicies().size());
Assert.assertEquals(1, field1Policy.getValidators().size());
}
use of com.thinkbiganalytics.policy.standardization.DefaultValueStandardizer in project kylo by Teradata.
the class TestStandardizationTransform method testUiCreation.
@Test
public void testUiCreation() {
List<FieldStandardizationRule> standardizationRules = AvailablePolicies.discoverStandardizationRules();
FieldStandardizationRule defaultValue = Iterables.tryFind(standardizationRules, new PredicateImpl<FieldStandardizationRule>() {
@Override
public boolean test(FieldStandardizationRule fieldStandardizationRule) {
return fieldStandardizationRule.getName().equalsIgnoreCase("Default Value");
}
}).orNull();
defaultValue.getProperty("Default Value").setValue("a new default value");
DefaultValueStandardizer convertedPolicy = fromUI(defaultValue, DefaultValueStandardizer.class);
Assert.assertEquals("a new default value", convertedPolicy.getDefaultStr());
}
use of com.thinkbiganalytics.policy.standardization.DefaultValueStandardizer in project kylo by Teradata.
the class TestStandardizationTransform method testDefaultValue.
@Test
public void testDefaultValue() throws IOException {
String INPUT = "My Default";
DefaultValueStandardizer standardizer = new DefaultValueStandardizer(INPUT);
FieldStandardizationRule uiModel = StandardizationAnnotationTransformer.instance().toUIModel(standardizer);
DefaultValueStandardizer convertedPolicy = fromUI(uiModel, DefaultValueStandardizer.class);
Assert.assertEquals(INPUT, convertedPolicy.getDefaultStr());
}
Aggregations