use of org.talend.daikon.avro.AvroRegistry in project components by Talend.
the class FilterRowPropertiesTest method testUpdateConditions_floatSchema.
@Ignore("Need to be able to check the column type in order to provide a function checking.")
@Test
public void testUpdateConditions_floatSchema() {
AvroRegistry registry = new AvroRegistry();
Schema floatSchema = registry.getConverter(Float.class).getSchema();
Schema.Field inputValue1Field = new Schema.Field("inputValue1", floatSchema, null, null, Order.ASCENDING);
Schema.Field inputValue2Field = new Schema.Field("inputValue2", floatSchema, null, null, Order.ASCENDING);
Schema inputSchema = Schema.createRecord("inputSchema", null, null, false, Arrays.asList(inputValue1Field, inputValue2Field));
// specific value, will change due to type compatibility
FilterRowProperties properties = new FilterRowProperties("condition4");
properties.init();
FilterRowCriteriaProperties filterProperties = new FilterRowCriteriaProperties("filter1");
filterProperties.init();
properties.main.schema.setValue(inputSchema);
properties.updateOutputSchemas();
filterProperties.columnName.setValue("inputValue2");
filterProperties.function.setValue(ConditionsRowConstant.Function.LOWER_CASE);
filterProperties.operator.setValue(ConditionsRowConstant.Operator.EQUAL);
filterProperties.value.setValue("2222");
properties.updateConditionsRow();
assertEquals("inputValue2", filterProperties.columnName.getValue());
assertEquals(ConditionsRowConstant.Function.EMPTY, filterProperties.function.getValue());
assertEquals(ConditionsRowConstant.Operator.EQUAL, filterProperties.operator.getValue());
assertEquals("2222", filterProperties.value.getValue());
assertThat((List<String>) filterProperties.columnName.getPossibleValues(), is(Arrays.asList("inputValue1", "inputValue2")));
assertThat((List<String>) filterProperties.function.getPossibleValues(), is(ConditionsRowConstant.NUMERICAL_FUNCTIONS));
assertThat((List<String>) filterProperties.operator.getPossibleValues(), is(ConditionsRowConstant.DEFAULT_OPERATORS));
}
use of org.talend.daikon.avro.AvroRegistry in project components by Talend.
the class FilterRowPropertiesTest method testUpdateDefaultConditions.
// testing conditions update specific case
@Ignore("Need to be able to have a schema in order to provide a column name checking.")
@Test
public void testUpdateDefaultConditions() {
AvroRegistry registry = new AvroRegistry();
Schema stringSchema = registry.getConverter(String.class).getSchema();
Schema.Field inputValue1Field = new Schema.Field("inputValue1", stringSchema, null, null, Order.ASCENDING);
Schema.Field inputValue2Field = new Schema.Field("inputValue2", stringSchema, null, null, Order.ASCENDING);
Schema inputSchema = Schema.createRecord("inputSchema", null, null, false, Arrays.asList(inputValue1Field, inputValue2Field));
// default value, "columName" will change
FilterRowProperties properties = new FilterRowProperties("condition0");
properties.init();
FilterRowCriteriaProperties filterProperties = new FilterRowCriteriaProperties("filter1");
filterProperties.init();
properties.main.schema.setValue(inputSchema);
properties.updateOutputSchemas();
properties.updateConditionsRow();
assertEquals("inputValue1", filterProperties.columnName.getValue());
assertEquals(ConditionsRowConstant.Function.EMPTY, filterProperties.function.getValue());
assertEquals(ConditionsRowConstant.Operator.EQUAL, filterProperties.operator.getValue());
assertNull(filterProperties.value.getValue());
assertThat((List<String>) filterProperties.columnName.getPossibleValues(), is(Arrays.asList("inputValue1", "inputValue2")));
assertThat((List<String>) filterProperties.function.getPossibleValues(), is(ConditionsRowConstant.STRING_FUNCTIONS));
assertThat((List<String>) filterProperties.operator.getPossibleValues(), is(ConditionsRowConstant.DEFAULT_OPERATORS));
}
use of org.talend.daikon.avro.AvroRegistry in project components by Talend.
the class FilterRowPropertiesTest method testUpdateConditions_integerSchema.
@Test
@Ignore("Need to be able to check the column type in order to provide a function checking.")
public void testUpdateConditions_integerSchema() {
AvroRegistry registry = new AvroRegistry();
Schema integerSchema = registry.getConverter(Integer.class).getSchema();
Schema.Field inputValue1Field = new Schema.Field("inputValue1", integerSchema, null, null, Order.ASCENDING);
Schema.Field inputValue2Field = new Schema.Field("inputValue2", integerSchema, null, null, Order.ASCENDING);
Schema inputSchema = Schema.createRecord("inputSchema", null, null, false, Arrays.asList(inputValue1Field, inputValue2Field));
// specific value, will change due to type compatibility
FilterRowProperties properties = new FilterRowProperties("condition4");
properties.init();
FilterRowCriteriaProperties filterProperties = new FilterRowCriteriaProperties("filter1");
filterProperties.init();
properties.main.schema.setValue(inputSchema);
properties.updateOutputSchemas();
filterProperties.columnName.setValue("inputValue2");
filterProperties.function.setValue(ConditionsRowConstant.Function.LOWER_CASE);
filterProperties.operator.setValue(ConditionsRowConstant.Operator.EQUAL);
filterProperties.value.setValue("2222");
properties.updateConditionsRow();
assertEquals("inputValue2", filterProperties.columnName.getValue());
assertEquals(ConditionsRowConstant.Function.EMPTY, filterProperties.function.getValue());
assertEquals(ConditionsRowConstant.Operator.EQUAL, filterProperties.operator.getValue());
assertEquals("2222", filterProperties.value.getValue());
assertThat((List<String>) filterProperties.columnName.getPossibleValues(), is(Arrays.asList("inputValue1", "inputValue2")));
assertThat((List<String>) filterProperties.function.getPossibleValues(), is(ConditionsRowConstant.NUMERICAL_FUNCTIONS));
assertThat((List<String>) filterProperties.operator.getPossibleValues(), is(ConditionsRowConstant.DEFAULT_OPERATORS));
}
use of org.talend.daikon.avro.AvroRegistry in project components by Talend.
the class FilterRowPropertiesTest method testSetupSchema.
/**
* Checks {@link FilterRowProperties} update correctly * schema property
*/
@Ignore("Need to be able to have a schema in order to provide a column name checking.")
@Test
public void testSetupSchema() {
FilterRowProperties properties = new FilterRowProperties("test");
properties.init();
AvroRegistry registry = new AvroRegistry();
Schema stringSchema = registry.getConverter(String.class).getSchema();
Schema.Field inputValue1Field = new Schema.Field("inputValue1", stringSchema, null, null, Order.ASCENDING);
Schema.Field inputValue2Field = new Schema.Field("inputValue2", stringSchema, null, null, Order.ASCENDING);
Schema inputSchema = Schema.createRecord("inputSchema", null, null, false, Arrays.asList(inputValue1Field, inputValue2Field));
properties.main.schema.setValue(inputSchema);
FilterRowCriteriaProperties filterProperties = new FilterRowCriteriaProperties("filter1");
filterProperties.init();
filterProperties.columnName.setValue("invalid");
filterProperties.function.setValue("invalid");
filterProperties.operator.setValue("invalid");
filterProperties.value.setValue("valid");
// Direct call since we are directly using the component property
// instead of using PropertiesDynamicMethodHelper
properties.schemaListener.afterSchema();
assertThat(properties.main.schema.getValue(), equalTo(inputSchema));
assertThat(properties.schemaFlow.schema.getValue(), equalTo(inputSchema));
assertThat(properties.schemaReject.schema.getValue(), equalTo(inputSchema));
// the afterScheam trigger an update to the columnName
assertEquals("inputValue1", filterProperties.columnName.getValue());
assertEquals("EMPTY", filterProperties.function.getValue());
assertEquals("==", filterProperties.operator.getValue());
assertEquals("valid", filterProperties.value.getValue());
}
use of org.talend.daikon.avro.AvroRegistry in project components by Talend.
the class FilterRowPropertiesTest method testUpdateConditions_doubleSchema.
@Ignore("Need to be able to check the column type in order to provide a function checking.")
@Test
public void testUpdateConditions_doubleSchema() {
AvroRegistry registry = new AvroRegistry();
Schema doubleSchema = registry.getConverter(Double.class).getSchema();
Schema.Field inputValue1Field = new Schema.Field("inputValue1", doubleSchema, null, null, Order.ASCENDING);
Schema.Field inputValue2Field = new Schema.Field("inputValue2", doubleSchema, null, null, Order.ASCENDING);
Schema inputSchema = Schema.createRecord("inputSchema", null, null, false, Arrays.asList(inputValue1Field, inputValue2Field));
// specific value, will change due to type compatibility
FilterRowProperties properties = new FilterRowProperties("condition4");
properties.init();
FilterRowCriteriaProperties filterProperties = new FilterRowCriteriaProperties("filter1");
filterProperties.init();
properties.main.schema.setValue(inputSchema);
properties.updateOutputSchemas();
filterProperties.columnName.setValue("inputValue2");
filterProperties.function.setValue(ConditionsRowConstant.Function.LOWER_CASE);
filterProperties.operator.setValue(ConditionsRowConstant.Operator.EQUAL);
filterProperties.value.setValue("2222");
properties.updateConditionsRow();
assertEquals("inputValue2", filterProperties.columnName.getValue());
assertEquals(ConditionsRowConstant.Function.EMPTY, filterProperties.function.getValue());
assertEquals(ConditionsRowConstant.Operator.EQUAL, filterProperties.operator.getValue());
assertEquals("2222", filterProperties.value.getValue());
assertThat((List<String>) filterProperties.columnName.getPossibleValues(), is(Arrays.asList("inputValue1", "inputValue2")));
assertThat((List<String>) filterProperties.function.getPossibleValues(), is(ConditionsRowConstant.NUMERICAL_FUNCTIONS));
assertThat((List<String>) filterProperties.operator.getPossibleValues(), is(ConditionsRowConstant.DEFAULT_OPERATORS));
}
Aggregations