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);
}
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);
}
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));
}
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));
}
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())));
}
Aggregations