Search in sources :

Example 1 with JDBCDatasetRuntime

use of org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime in project components by Talend.

the class JDBCDatasetTestIT method testGetSchema.

@Test
public void testGetSchema() {
    JDBCDatasetProperties dataset = createDatasetProperties(false);
    JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
    runtime.initialize(null, dataset);
    Schema schema = runtime.getSchema();
    Assert.assertNotNull(schema);
    DBTestUtils.testMetadata(schema.getFields(), true);
}
Also used : JDBCDatasetRuntime(org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime) Schema(org.apache.avro.Schema) JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) Test(org.junit.Test)

Example 2 with JDBCDatasetRuntime

use of org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime in project components by Talend.

the class JDBCDatasetOracleTestIT method getSampleAction.

private void getSampleAction(JDBCDatasetProperties dataset) {
    JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
    runtime.initialize(null, dataset);
    final IndexedRecord[] record = new IndexedRecord[1];
    Consumer<IndexedRecord> storeTheRecords = new Consumer<IndexedRecord>() {

        @Override
        public void accept(IndexedRecord data) {
            record[0] = data;
        }
    };
    runtime.getSample(1, storeTheRecords);
    Assert.assertEquals(new BigDecimal("1"), record[0].get(0));
    Assert.assertEquals("wangwei", record[0].get(1));
}
Also used : JDBCDatasetRuntime(org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime) IndexedRecord(org.apache.avro.generic.IndexedRecord) Consumer(org.talend.daikon.java8.Consumer) BigDecimal(java.math.BigDecimal)

Example 3 with JDBCDatasetRuntime

use of org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime in project components by Talend.

the class JDBCInputTestIT method updateSchema.

protected void updateSchema(JDBCDatasetProperties dataset) {
    JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
    runtime.initialize(null, dataset);
    dataset.main.schema.setValue(runtime.getSchema());
}
Also used : JDBCDatasetRuntime(org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime)

Example 4 with JDBCDatasetRuntime

use of org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime in project components by Talend.

the class JdbcDatasetTestIT method testGetSchema.

@Test
public void testGetSchema() {
    JDBCDatasetProperties dataset = createDatasetProperties(false);
    JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
    runtime.initialize(null, dataset);
    Schema schema = runtime.getSchema();
    Assert.assertNotNull(schema);
    DBTestUtils.testMetadata(schema.getFields(), true);
}
Also used : JDBCDatasetRuntime(org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime) Schema(org.apache.avro.Schema) JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) Test(org.junit.Test)

Example 5 with JDBCDatasetRuntime

use of org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime in project components by Talend.

the class JdbcDatasetTestIT method getSampleAction.

private void getSampleAction(JDBCDatasetProperties dataset) {
    JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
    runtime.initialize(null, dataset);
    final IndexedRecord[] record = new IndexedRecord[1];
    Consumer<IndexedRecord> storeTheRecords = new Consumer<IndexedRecord>() {

        @Override
        public void accept(IndexedRecord data) {
            record[0] = data;
        }
    };
    runtime.getSample(1, storeTheRecords);
    Assert.assertEquals("1", record[0].get(0));
    Assert.assertEquals("wangwei", record[0].get(1));
}
Also used : JDBCDatasetRuntime(org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime) IndexedRecord(org.apache.avro.generic.IndexedRecord) Consumer(org.talend.daikon.java8.Consumer)

Aggregations

JDBCDatasetRuntime (org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime)10 Schema (org.apache.avro.Schema)5 Test (org.junit.Test)4 JDBCDatasetProperties (org.talend.components.jdbc.dataset.JDBCDatasetProperties)4 IndexedRecord (org.apache.avro.generic.IndexedRecord)3 Consumer (org.talend.daikon.java8.Consumer)3 BigDecimal (java.math.BigDecimal)1 Ignore (org.junit.Ignore)1 JDBCSourceOrSink (org.talend.components.jdbc.runtime.JDBCSourceOrSink)1