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