Search in sources :

Example 1 with TSnowflakeInputDefinition

use of org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputDefinition in project components by Talend.

the class SnowflakeReadersTestIT method testInputManual.

@Test
public void testInputManual() throws Throwable {
    TSnowflakeInputProperties props = (TSnowflakeInputProperties) new TSnowflakeInputDefinition().createProperties();
    setupProps(props.getConnectionProperties());
    Form f = props.getForm(MAIN);
    props.manualQuery.setValue(true);
    props = (TSnowflakeInputProperties) PropertiesTestUtils.checkAndAfter(getComponentService(), f, props.manualQuery.getName(), props);
    props.query.setValue("select ID, C7 from " + testTable + " where ID > 80");
    setupTableWithStaticValues(props);
    List<IndexedRecord> rows = readRows(props);
    assertEquals(19, rows.size());
    Schema schema = rows.get(0).getSchema();
    LOGGER.debug(schema.toString());
    assertEquals(BigDecimal.valueOf(81), rows.get(0).get(0));
    assertThat((String) rows.get(0).get(1), containsString("\"bar\": 81"));
}
Also used : TSnowflakeInputDefinition(org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputDefinition) IndexedRecord(org.apache.avro.generic.IndexedRecord) Form(org.talend.daikon.properties.presentation.Form) Schema(org.apache.avro.Schema) TSnowflakeInputProperties(org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties) Test(org.junit.Test)

Example 2 with TSnowflakeInputDefinition

use of org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputDefinition in project components by Talend.

the class SnowflakeReadersTestIT method testInputManualError.

@Test(expected = IOException.class)
public void testInputManualError() throws Throwable {
    TSnowflakeInputProperties props = (TSnowflakeInputProperties) new TSnowflakeInputDefinition().createProperties();
    setupProps(props.getConnectionProperties());
    Form f = props.getForm(MAIN);
    props.manualQuery.setValue(true);
    props = (TSnowflakeInputProperties) PropertiesTestUtils.checkAndAfter(getComponentService(), f, props.manualQuery.getName(), props);
    props.query.setValue("bad query");
    readRows(props);
}
Also used : TSnowflakeInputDefinition(org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputDefinition) Form(org.talend.daikon.properties.presentation.Form) TSnowflakeInputProperties(org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties) Test(org.junit.Test)

Example 3 with TSnowflakeInputDefinition

use of org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputDefinition in project components by Talend.

the class SnowflakeReadersTestIT method testInputCondition.

@Test
public void testInputCondition() throws Throwable {
    TSnowflakeInputProperties props = (TSnowflakeInputProperties) new TSnowflakeInputDefinition().createProperties();
    setupProps(props.getConnectionProperties());
    Form f = props.getForm(MAIN);
    props.manualQuery.setValue(false);
    props = (TSnowflakeInputProperties) PropertiesTestUtils.checkAndAfter(getComponentService(), f, props.manualQuery.getName(), props);
    props.condition.setValue("ID > 80");
    setupTableWithStaticValues(props);
    List<IndexedRecord> rows = readRows(props);
    assertEquals(19, rows.size());
    assertEquals(BigDecimal.valueOf(81), rows.get(0).get(0));
    assertEquals("foo_81", rows.get(0).get(1));
}
Also used : TSnowflakeInputDefinition(org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputDefinition) IndexedRecord(org.apache.avro.generic.IndexedRecord) Form(org.talend.daikon.properties.presentation.Form) TSnowflakeInputProperties(org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 TSnowflakeInputDefinition (org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputDefinition)3 TSnowflakeInputProperties (org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties)3 Form (org.talend.daikon.properties.presentation.Form)3 IndexedRecord (org.apache.avro.generic.IndexedRecord)2 Schema (org.apache.avro.Schema)1