Search in sources :

Example 1 with AvroRegistry

use of org.talend.daikon.avro.AvroRegistry in project components by Talend.

the class TSplunkEventCollectorWriterTestIT method createSchema.

/**
 * Create default static schema for indexed record.
 */
private Schema createSchema() {
    AvroRegistry avroReg = new AvroRegistry();
    FieldAssembler<Schema> record = SchemaBuilder.record("Main").fields();
    addField(record, "FieldString", String.class, avroReg);
    addField(record, "FieldInt", Integer.class, avroReg);
    Schema defaultSchema = record.endRecord();
    return defaultSchema;
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema)

Example 2 with AvroRegistry

use of org.talend.daikon.avro.AvroRegistry in project components by Talend.

the class FilterRowPropertiesTest method testUpdateConditions_wrongfunction.

@Ignore("Need to be able to check the column type in order to provide a function checking.")
@Test
public void testUpdateConditions_wrongfunction() {
    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));
    // specific value, "function" will change cause inputValue1's type is
    // not a compatible with ConditionsRow.ABS_VALUE
    FilterRowProperties properties = new FilterRowProperties("condition1");
    properties.init();
    FilterRowCriteriaProperties filterProperties = new FilterRowCriteriaProperties("filter1");
    filterProperties.init();
    properties.main.schema.setValue(inputSchema);
    properties.updateOutputSchemas();
    filterProperties.columnName.setValue("inputValue1");
    filterProperties.function.setValue(ConditionsRowConstant.Function.ABS_VALUE);
    filterProperties.operator.setValue(ConditionsRowConstant.Operator.NOT_EQUAL);
    filterProperties.value.setValue("1111");
    properties.updateConditionsRow();
    assertEquals("inputValue1", filterProperties.columnName.getValue());
    assertEquals(ConditionsRowConstant.Function.EMPTY, filterProperties.function.getValue());
    assertEquals(ConditionsRowConstant.Operator.NOT_EQUAL, filterProperties.operator.getValue());
    assertEquals("1111", 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 3 with AvroRegistry

use of org.talend.daikon.avro.AvroRegistry in project components by Talend.

the class FilterRowPropertiesTest method testUpdateConditions_longSchema.

@Ignore("Need to be able to check the column type in order to provide a function checking.")
@Test
public void testUpdateConditions_longSchema() {
    AvroRegistry registry = new AvroRegistry();
    Schema longSchema = registry.getConverter(Long.class).getSchema();
    Schema.Field inputValue1Field = new Schema.Field("inputValue1", longSchema, null, null, Order.ASCENDING);
    Schema.Field inputValue2Field = new Schema.Field("inputValue2", longSchema, 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 4 with AvroRegistry

use of org.talend.daikon.avro.AvroRegistry in project components by Talend.

the class FilterRowPropertiesTest method testUpdateConditions_booleanSchema.

@Ignore("Need to be able to check the column type in order to provide a function checking.")
@Test
public void testUpdateConditions_booleanSchema() {
    AvroRegistry registry = new AvroRegistry();
    Schema booleanSchema = registry.getConverter(Boolean.class).getSchema();
    Schema.Field inputValue1Field = new Schema.Field("inputValue1", booleanSchema, null, null, Order.ASCENDING);
    Schema.Field inputValue2Field = new Schema.Field("inputValue2", booleanSchema, 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("condition5");
    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.DEFAULT_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 5 with AvroRegistry

use of org.talend.daikon.avro.AvroRegistry in project components by Talend.

the class FilterRowPropertiesTest method testConditions.

/**
 * 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 testConditions() {
    FilterRowProperties properties = new FilterRowProperties("test");
    properties.init();
    FilterRowCriteriaProperties filterProperties = new FilterRowCriteriaProperties("filter1");
    filterProperties.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);
    // default value, "columName" will change
    properties.schemaListener.afterSchema();
    assertEquals("inputValue1", filterProperties.columnName.getValue());
    assertEquals("EMPTY", filterProperties.function.getValue());
    assertEquals("==", filterProperties.operator.getValue());
    assertNull(filterProperties.value.getValue());
    // specific value, "function" will change cause inputValue1's type is
    // not a compatible with "ABS_VALUE"
    filterProperties.columnName.setValue("inputValue1");
    filterProperties.function.setValue("ABS_VALUE");
    filterProperties.operator.setValue("!=");
    filterProperties.value.setValue("1111");
    properties.schemaListener.afterSchema();
    assertEquals("inputValue1", filterProperties.columnName.getValue());
    assertEquals("EMPTY", filterProperties.function.getValue());
    assertEquals("!=", filterProperties.operator.getValue());
    assertEquals("1111", filterProperties.value.getValue());
    // specific value, will not change
    filterProperties.columnName.setValue("inputValue2");
    filterProperties.function.setValue("LC");
    filterProperties.operator.setValue("==");
    filterProperties.value.setValue("2222");
    properties.schemaListener.afterSchema();
    assertEquals("inputValue2", filterProperties.columnName.getValue());
    assertEquals("LC", filterProperties.function.getValue());
    assertEquals("==", filterProperties.operator.getValue());
    assertEquals("2222", filterProperties.value.getValue());
    // specific value, "operator" will change cause the function "MATCH" is
    // not a compatible with "<"
    filterProperties.columnName.setValue("INPUTVALUE1");
    filterProperties.function.setValue("MATCH");
    filterProperties.operator.setValue("<");
    filterProperties.value.setValue("3333");
    properties.schemaListener.afterSchema();
    assertEquals("inputValue1", filterProperties.columnName.getValue());
    assertEquals("MATCH", filterProperties.function.getValue());
    assertEquals("==", filterProperties.operator.getValue());
    assertEquals("3333", filterProperties.value.getValue());
    // specific value, "operator" will change cause the function "CONTAINS" is
    // not a compatible with "<"
    filterProperties.columnName.setValue("inputValue1");
    filterProperties.function.setValue("CONTAINS");
    filterProperties.operator.setValue("<");
    filterProperties.value.setValue("4444");
    properties.schemaListener.afterSchema();
    assertEquals("inputValue1", filterProperties.columnName.getValue());
    assertEquals("CONTAINS", filterProperties.function.getValue());
    assertEquals("==", filterProperties.operator.getValue());
    assertEquals("4444", filterProperties.value.getValue());
}
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