Search in sources :

Example 11 with JDBCDatastoreProperties

use of org.talend.components.jdbc.datastore.JDBCDatastoreProperties in project components by Talend.

the class JdbcComponentTestIT method initializeJDBCDatasetProperties.

@Test
public void initializeJDBCDatasetProperties() throws java.io.IOException {
    // given
    SerPropertiesDto propDto = new SerPropertiesDto();
    propDto.setProperties(new JDBCDatasetProperties("").init().toSerialized());
    propDto.setDependencies(singletonList(new JDBCDatastoreProperties("").init().toSerialized()));
    // when
    Response response = // 
    given().content(propDto).contentType(ServiceConstants.JSONIO_CONTENT_TYPE).accept(// 
    ServiceConstants.UI_SPEC_CONTENT_TYPE).expect().statusCode(200).log().ifError().post(getVersionPrefix() + "/properties/uispec");
    // then
    ObjectNode jdbcProperties = mapper.readerFor(ObjectNode.class).readValue(response.asInputStream());
    assertNotNull(jdbcProperties.get("jsonSchema"));
    assertNotNull(jdbcProperties.get("properties"));
    assertNotNull(jdbcProperties.get("uiSchema"));
    assertEquals("JDBCDataset", jdbcProperties.get("properties").get("@definitionName").textValue());
}
Also used : Response(com.jayway.restassured.response.Response) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties) SerPropertiesDto(org.talend.components.service.rest.dto.SerPropertiesDto) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with JDBCDatastoreProperties

use of org.talend.components.jdbc.datastore.JDBCDatastoreProperties in project components by Talend.

the class JDBCOutputProperties method getRuntimeSetting.

@Override
public AllSetting getRuntimeSetting() {
    // TODO only return the Driver paths is enough to get the getRuntimeInfo works, AllSetting should be removed
    // after refactor
    AllSetting setting = new AllSetting();
    JDBCDatasetProperties datasetProperties = this.getDatasetProperties();
    JDBCDatastoreProperties datastoreProperties = datasetProperties.getDatastoreProperties();
    setting.setDriverPaths(datastoreProperties.getCurrentDriverPaths());
    setting.setDriverClass(datastoreProperties.getCurrentDriverClass());
    setting.setJdbcUrl(datastoreProperties.jdbcUrl.getValue());
    setting.setUsername(datastoreProperties.userId.getValue());
    setting.setPassword(datastoreProperties.password.getValue());
    return setting;
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties)

Example 13 with JDBCDatastoreProperties

use of org.talend.components.jdbc.datastore.JDBCDatastoreProperties in project components by Talend.

the class JdbcDatasetRuntimeTest method createDatasetProperties.

/**
 * @return the properties for this dataset, fully initialized with the default values.
 */
public static JDBCDatasetProperties createDatasetProperties() {
    JDBCDatastoreProperties jdbcDatastoreProperties;
    jdbcDatastoreProperties = new JDBCDatastoreProperties("datastore");
    jdbcDatastoreProperties.init();
    jdbcDatastoreProperties.dbTypes.setValue("DERBY");
    jdbcDatastoreProperties.jdbcUrl.setValue(JDBC_URL);
    JDBCDatasetProperties inputDatasetProperties = new JDBCDatasetProperties("inputDataset");
    inputDatasetProperties.init();
    inputDatasetProperties.setDatastoreProperties(jdbcDatastoreProperties);
    inputDatasetProperties.sql.setValue("select * from " + TABLE_IN);
    return inputDatasetProperties;
}
Also used : JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties)

Example 14 with JDBCDatastoreProperties

use of org.talend.components.jdbc.datastore.JDBCDatastoreProperties in project components by Talend.

the class JdbcDatasetTestIT method createDatasetProperties.

private JDBCDatasetProperties createDatasetProperties(boolean updateSchema) {
    JDBCDatastoreDefinition def = new JDBCDatastoreDefinition();
    JDBCDatastoreProperties datastore = new JDBCDatastoreProperties("datastore");
    datastore.dbTypes.setValue("DERBY");
    datastore.afterDbTypes();
    datastore.jdbcUrl.setValue(allSetting.getJdbcUrl());
    datastore.userId.setValue(allSetting.getUsername());
    datastore.password.setValue(allSetting.getPassword());
    JDBCDatasetProperties dataset = (JDBCDatasetProperties) def.createDatasetProperties(datastore);
    dataset.sql.setValue(DBTestUtils.getSQL(tablename));
    if (updateSchema) {
        dataset.updateSchema();
    }
    return dataset;
}
Also used : JDBCDatastoreDefinition(org.talend.components.jdbc.datastore.JDBCDatastoreDefinition) JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties)

Example 15 with JDBCDatastoreProperties

use of org.talend.components.jdbc.datastore.JDBCDatastoreProperties in project components by Talend.

the class JDBCOutputPropertiesTest method testGetRuntimeSetting.

@Test
public void testGetRuntimeSetting() {
    JDBCOutputProperties fixture = new JDBCOutputProperties("output");
    JDBCDatasetProperties dataset = new JDBCDatasetProperties("dataset");
    JDBCDatastoreProperties datastore = new JDBCDatastoreProperties("datastore");
    datastore.init();
    dataset.setDatastoreProperties(datastore);
    fixture.setDatasetProperties(dataset);
    AllSetting result = fixture.getRuntimeSetting();
    assertNotNull(result);
}
Also used : AllSetting(org.talend.components.jdbc.runtime.setting.AllSetting) JDBCDatasetProperties(org.talend.components.jdbc.dataset.JDBCDatasetProperties) JDBCDatastoreProperties(org.talend.components.jdbc.datastore.JDBCDatastoreProperties) Test(org.junit.Test)

Aggregations

JDBCDatastoreProperties (org.talend.components.jdbc.datastore.JDBCDatastoreProperties)16 JDBCDatasetProperties (org.talend.components.jdbc.dataset.JDBCDatasetProperties)12 Test (org.junit.Test)7 AllSetting (org.talend.components.jdbc.runtime.setting.AllSetting)6 JDBCDatastoreDefinition (org.talend.components.jdbc.datastore.JDBCDatastoreDefinition)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Response (com.jayway.restassured.response.Response)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 SerPropertiesDto (org.talend.components.service.rest.dto.SerPropertiesDto)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 HashMap (java.util.HashMap)1 Schema (org.apache.avro.Schema)1 PipelineResult (org.apache.beam.sdk.PipelineResult)1 JDBCInputProperties (org.talend.components.jdbc.dataprep.JDBCInputProperties)1 JDBCOutputProperties (org.talend.components.jdbc.datastream.JDBCOutputProperties)1