Search in sources :

Example 1 with Repository

use of org.talend.daikon.properties.service.Repository in project components by Talend.

the class SalesforceComponentTestIT 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 connectionWizardDefinitionNumber = 0;
    ComponentWizardDefinition wizardDef = null;
    for (ComponentWizardDefinition wizardDefinition : wizards) {
        if (wizardDefinition instanceof SalesforceConnectionWizardDefinition) {
            wizardDef = wizardDefinition;
            connectionWizardDefinitionNumber++;
        }
    }
    assertEquals(1, connectionWizardDefinitionNumber);
    assertEquals("Salesforce Connection", wizardDef.getMenuItemName());
    ComponentWizard connectionWizard = getComponentService().getComponentWizard(SalesforceConnectionWizardDefinition.COMPONENT_WIZARD_NAME, "nodeSalesforce");
    assertNotNull(connectionWizard);
    assertEquals("nodeSalesforce", 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 SalesforceModuleListProperties
    assertEquals("Main", forms.get(1).getName());
    assertEquals("Salesforce Connection Settings", connFormWizard.getTitle());
    assertEquals("Complete these fields in order to connect to your Salesforce account.", connFormWizard.getSubtitle());
    SalesforceConnectionProperties connProps = (SalesforceConnectionProperties) 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);
    Object image = getComponentService().getWizardPngImage(SalesforceConnectionWizardDefinition.COMPONENT_WIZARD_NAME, WizardImageType.TREE_ICON_16X16);
    assertNotNull(image);
    image = getComponentService().getWizardPngImage(SalesforceConnectionWizardDefinition.COMPONENT_WIZARD_NAME, WizardImageType.WIZARD_BANNER_75X66);
    assertNotNull(image);
    // Check the non-top-level wizard
    // check password i18n
    assertEquals("Name", connProps.getProperty("name").getDisplayName());
    connProps.name.setValue("connName");
    setupProps(connProps, !ADD_QUOTES);
    Form userPassword = (Form) connFormWizard.getWidget("userPassword").getContent();
    Property passwordSe = (Property) userPassword.getWidget("password").getContent();
    assertEquals("Password", passwordSe.getDisplayName());
    // check name i18n
    // $NON-NLS-1$
    NamedThing nameProp = connFormWizard.getWidget("name").getContent();
    assertEquals("Name", nameProp.getDisplayName());
    connProps = (SalesforceConnectionProperties) PropertiesTestUtils.checkAndValidate(getComponentService(), connFormWizard, "testConnection", connProps);
    assertTrue(connFormWizard.isAllowForward());
    Form modForm = forms.get(1);
    SalesforceModuleListProperties mlProps = (SalesforceModuleListProperties) modForm.getProperties();
    assertFalse(modForm.isCallAfterFormBack());
    assertFalse(modForm.isCallAfterFormNext());
    assertTrue(modForm.isCallAfterFormFinish());
    assertTrue(modForm.isCallBeforeFormPresent());
    assertFalse(modForm.isAllowBack());
    assertFalse(modForm.isAllowForward());
    assertFalse(modForm.isAllowFinish());
    mlProps = (SalesforceModuleListProperties) getComponentService().beforeFormPresent(modForm.getName(), mlProps);
    assertTrue(modForm.isAllowBack());
    assertFalse(modForm.isAllowForward());
    assertTrue(modForm.isAllowFinish());
    @SuppressWarnings("unchecked") List<NamedThing> all = mlProps.selectedModuleNames.getValue();
    assertNull(all);
    // TCOMP-9 Change the module list to use getPossibleValues() for SalesforceModuleListProperties
    List<NamedThing> possibleValues = (List<NamedThing>) mlProps.selectedModuleNames.getPossibleValues();
    assertTrue(possibleValues.size() > 50);
    List<NamedThing> selected = new ArrayList<>();
    selected.add(possibleValues.get(0));
    selected.add(possibleValues.get(2));
    selected.add(possibleValues.get(3));
    mlProps.selectedModuleNames.setValue(selected);
    getComponentService().afterFormFinish(modForm.getName(), mlProps);
    LOGGER.debug(repoProps.toString());
    assertEquals(4, repoProps.size());
    int i = 0;
    for (RepoProps rp : repoProps) {
        if (i == 0) {
            assertEquals("connName", rp.name);
            SalesforceConnectionProperties storedConnProps = (SalesforceConnectionProperties) rp.props;
            assertEquals(userId, storedConnProps.userPassword.userId.getValue());
            assertEquals(password, storedConnProps.userPassword.password.getValue());
        } else {
            SalesforceModuleProperties storedModule = (SalesforceModuleProperties) rp.props;
            assertEquals(selected.get(i - 1).getName(), storedModule.moduleName.getValue());
            assertTrue(rp.schema.getFields().size() > 10);
            assertThat(storedModule.main.schema.getStringValue(), is(rp.schema.toString()));
        }
        i++;
    }
}
Also used : SalesforceConnectionProperties(org.talend.components.salesforce.SalesforceConnectionProperties) PresentationItem(org.talend.daikon.properties.PresentationItem) Form(org.talend.daikon.properties.presentation.Form) ArrayList(java.util.ArrayList) NamedThing(org.talend.daikon.NamedThing) SalesforceConnectionWizardDefinition(org.talend.components.salesforce.SalesforceConnectionWizardDefinition) SalesforceModuleProperties(org.talend.components.salesforce.SalesforceModuleProperties) Repository(org.talend.daikon.properties.service.Repository) ComponentWizard(org.talend.components.api.wizard.ComponentWizard) SalesforceModuleListProperties(org.talend.components.salesforce.SalesforceModuleListProperties) ComponentWizardDefinition(org.talend.components.api.wizard.ComponentWizardDefinition) List(java.util.List) ArrayList(java.util.ArrayList) Property(org.talend.daikon.properties.property.Property) Test(org.junit.Test)

Example 2 with Repository

use of org.talend.daikon.properties.service.Repository 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 3 with Repository

use of org.talend.daikon.properties.service.Repository in project components by Talend.

the class AzureStorageConnectionWizardTest 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 count = 0;
    ComponentWizardDefinition wizardDef = null;
    for (ComponentWizardDefinition wizardDefinition : wizards) {
        if (wizardDefinition instanceof AzureStorageConnectionWizardDefinition) {
            wizardDef = wizardDefinition;
            count++;
        }
    }
    assertEquals(1, count);
    assertEquals("Create an Azure Storage Connection", wizardDef.getMenuItemName());
    ComponentWizard wiz = getComponentService().getComponentWizard(AzureStorageConnectionWizardDefinition.COMPONENT_WIZARD_NAME, "nodeAzureStorage");
    assertNotNull(wiz);
    assertEquals("nodeAzureStorage", wiz.getRepositoryLocation());
    List<Form> forms = wiz.getForms();
    Form connFormWizard = forms.get(0);
    assertEquals("Wizard", connFormWizard.getName());
    assertFalse(connFormWizard.isAllowBack());
    assertFalse(connFormWizard.isAllowForward());
    assertFalse(connFormWizard.isAllowFinish());
    // Main from SalesforceModuleListProperties
    assertEquals("Container", forms.get(1).getName());
    assertEquals("Queue", forms.get(2).getName());
    assertEquals("Table", forms.get(3).getName());
    assertEquals("Azure Storage Connection Settings", connFormWizard.getTitle());
    assertEquals("Fill in fields to configure connection.", connFormWizard.getSubtitle());
    TAzureStorageConnectionProperties connProps = (TAzureStorageConnectionProperties) connFormWizard.getProperties();
    connProps.setupProperties();
    Object image = getComponentService().getWizardPngImage(AzureStorageConnectionWizardDefinition.COMPONENT_WIZARD_NAME, WizardImageType.TREE_ICON_16X16);
    assertNotNull(image);
    image = getComponentService().getWizardPngImage(AzureStorageConnectionWizardDefinition.COMPONENT_WIZARD_NAME, WizardImageType.WIZARD_BANNER_75X66);
    assertNotNull(image);
    // Check the non-top-level wizard
    // check password i18n
    assertEquals("Name", connProps.getProperty("name").getDisplayName());
    connProps.name.setValue("connName");
    connProps.accountName.setValue("demo");
    connProps.accountKey.setValue("demo");
    // check name i18n
    // $NON-NLS-1$
    NamedThing nameProp = connFormWizard.getWidget("name").getContent();
    assertEquals("Name", nameProp.getDisplayName());
    connProps = (TAzureStorageConnectionProperties) PropertiesTestUtils.checkAndValidate(getComponentService(), connFormWizard, "testConnection", connProps);
    assertFalse(connFormWizard.isAllowForward());
    Form modForm = forms.get(1);
}
Also used : Form(org.talend.daikon.properties.presentation.Form) ArrayList(java.util.ArrayList) TAzureStorageConnectionProperties(org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties) NamedThing(org.talend.daikon.NamedThing) Repository(org.talend.daikon.properties.service.Repository) ComponentWizard(org.talend.components.api.wizard.ComponentWizard) ComponentWizardDefinition(org.talend.components.api.wizard.ComponentWizardDefinition) Test(org.junit.Test)

Example 4 with Repository

use of org.talend.daikon.properties.service.Repository in project components by Talend.

the class FileDelimitedWizardTestIT 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 count = 0;
    ComponentWizardDefinition wizardDef = null;
    for (ComponentWizardDefinition wizardDefinition : wizards) {
        if (wizardDefinition instanceof FileDelimitedWizardDefinition) {
            wizardDef = wizardDefinition;
            count++;
        }
    }
    assertEquals(1, count);
    assertEquals("file delimited", wizardDef.getMenuItemName());
    ComponentWizard wiz = getComponentService().getComponentWizard(FileDelimitedWizardDefinition.COMPONENT_WIZARD_NAME, "nodeFileDelimited");
    assertNotNull(wiz);
    assertEquals("nodeFileDelimited", wiz.getRepositoryLocation());
    FileDelimitedWizard swiz = (FileDelimitedWizard) wiz;
    List<Form> forms = wiz.getForms();
    Form formWizard = forms.get(0);
    assertEquals("Wizard", formWizard.getName());
    assertFalse(formWizard.isAllowBack());
    assertFalse(formWizard.isAllowForward());
    assertFalse(formWizard.isAllowFinish());
    assertEquals("Delimited File Settings", formWizard.getTitle());
    assertEquals("", formWizard.getSubtitle());
    FileDelimitedProperties wizardProps = (FileDelimitedProperties) formWizard.getProperties();
    Object image = getComponentService().getWizardPngImage(FileDelimitedWizardDefinition.COMPONENT_WIZARD_NAME, WizardImageType.TREE_ICON_16X16);
    assertNotNull(image);
    image = getComponentService().getWizardPngImage(FileDelimitedWizardDefinition.COMPONENT_WIZARD_NAME, WizardImageType.WIZARD_BANNER_75X66);
    assertNotNull(image);
    // Check the non-top-level wizard
    assertEquals("Name", wizardProps.getProperty("name").getDisplayName());
    wizardProps.name.setValue("connName");
    setupProps(wizardProps);
    Form encodingForm = (Form) formWizard.getWidget("encoding").getContent();
    assertEquals("Main", encodingForm.getDisplayName());
    Property encodingType = (Property) encodingForm.getWidget("encodingType").getContent();
    assertEquals("Encoding", encodingType.getDisplayName());
    assertFalse(formWizard.getWidget(wizardProps.encoding.getName()).isHidden());
    assertFalse(encodingForm.getWidget(wizardProps.encoding.encodingType.getName()).isHidden());
    assertTrue(encodingForm.getWidget(wizardProps.encoding.customEncoding.getName()).isHidden());
    wizardProps.encoding.encodingType.setValue(EncodingTypeProperties.ENCODING_TYPE_CUSTOM);
    assertTrue(encodingForm.getWidget(wizardProps.encoding.encodingType.getName()).isCallAfter());
    getComponentService().afterProperty(wizardProps.encoding.encodingType.getName(), wizardProps.encoding);
    assertFalse(encodingForm.getWidget(wizardProps.encoding.customEncoding.getName()).isHidden());
    wizardProps.main.schema.setValue(BASIC_SCHEMA);
    ValidationResult result = wizardProps.afterFormFinishWizard(repo);
    assertEquals(ValidationResult.OK, result);
// TODO Continue when finish the wizard
}
Also used : Form(org.talend.daikon.properties.presentation.Form) ArrayList(java.util.ArrayList) ValidationResult(org.talend.daikon.properties.ValidationResult) Repository(org.talend.daikon.properties.service.Repository) ComponentWizard(org.talend.components.api.wizard.ComponentWizard) FileDelimitedProperties(org.talend.components.filedelimited.FileDelimitedProperties) ComponentWizardDefinition(org.talend.components.api.wizard.ComponentWizardDefinition) Property(org.talend.daikon.properties.property.Property) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 ComponentWizard (org.talend.components.api.wizard.ComponentWizard)4 ComponentWizardDefinition (org.talend.components.api.wizard.ComponentWizardDefinition)4 Form (org.talend.daikon.properties.presentation.Form)4 Repository (org.talend.daikon.properties.service.Repository)4 NamedThing (org.talend.daikon.NamedThing)3 Property (org.talend.daikon.properties.property.Property)3 List (java.util.List)2 PresentationItem (org.talend.daikon.properties.PresentationItem)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 TAzureStorageConnectionProperties (org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties)1 FileDelimitedProperties (org.talend.components.filedelimited.FileDelimitedProperties)1 SalesforceConnectionProperties (org.talend.components.salesforce.SalesforceConnectionProperties)1 SalesforceConnectionWizardDefinition (org.talend.components.salesforce.SalesforceConnectionWizardDefinition)1 SalesforceModuleListProperties (org.talend.components.salesforce.SalesforceModuleListProperties)1 SalesforceModuleProperties (org.talend.components.salesforce.SalesforceModuleProperties)1 SnowflakeConnectionProperties (org.talend.components.snowflake.SnowflakeConnectionProperties)1 SnowflakeConnectionWizardDefinition (org.talend.components.snowflake.SnowflakeConnectionWizardDefinition)1 SnowflakeTableListProperties (org.talend.components.snowflake.SnowflakeTableListProperties)1