Search in sources :

Example 1 with SnowflakeTableProperties

use of org.talend.components.snowflake.SnowflakeTableProperties in project components by Talend.

the class SnowflakeRuntimeIT method setupTableWithStaticValues.

protected void setupTableWithStaticValues(SnowflakeConnectionTableProperties props) throws Throwable {
    Form f = props.table.getForm(Form.REFERENCE);
    SnowflakeTableProperties tableProps = (SnowflakeTableProperties) f.getProperties();
    tableProps.tableName.setValue(testTable);
    Schema mainSchema = getMakeRowSchema();
    tableProps.main.schema.setValue(mainSchema);
    Form schemaForm = tableProps.main.getForm(Form.REFERENCE);
    PropertiesTestUtils.checkAndAfter(getComponentService(), schemaForm, tableProps.main.schema.getName(), tableProps.main);
}
Also used : Form(org.talend.daikon.properties.presentation.Form) Schema(org.apache.avro.Schema) SnowflakeTableProperties(org.talend.components.snowflake.SnowflakeTableProperties)

Example 2 with SnowflakeTableProperties

use of org.talend.components.snowflake.SnowflakeTableProperties in project components by Talend.

the class SnowflakeWritersTestIT method testOutputBadConnection.

@Test
public void testOutputBadConnection() throws Throwable {
    TSnowflakeOutputProperties outputProps = (TSnowflakeOutputProperties) getComponentService().getComponentProperties(TSnowflakeOutputDefinition.COMPONENT_NAME);
    // No connection information
    SnowflakeTableProperties tableProps = outputProps.table;
    Form f = tableProps.getForm(Form.REFERENCE);
    tableProps.tableName.setValue("BADONE");
    tableProps = (SnowflakeTableProperties) PropertiesTestUtils.checkAndAfter(getComponentService(), f, tableProps.tableName.getName(), tableProps);
    LOGGER.info(String.valueOf(tableProps.getValidationResult()));
    assertEquals(ValidationResult.Result.ERROR, tableProps.getValidationResult().getStatus());
    assertThat(tableProps.getValidationResult().getMessage(), containsString("Missing account"));
}
Also used : TSnowflakeOutputProperties(org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties) Form(org.talend.daikon.properties.presentation.Form) SnowflakeTableProperties(org.talend.components.snowflake.SnowflakeTableProperties) Test(org.junit.Test)

Example 3 with SnowflakeTableProperties

use of org.talend.components.snowflake.SnowflakeTableProperties in project components by Talend.

the class SpringSnowflakeTestIT method testWizard.

@Test
public void testWizard() throws Throwable {
    final List<RepoProps> repoProps = new ArrayList<>();
    Repository repo = new TestRepository(repoProps);
    getComponentService().setRepository(repo);
    Set<ComponentWizardDefinition> wizards = getComponentService().getTopLevelComponentWizards();
    int connectionWizardNumber = 0;
    ComponentWizardDefinition wizardDef = null;
    for (ComponentWizardDefinition wizardDefinition : wizards) {
        if (wizardDefinition instanceof SnowflakeConnectionWizardDefinition) {
            wizardDef = wizardDefinition;
            connectionWizardNumber++;
        }
    }
    assertEquals(1, connectionWizardNumber);
    assertEquals("Snowflake Connection", wizardDef.getMenuItemName());
    ComponentWizard connectionWizard = getComponentService().getComponentWizard(SnowflakeConnectionWizardDefinition.COMPONENT_WIZARD_NAME, "nodeSnowflake");
    assertNotNull(connectionWizard);
    assertEquals("nodeSnowflake", connectionWizard.getRepositoryLocation());
    List<Form> forms = connectionWizard.getForms();
    Form connFormWizard = forms.get(0);
    assertEquals("Wizard", connFormWizard.getName());
    assertFalse(connFormWizard.isAllowBack());
    assertFalse(connFormWizard.isAllowForward());
    assertFalse(connFormWizard.isAllowFinish());
    // Main from SnowflakeTableListProperties
    assertEquals("Main", forms.get(1).getName());
    assertEquals("Snowflake Connection Settings", connFormWizard.getTitle());
    assertEquals("Complete these fields in order to connect to your Snowflake account.", connFormWizard.getSubtitle());
    SnowflakeConnectionProperties connProps = (SnowflakeConnectionProperties) connFormWizard.getProperties();
    Form advancedForm = connProps.getForm(Form.ADVANCED);
    assertTrue(((PresentationItem) connFormWizard.getWidget("advanced").getContent()).getFormtoShow() + " should be == to " + advancedForm, ((PresentationItem) connFormWizard.getWidget("advanced").getContent()).getFormtoShow() == advancedForm);
    assertEquals("Name", connProps.getProperty("name").getDisplayName());
    connProps.name.setValue("connName");
    setupProps(connProps);
    Form userPassword = (Form) connFormWizard.getWidget("userPassword").getContent();
    Property passwordSe = (Property) userPassword.getWidget("password").getContent();
    assertEquals("Password", passwordSe.getDisplayName());
    // $NON-NLS-1$
    NamedThing nameProp = connFormWizard.getWidget("name").getContent();
    assertEquals("Name", nameProp.getDisplayName());
    PropertiesTestUtils.checkAndValidate(getComponentService(), connFormWizard, "testConnection", connProps);
    assertTrue(connFormWizard.isAllowForward());
    Form modForm = forms.get(1);
    SnowflakeTableListProperties mlProps = (SnowflakeTableListProperties) modForm.getProperties();
    assertFalse(modForm.isCallAfterFormBack());
    assertFalse(modForm.isCallAfterFormNext());
    assertTrue(modForm.isCallAfterFormFinish());
    assertTrue(modForm.isCallBeforeFormPresent());
    assertFalse(modForm.isAllowBack());
    assertFalse(modForm.isAllowForward());
    assertFalse(modForm.isAllowFinish());
    mlProps = (SnowflakeTableListProperties) getComponentService().beforeFormPresent(modForm.getName(), mlProps);
    assertTrue(modForm.isAllowBack());
    assertFalse(modForm.isAllowForward());
    assertTrue(modForm.isAllowFinish());
    List<NamedThing> all = mlProps.selectedTableNames.getValue();
    assertNull(all);
    List<NamedThing> possibleValues = (List<NamedThing>) mlProps.selectedTableNames.getPossibleValues();
    LOGGER.info("possibleValues: " + possibleValues);
    assertEquals(1, possibleValues.size());
    List<NamedThing> selected = new ArrayList<>();
    selected.add(possibleValues.get(0));
    mlProps.selectedTableNames.setValue(selected);
    getComponentService().afterFormFinish(modForm.getName(), mlProps);
    LOGGER.debug(repoProps.toString());
    assertEquals(2, repoProps.size());
    int i = 0;
    for (RepoProps rp : repoProps) {
        if (i == 0) {
            assertEquals("connName", rp.name);
            SnowflakeConnectionProperties storedConnProps = (SnowflakeConnectionProperties) rp.props;
            assertEquals(USER, storedConnProps.userPassword.userId.getValue());
            assertEquals(PASSWORD, storedConnProps.userPassword.password.getValue());
        } else {
            SnowflakeTableProperties storedModule = (SnowflakeTableProperties) rp.props;
            assertEquals(selected.get(i - 1).getName(), storedModule.tableName.getValue());
            assertTrue(rp.schema.getFields().size() == NUM_COLUMNS);
            assertThat(storedModule.main.schema.getStringValue(), Matchers.is(rp.schema.toString()));
        }
        i++;
    }
}
Also used : PresentationItem(org.talend.daikon.properties.PresentationItem) Form(org.talend.daikon.properties.presentation.Form) ArrayList(java.util.ArrayList) SnowflakeConnectionProperties(org.talend.components.snowflake.SnowflakeConnectionProperties) NamedThing(org.talend.daikon.NamedThing) SnowflakeTableListProperties(org.talend.components.snowflake.SnowflakeTableListProperties) Repository(org.talend.daikon.properties.service.Repository) SnowflakeConnectionWizardDefinition(org.talend.components.snowflake.SnowflakeConnectionWizardDefinition) ComponentWizard(org.talend.components.api.wizard.ComponentWizard) ComponentWizardDefinition(org.talend.components.api.wizard.ComponentWizardDefinition) ArrayList(java.util.ArrayList) List(java.util.List) SnowflakeTableProperties(org.talend.components.snowflake.SnowflakeTableProperties) Property(org.talend.daikon.properties.property.Property) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with SnowflakeTableProperties

use of org.talend.components.snowflake.SnowflakeTableProperties 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);
}
Also used : Form(org.talend.daikon.properties.presentation.Form) Schema(org.apache.avro.Schema) SnowflakeTableProperties(org.talend.components.snowflake.SnowflakeTableProperties) TSnowflakeInputProperties(org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties) Test(org.junit.Test)

Example 5 with SnowflakeTableProperties

use of org.talend.components.snowflake.SnowflakeTableProperties in project components by Talend.

the class SnowflakeRuntimeIT method checkAndSetupTable.

protected void checkAndSetupTable(SnowflakeConnectionTableProperties props) throws Throwable {
    assertEquals(2, props.getForms().size());
    Form f = props.table.getForm(Form.REFERENCE);
    SnowflakeTableProperties tableProps = (SnowflakeTableProperties) f.getProperties();
    assertTrue(f.getWidget(tableProps.tableName.getName()).isCallBeforeActivate());
    tableProps = (SnowflakeTableProperties) PropertiesTestUtils.checkAndBeforeActivate(getComponentService(), f, tableProps.tableName.getName(), tableProps);
    Property prop = (Property) f.getWidget(tableProps.tableName.getName()).getContent();
    LOGGER.debug(prop.getPossibleValues().toString());
    LOGGER.debug(tableProps.getValidationResult().toString());
    assertEquals(ValidationResult.Result.OK, tableProps.getValidationResult().getStatus());
    assertEquals(1, prop.getPossibleValues().size());
    tableProps.tableName.setValue(testTable);
    tableProps = (SnowflakeTableProperties) PropertiesTestUtils.checkAndAfter(getComponentService(), f, tableProps.tableName.getName(), tableProps);
    Form schemaForm = tableProps.main.getForm(Form.REFERENCE);
    PropertiesTestUtils.checkAndAfter(getComponentService(), schemaForm, tableProps.main.schema.getName(), tableProps.main);
    Schema schema = tableProps.main.schema.getValue();
    LOGGER.debug(schema.toString());
    for (Schema.Field child : schema.getFields()) {
        LOGGER.debug(child.name());
    }
    assertEquals(NUM_COLUMNS, schema.getFields().size());
}
Also used : Form(org.talend.daikon.properties.presentation.Form) Schema(org.apache.avro.Schema) SnowflakeTableProperties(org.talend.components.snowflake.SnowflakeTableProperties) Property(org.talend.daikon.properties.property.Property)

Aggregations

SnowflakeTableProperties (org.talend.components.snowflake.SnowflakeTableProperties)6 Form (org.talend.daikon.properties.presentation.Form)6 Test (org.junit.Test)4 Schema (org.apache.avro.Schema)3 TSnowflakeOutputProperties (org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties)2 Property (org.talend.daikon.properties.property.Property)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 ComponentWizard (org.talend.components.api.wizard.ComponentWizard)1 ComponentWizardDefinition (org.talend.components.api.wizard.ComponentWizardDefinition)1 SnowflakeConnectionProperties (org.talend.components.snowflake.SnowflakeConnectionProperties)1 SnowflakeConnectionWizardDefinition (org.talend.components.snowflake.SnowflakeConnectionWizardDefinition)1 SnowflakeTableListProperties (org.talend.components.snowflake.SnowflakeTableListProperties)1 TSnowflakeInputProperties (org.talend.components.snowflake.tsnowflakeinput.TSnowflakeInputProperties)1 NamedThing (org.talend.daikon.NamedThing)1 PresentationItem (org.talend.daikon.properties.PresentationItem)1 Repository (org.talend.daikon.properties.service.Repository)1