Search in sources :

Example 26 with AvroRegistry

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));
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 27 with AvroRegistry

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));
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 28 with AvroRegistry

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));
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 29 with AvroRegistry

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());
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 30 with AvroRegistry

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));
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

AvroRegistry (org.talend.daikon.avro.AvroRegistry)31 Schema (org.apache.avro.Schema)29 Test (org.junit.Test)19 Ignore (org.junit.Ignore)11 Before (org.junit.Before)4 TJiraOutputProperties (org.talend.components.jira.tjiraoutput.TJiraOutputProperties)3 IndexedRecord (org.apache.avro.generic.IndexedRecord)2 BeforeClass (org.junit.BeforeClass)2 SplunkJSONEventField (org.talend.components.splunk.objects.SplunkJSONEventField)2 Field (org.apache.avro.Schema.Field)1 DoFn (org.apache.beam.sdk.transforms.DoFn)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 GenericAvroRegistry (org.talend.components.common.runtime.GenericAvroRegistry)1 Action (org.talend.components.jira.Action)1 Mode (org.talend.components.jira.Mode)1 Resource (org.talend.components.jira.Resource)1 TJiraInputProperties (org.talend.components.jira.tjirainput.TJiraInputProperties)1 IndexedRecordConverter (org.talend.daikon.avro.converter.IndexedRecordConverter)1 TalendRuntimeException (org.talend.daikon.exception.TalendRuntimeException)1