Search in sources :

Example 1 with TSnowflakeRowProperties

use of org.talend.components.snowflake.tsnowflakerow.TSnowflakeRowProperties in project components by Talend.

the class SnowflakeRowStandaloneTest method setup.

@Before
public void setup() throws Exception {
    properties = new TSnowflakeRowProperties("rowProperties");
    properties.setupProperties();
    properties.query.setValue(QUERY);
    standalone = new SnowflakeRowStandalone();
    standalone.initialize(null, properties);
    connection = Mockito.mock(Connection.class);
    PowerMockito.mockStatic(DriverManagerUtils.class);
    PowerMockito.when(DriverManagerUtils.getConnection(properties.getConnectionProperties())).thenReturn(connection);
}
Also used : TSnowflakeRowProperties(org.talend.components.snowflake.tsnowflakerow.TSnowflakeRowProperties) Connection(java.sql.Connection) Before(org.junit.Before)

Example 2 with TSnowflakeRowProperties

use of org.talend.components.snowflake.tsnowflakerow.TSnowflakeRowProperties in project components by Talend.

the class SnowflakeRowSinkTest method testInitialize.

@Test
public void testInitialize() {
    RuntimeContainer container = Mockito.mock(RuntimeContainer.class);
    TSnowflakeRowProperties properties = new TSnowflakeRowProperties("rowProperties");
    Assert.assertNull(sink.getRowProperties());
    ValidationResult result = sink.initialize(container, properties);
    Assert.assertEquals(ValidationResult.OK, result);
    Assert.assertEquals(properties, sink.getRowProperties());
}
Also used : TSnowflakeRowProperties(org.talend.components.snowflake.tsnowflakerow.TSnowflakeRowProperties) ValidationResult(org.talend.daikon.properties.ValidationResult) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Test(org.junit.Test)

Example 3 with TSnowflakeRowProperties

use of org.talend.components.snowflake.tsnowflakerow.TSnowflakeRowProperties in project components by Talend.

the class SnowflakeRowReaderTest method setup.

@Before
public void setup() throws IOException, SQLException {
    source = Mockito.mock(SnowflakeRowSource.class);
    connection = Mockito.mock(Connection.class);
    Mockito.when(source.createConnection(Mockito.any(RuntimeContainer.class))).thenReturn(connection);
    Mockito.doNothing().when(source).closeConnection(Mockito.any(RuntimeContainer.class), Mockito.any(Connection.class));
    properties = new TSnowflakeRowProperties("rowProperties");
    Schema schema = SchemaBuilder.builder().record("test").fields().requiredString("name").endRecord();
    query = "SELECT id, name from " + TABLE_NAME;
    properties.query.setValue(query);
    properties.schemaFlow.schema.setValue(schema);
    properties.setupProperties();
    properties.table.tableName.setValue(TABLE_NAME);
    Mockito.when(source.getRowProperties()).thenReturn(properties);
    Mockito.when(source.getRuntimeSchema(null)).thenReturn(schema);
    reader = new SnowflakeRowReader(null, source);
    Mockito.doCallRealMethod().when(source).getQuery();
}
Also used : TSnowflakeRowProperties(org.talend.components.snowflake.tsnowflakerow.TSnowflakeRowProperties) Schema(org.apache.avro.Schema) Connection(java.sql.Connection) RuntimeContainer(org.talend.components.api.container.RuntimeContainer) Before(org.junit.Before)

Example 4 with TSnowflakeRowProperties

use of org.talend.components.snowflake.tsnowflakerow.TSnowflakeRowProperties in project components by Talend.

the class SnowflakeRowSourceTest method setup.

@Before
public void setup() {
    source = new SnowflakeRowSource();
    source.initialize(null, new TSnowflakeRowProperties("rowProperties"));
}
Also used : TSnowflakeRowProperties(org.talend.components.snowflake.tsnowflakerow.TSnowflakeRowProperties) Before(org.junit.Before)

Example 5 with TSnowflakeRowProperties

use of org.talend.components.snowflake.tsnowflakerow.TSnowflakeRowProperties in project components by Talend.

the class SnowflakeRowWriteOperationTest method testCreateWriter.

@Test
public void testCreateWriter() {
    TSnowflakeRowProperties properties = new TSnowflakeRowProperties("rowProperties");
    sink.initialize(null, properties);
    Writer<Result> writer = operation.createWriter(null);
    Assert.assertTrue(writer instanceof SnowflakeRowWriter);
}
Also used : TSnowflakeRowProperties(org.talend.components.snowflake.tsnowflakerow.TSnowflakeRowProperties) Result(org.talend.components.api.component.runtime.Result) Test(org.junit.Test)

Aggregations

TSnowflakeRowProperties (org.talend.components.snowflake.tsnowflakerow.TSnowflakeRowProperties)6 Before (org.junit.Before)4 Connection (java.sql.Connection)3 Test (org.junit.Test)2 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)2 ResultSet (java.sql.ResultSet)1 Schema (org.apache.avro.Schema)1 Result (org.talend.components.api.component.runtime.Result)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1