Search in sources :

Example 6 with TSnowflakeInputProperties

use of org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties 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 7 with TSnowflakeInputProperties

use of org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties 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)

Example 8 with TSnowflakeInputProperties

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

the class SnowflakeReadersTestIT method testTableNamesInput.

@Test
public void testTableNamesInput() throws Throwable {
    TSnowflakeInputProperties props = (TSnowflakeInputProperties) getComponentService().getComponentProperties(TSnowflakeInputDefinition.COMPONENT_NAME);
    setupProps(props.getConnectionProperties());
    ComponentTestUtils.checkSerialize(props, errorCollector);
    checkAndSetupTable(props);
}
Also used : TSnowflakeInputProperties(org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties) Test(org.junit.Test)

Example 9 with TSnowflakeInputProperties

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

the class SnowflakeRuntimeIT method readRows.

protected List<IndexedRecord> readRows(SnowflakeConnectionTableProperties props, RuntimeContainer container) throws IOException {
    TSnowflakeInputProperties inputProps = null;
    if (props instanceof TSnowflakeInputProperties) {
        inputProps = (TSnowflakeInputProperties) props;
    } else {
        inputProps = (TSnowflakeInputProperties) new TSnowflakeInputProperties("bar").init();
    }
    inputProps.connection = props.connection;
    inputProps.table = props.table;
    BoundedReader<IndexedRecord> reader = (SnowflakeReader) createBoundedReader(inputProps, container);
    boolean hasRecord = reader.start();
    List<IndexedRecord> rows = new ArrayList<>();
    while (hasRecord) {
        org.apache.avro.generic.IndexedRecord unenforced = reader.getCurrent();
        rows.add(unenforced);
        hasRecord = reader.advance();
    }
    reader.close();
    return rows;
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) ArrayList(java.util.ArrayList) TSnowflakeInputProperties(org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties) IndexedRecord(org.apache.avro.generic.IndexedRecord) SnowflakeReader(org.talend.components.snowflake.runtime.SnowflakeReader)

Example 10 with TSnowflakeInputProperties

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

the class SnowflakeReaderTest method setUp.

@Before
public void setUp() throws Exception {
    schema = SchemaBuilder.builder().record("Schema").fields().requiredString("field").requiredString("column").endRecord();
    schema.getField("field").addProp(SchemaConstants.TALEND_COLUMN_DB_COLUMN_NAME, "field");
    schema.getField("column").addProp(SchemaConstants.TALEND_COLUMN_DB_COLUMN_NAME, "column");
    TSnowflakeInputProperties tSnowflakeInputProperties = new TSnowflakeInputProperties("test");
    tSnowflakeInputProperties.setupProperties();
    tSnowflakeInputProperties.table.main.schema.setValue(schema);
    tSnowflakeInputProperties.table.tableName.setValue("Table");
    snowflakeReader = new SnowflakeReader(runtimeContainerMock, snowflakeSourceMock, tSnowflakeInputProperties);
}
Also used : TSnowflakeInputProperties(org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties) Before(org.junit.Before)

Aggregations

TSnowflakeInputProperties (org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties)10 Test (org.junit.Test)7 Form (org.talend.daikon.properties.presentation.Form)4 IndexedRecord (org.apache.avro.generic.IndexedRecord)3 TSnowflakeInputDefinition (org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputDefinition)3 Schema (org.apache.avro.Schema)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Before (org.junit.Before)2 SnowflakeConnectionProperties (org.talend.components.snowflake.SnowflakeConnectionProperties)2 SnowflakeSourceOrSink (org.talend.components.snowflake.runtime.SnowflakeSourceOrSink)2 ArrayList (java.util.ArrayList)1 DefaultComponentRuntimeContainerImpl (org.talend.components.api.container.DefaultComponentRuntimeContainerImpl)1 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)1 SnowflakeTableProperties (org.talend.components.snowflake.SnowflakeTableProperties)1 SnowflakeReader (org.talend.components.snowflake.runtime.SnowflakeReader)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1