Search in sources :

Example 11 with AvroRegistry

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

the class JiraSinkTest 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);
    outputProperties.deleteSubtasks.setValue(true);
}
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 12 with AvroRegistry

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

the class IssueAdapterFactoryTest method setUp.

/**
 * Initializes test arguments before tests
 */
@BeforeClass
public static 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);
    testSchema = Schema.createRecord("jira", null, null, false, Collections.singletonList(jsonField));
    testSchema.addProp(TALEND_IS_LOCKED, "true");
    issueIndexedRecord = new IssueIndexedRecord(testJson, testSchema);
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) BeforeClass(org.junit.BeforeClass)

Example 13 with AvroRegistry

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

the class TJiraOutputPropertiesTest method testAfterActionInsert.

/**
 * Checks {@link TJiraOutputProperties#afterAction()} hides deleteSubtasks widget and sets correct schema for Insert
 * action, if Insert action chosen
 */
@Test
public void testAfterActionInsert() {
    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");
    TJiraOutputProperties properties = new TJiraOutputProperties("root");
    properties.init();
    properties.action.setValue(Action.INSERT);
    properties.afterAction();
    boolean deleteSubtasksHidden = properties.getForm(Form.ADVANCED).getWidget("deleteSubtasks").isHidden();
    assertTrue(deleteSubtasksHidden);
    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 14 with AvroRegistry

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

the class TJiraOutputPropertiesTest method testAfterActionDelete.

/**
 * Checks {@link TJiraOutputProperties#afterAction()} sets correct schema for Delete
 * action, if Delete action is chosen
 */
@Test
public void testAfterActionDelete() {
    AvroRegistry registry = new AvroRegistry();
    Schema stringSchema = registry.getConverter(String.class).getSchema();
    Schema.Field idField = new Schema.Field("id", stringSchema, null, null, Order.ASCENDING);
    Schema expectedSchema = Schema.createRecord("jira", null, null, false, Collections.singletonList(idField));
    expectedSchema.addProp(TALEND_IS_LOCKED, "true");
    TJiraOutputProperties properties = new TJiraOutputProperties("root");
    properties.init();
    properties.action.setValue(Action.DELETE);
    properties.afterAction();
    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 15 with AvroRegistry

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

the class NormalizePropertiesTest method testSetupSchema.

/**
 * Checks {@link NormalizeProperties} update correctly * schema property
 */
@Test
public void testSetupSchema() {
    NormalizeProperties properties = new NormalizeProperties("test");
    properties.init();
    AvroRegistry registry = new AvroRegistry();
    Schema stringSchema = registry.getConverter(String.class).getSchema();
    Schema.Field inputValue1Field = new Schema.Field("inputValue1", stringSchema, null, null, Schema.Field.Order.ASCENDING);
    Schema.Field inputValue2Field = new Schema.Field("inputValue2", stringSchema, null, null, Schema.Field.Order.ASCENDING);
    Schema inputSchema = Schema.createRecord("inputSchema", null, null, false, Arrays.asList(inputValue1Field, inputValue2Field));
    properties.main.schema.setValue(inputSchema);
    properties.columnToNormalize.setValue("testColumnToNormalize");
    properties.isList.setValue(false);
    properties.fieldSeparator.setValue(NormalizeConstant.Delimiter.OTHER);
    properties.otherSeparator.setValue("|");
    properties.discardTrailingEmptyStr.setValue(false);
    properties.trim.setValue(false);
    // 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));
    // the afterScheam trigger an update to the columnName
    assertThat("testColumnToNormalize", is(equalTo(properties.columnToNormalize.getValue())));
    assertThat(false, is(equalTo(properties.isList.getValue())));
    assertThat(NormalizeConstant.Delimiter.OTHER, is(equalTo(properties.fieldSeparator.getValue())));
    assertThat("|", is(equalTo(properties.otherSeparator.getValue())));
    assertThat(false, is(equalTo(properties.discardTrailingEmptyStr.getValue())));
    assertThat(false, is(equalTo(properties.trim.getValue())));
}
Also used : AvroRegistry(org.talend.daikon.avro.AvroRegistry) Schema(org.apache.avro.Schema) 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