Search in sources :

Example 6 with AvroRegistry

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

the class FilterRowPropertiesTest method testRefreshLayoutMainInitial.

/**
 * Checks {@link FilterRowProperties#refreshLayout(Form)}
 */
@Ignore("Need to be able to have a schema in order to provide a column name checking.")
@Test
public void testRefreshLayoutMainInitial() {
    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);
    properties.refreshLayout(properties.getForm(Form.MAIN));
    assertTrue(properties.getForm(Form.MAIN).getWidget("columnName").isVisible());
    assertTrue(properties.getForm(Form.MAIN).getWidget("function").isVisible());
    assertTrue(properties.getForm(Form.MAIN).getWidget("operator").isVisible());
    assertTrue(properties.getForm(Form.MAIN).getWidget("value").isVisible());
    // The refreshLayout will change the columnName
    assertEquals("inputValue1", filterProperties.columnName.getValue());
    assertEquals("EMPTY", filterProperties.function.getValue());
    assertEquals("==", filterProperties.operator.getValue());
    assertNull(filterProperties.value.getValue());
    properties.refreshLayout(properties.getForm(Form.MAIN));
    assertTrue(properties.getForm(Form.MAIN).getWidget("columnName").isVisible());
    assertTrue(properties.getForm(Form.MAIN).getWidget("function").isVisible());
    assertTrue(properties.getForm(Form.MAIN).getWidget("operator").isVisible());
    assertTrue(properties.getForm(Form.MAIN).getWidget("value").isVisible());
    // The refreshLayout will change the columnName
    assertEquals("inputValue1", filterProperties.columnName.getValue());
    assertEquals("EMPTY", filterProperties.function.getValue());
    assertEquals("==", filterProperties.operator.getValue());
    assertNull(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 7 with AvroRegistry

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

the class FilterRowPropertiesTest method testUpdateConditions_ok.

@Ignore("Need to be able to have a schema in order to provide a column name checking.")
@Test
public void testUpdateConditions_ok() {
    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, will not change
    FilterRowProperties properties = new FilterRowProperties("condition2");
    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.LOWER_CASE, 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.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 8 with AvroRegistry

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

the class TJiraInputPropertiesTest method testSetupSchema.

/**
 * Checks {@link TJiraInputProperties#setupSchema()} sets correct initial schema property
 */
@Test
public void testSetupSchema() {
    AvroRegistry registry = new AvroRegistry();
    Schema stringSchema = registry.getConverter(String.class).getSchema();
    Schema.Field jsonField = new Schema.Field("json", stringSchema, null, null, Order.ASCENDING);
    Schema expectedSchema = Schema.createRecord("jira", null, null, false, Collections.singletonList(jsonField));
    expectedSchema.addProp(TALEND_IS_LOCKED, "true");
    TJiraInputProperties properties = new TJiraInputProperties("root");
    properties.setupSchema();
    Schema schema = properties.schema.schema.getValue();
    assertThat(schema, equalTo(expectedSchema));
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) Test(org.junit.Test)

Example 9 with AvroRegistry

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

the class JiraSourceOrSinkTest method setUp.

/**
 * Prepares required instances for tests
 */
@Before
public void setUp() {
    AvroRegistry registry = new AvroRegistry();
    Schema stringSchema = registry.getConverter(String.class).getSchema();
    Schema.Field jsonField = new Schema.Field("json", stringSchema, null, null, Order.ASCENDING);
    schema = Schema.createRecord("jira", null, null, false, Collections.singletonList(jsonField));
    schema.addProp(TALEND_IS_LOCKED, "true");
    outputProperties = new TJiraOutputProperties("root");
    outputProperties.connection.hostUrl.setValue("hostValue");
    outputProperties.connection.basicAuthentication.userId.setValue("userIdValue");
    outputProperties.connection.basicAuthentication.password.setValue("passwordValue");
    outputProperties.resource.setValue(Resource.ISSUE);
    outputProperties.schema.schema.setValue(schema);
    outputProperties.action.setValue(Action.INSERT);
    sourceOrSink = new JiraSourceOrSink();
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) TJiraOutputProperties(org.talend.components.jira.tjiraoutput.TJiraOutputProperties) Before(org.junit.Before)

Example 10 with AvroRegistry

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

the class JiraSourceTest method setUp.

/**
 * Prepares required instances for tests
 */
@Before
public void setUp() {
    AvroRegistry registry = new AvroRegistry();
    Schema stringSchema = registry.getConverter(String.class).getSchema();
    Schema.Field jsonField = new Schema.Field("json", stringSchema, null, null, Order.ASCENDING);
    schema = Schema.createRecord("jira", null, null, false, Collections.singletonList(jsonField));
    schema.addProp(TALEND_IS_LOCKED, "true");
    inputProperties = new TJiraInputProperties("root");
    inputProperties.connection.hostUrl.setValue("hostValue");
    inputProperties.connection.basicAuthentication.userId.setValue("userIdValue");
    inputProperties.connection.basicAuthentication.password.setValue("passwordValue");
    inputProperties.resource.setValue(Resource.ISSUE);
    inputProperties.schema.schema.setValue(schema);
    inputProperties.jql.setValue("jqlValue");
    inputProperties.batchSize.setValue(50);
    inputProperties.projectId.setValue("projectIdValue");
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) TJiraInputProperties(org.talend.components.jira.tjirainput.TJiraInputProperties) Before(org.junit.Before)

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