use of org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties in project components by Talend.
the class SnowflakeReadersTestIT method testInputConnectionRef.
@Test
public void testInputConnectionRef() throws Throwable {
TSnowflakeInputProperties props = (TSnowflakeInputProperties) getComponentService().getComponentProperties(TSnowflakeInputDefinition.COMPONENT_NAME);
setupProps(props.connection);
SnowflakeSourceOrSink SnowflakeSourceOrSink = new SnowflakeSourceOrSink();
SnowflakeSourceOrSink.initialize(null, props);
assertEquals(ValidationResult.Result.OK, SnowflakeSourceOrSink.validate(null).getStatus());
// Referenced properties simulating Snowflake connect component
SnowflakeConnectionProperties cProps = (SnowflakeConnectionProperties) getComponentService().getComponentProperties(TSnowflakeConnectionDefinition.COMPONENT_NAME);
setupProps(cProps);
cProps.userPassword.password.setValue("xxx");
String compId = "comp1";
// Use the connection props of the Snowflake connect component
props.connection.referencedComponent.referenceType.setValue(ComponentReferenceProperties.ReferenceType.COMPONENT_INSTANCE);
props.connection.referencedComponent.componentInstanceId.setValue(compId);
props.connection.referencedComponent.setReference(cProps);
PropertiesTestUtils.checkAndAfter(getComponentService(), props.connection.getForm(Form.REFERENCE), "referencedComponent", props.connection);
resetUser();
SnowflakeSourceOrSink = new SnowflakeSourceOrSink();
SnowflakeSourceOrSink.initialize(null, props);
SnowflakeSourceOrSink.validate(null);
assertEquals(ValidationResult.Result.ERROR, SnowflakeSourceOrSink.validate(null).getStatus());
resetUser();
setupProps(cProps);
setupTableWithStaticValues(props);
// Back to using the connection props of the Snowflake input component
props.connection.referencedComponent.referenceType.setValue(ComponentReferenceProperties.ReferenceType.THIS_COMPONENT);
props.connection.referencedComponent.componentInstanceId.setValue(null);
props.connection.referencedComponent.setReference(null);
// Check that the null referenced component works.
PropertiesTestUtils.checkAndAfter(getComponentService(), props.connection.getForm(Form.REFERENCE), "referencedComponent", props.connection);
resetUser();
SnowflakeSourceOrSink = new SnowflakeSourceOrSink();
SnowflakeSourceOrSink.initialize(null, props);
ValidationResult result = SnowflakeSourceOrSink.validate(null);
LOGGER.info(String.valueOf(result));
assertEquals(ValidationResult.Result.OK, result.getStatus());
}
use of org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties in project components by Talend.
the class SnowflakeReadersTestIT method testInputManual.
@Test
public void testInputManual() 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("select ID, C7 from " + testTable + " where ID > 80");
setupTableWithStaticValues(props);
List<IndexedRecord> rows = readRows(props);
assertEquals(19, rows.size());
Schema schema = rows.get(0).getSchema();
LOGGER.debug(schema.toString());
assertEquals(BigDecimal.valueOf(81), rows.get(0).get(0));
assertThat((String) rows.get(0).get(1), containsString("\"bar\": 81"));
}
use of org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties in project components by Talend.
the class SnowflakeSourceTest method setup.
@Before
public void setup() {
source = new SnowflakeSource();
source.initialize(null, new TSnowflakeInputProperties("inputProperties"));
}
use of org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties in project components by Talend.
the class SnowflakeReadersTestIT method testUseExistingConnection.
@Test
public void testUseExistingConnection() throws Throwable {
SnowflakeConnectionProperties connProps = (SnowflakeConnectionProperties) getComponentService().getComponentProperties(TSnowflakeConnectionDefinition.COMPONENT_NAME);
setupProps(connProps);
final String currentComponentName = TSnowflakeConnectionDefinition.COMPONENT_NAME + "_1";
RuntimeContainer connContainer = new DefaultComponentRuntimeContainerImpl() {
@Override
public String getCurrentComponentId() {
return currentComponentName;
}
};
SnowflakeSourceOrSink SnowflakeSourceOrSink = new SnowflakeSourceOrSink();
SnowflakeSourceOrSink.initialize(connContainer, connProps);
assertEquals(ValidationResult.Result.OK, SnowflakeSourceOrSink.validate(connContainer).getStatus());
// Input component get connection from the tSnowflakeConnection
TSnowflakeInputProperties inProps = (TSnowflakeInputProperties) getComponentService().getComponentProperties(TSnowflakeInputDefinition.COMPONENT_NAME);
inProps.connection.referencedComponent.componentInstanceId.setValue(currentComponentName);
SnowflakeSourceOrSink SnowflakeInputSourceOrSink = new SnowflakeSourceOrSink();
SnowflakeInputSourceOrSink.initialize(connContainer, inProps);
assertEquals(ValidationResult.Result.OK, SnowflakeInputSourceOrSink.validate(connContainer).getStatus());
}
use of org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties in project components by Talend.
the class SnowflakeReadersTestIT method testInputSchema.
@Test
public void testInputSchema() throws Throwable {
TSnowflakeInputProperties props = (TSnowflakeInputProperties) getComponentService().getComponentProperties(TSnowflakeInputDefinition.COMPONENT_NAME);
setupProps(props.connection);
Form f = props.table.getForm(Form.REFERENCE);
SnowflakeTableProperties moduleProps = (SnowflakeTableProperties) f.getProperties();
moduleProps = (SnowflakeTableProperties) PropertiesTestUtils.checkAndBeforeActivate(getComponentService(), f, moduleProps.tableName.getName(), moduleProps);
moduleProps.tableName.setValue(testTable);
moduleProps = (SnowflakeTableProperties) PropertiesTestUtils.checkAndAfter(getComponentService(), f, moduleProps.tableName.getName(), moduleProps);
Schema schema = moduleProps.main.schema.getValue();
LOGGER.debug(schema.toString());
for (Schema.Field child : schema.getFields()) {
LOGGER.debug(child.name());
}
assertEquals("ID", schema.getFields().get(0).name());
LOGGER.debug("Table \"" + testTable + "\" column size:" + schema.getFields().size());
assertTrue(schema.getFields().size() == NUM_COLUMNS);
}
Aggregations