Search in sources :

Example 71 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class BigQueryDatasetProperties method beforeBqDataset.

public ValidationResult beforeBqDataset() {
    BigQueryDatasetDefinition definition = new BigQueryDatasetDefinition();
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
    try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
        IBigQueryDatasetRuntime runtime = (IBigQueryDatasetRuntime) sandboxedInstance.getInstance();
        runtime.initialize(null, this);
        List<NamedThing> datasets = new ArrayList<>();
        for (String dataset : runtime.listDatasets()) {
            datasets.add(new SimpleNamedThing(dataset, dataset));
        }
        bqDataset.setPossibleValues(datasets);
        return ValidationResult.OK;
    } catch (Exception e) {
        return new ValidationResult(new ComponentException(e));
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) IBigQueryDatasetRuntime(org.talend.components.bigquery.runtime.IBigQueryDatasetRuntime) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) ComponentException(org.talend.components.api.exception.ComponentException) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ValidationResult(org.talend.daikon.properties.ValidationResult) ComponentException(org.talend.components.api.exception.ComponentException) TalendRuntimeException(org.talend.daikon.exception.TalendRuntimeException)

Example 72 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class BigQueryDatasetProperties method beforeTableName.

public void beforeTableName() {
    BigQueryDatasetDefinition definition = new BigQueryDatasetDefinition();
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
    try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
        IBigQueryDatasetRuntime runtime = (IBigQueryDatasetRuntime) sandboxedInstance.getInstance();
        runtime.initialize(null, this);
        List<NamedThing> tables = new ArrayList<>();
        for (String table : runtime.listTables()) {
            tables.add(new SimpleNamedThing(table, table));
        }
        this.tableName.setPossibleValues(tables);
    } catch (Exception e) {
        TalendRuntimeException.build(CommonErrorCodes.UNEXPECTED_EXCEPTION).setAndThrow(e.getMessage());
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) IBigQueryDatasetRuntime(org.talend.components.bigquery.runtime.IBigQueryDatasetRuntime) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ComponentException(org.talend.components.api.exception.ComponentException) TalendRuntimeException(org.talend.daikon.exception.TalendRuntimeException)

Example 73 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class CouchbaseOutputDefinitionTest method testGetRuntimeInfo.

@Test
public void testGetRuntimeInfo() {
    RuntimeInfo runtime = definition.getRuntimeInfo(ExecutionEngine.DI, null, ConnectorTopology.INCOMING);
    Assert.assertEquals(CouchbaseSink.class.getCanonicalName(), runtime.getRuntimeClassName());
}
Also used : RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) CouchbaseSink(org.talend.components.couchbase.runtime.CouchbaseSink) Test(org.junit.Test)

Example 74 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class ElasticsearchDatastoreTestIT method testBasic.

@Test
public void testBasic() throws Exception {
    ElasticsearchDatastoreProperties props = createDatastoreProperties();
    RuntimeInfo ri = def.getRuntimeInfo(props);
    try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
        DatastoreRuntime runtime = (DatastoreRuntime) si.getInstance();
        runtime.initialize(null, props);
        assertThat(runtime, not(nullValue()));
        Iterator iterator = runtime.doHealthChecks(null).iterator();
        assertTrue(iterator.hasNext());
        assertEquals(ValidationResult.OK, iterator.next());
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) DatastoreRuntime(org.talend.components.common.datastore.runtime.DatastoreRuntime) Iterator(java.util.Iterator) ElasticsearchDatastoreProperties(org.talend.components.elasticsearch.ElasticsearchDatastoreProperties) Test(org.junit.Test)

Example 75 with RuntimeInfo

use of org.talend.daikon.runtime.RuntimeInfo in project components by Talend.

the class BigQueryDatastoreDefinitionTest method testRuntimeInfo.

/**
 * Check {@link BigQueryDatastoreDefinition#getRuntimeInfo(BigQueryDatastoreProperties) returns RuntimeInfo,
 * which runtime class name is "org.talend.components.bigquery.runtime.BigQueryDatastoreRuntime"
 */
@Test
@Ignore("This can't work unless the runtime jar is already installed in maven!")
public void testRuntimeInfo() {
    RuntimeInfo runtimeInfo = datastoreDefinition.getRuntimeInfo(null);
    assertEquals("org.talend.components.bigquery.runtime.BigQueryDatastoreRuntime", runtimeInfo.getRuntimeClassName());
}
Also used : RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)131 Test (org.junit.Test)120 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)27 Ignore (org.junit.Ignore)21 JarRuntimeInfo (org.talend.components.api.component.runtime.JarRuntimeInfo)17 ArrayList (java.util.ArrayList)13 AllSetting (org.talend.components.jdbc.runtime.setting.AllSetting)11 IndexedRecord (org.apache.avro.generic.IndexedRecord)8 ExecutionEngine (org.talend.components.api.component.runtime.ExecutionEngine)8 DatasetRuntime (org.talend.components.common.dataset.runtime.DatasetRuntime)7 URL (java.net.URL)6 Schema (org.apache.avro.Schema)6 ComponentException (org.talend.components.api.exception.ComponentException)5 ValidationResult (org.talend.daikon.properties.ValidationResult)5 File (java.io.File)3 NamedThing (org.talend.daikon.NamedThing)3 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)3 TalendRuntimeException (org.talend.daikon.exception.TalendRuntimeException)3 FileWriter (java.io.FileWriter)2 GenericRecord (org.apache.avro.generic.GenericRecord)2