package org.talend.components.salesforce.dataset;

import java.io.IOException;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.talend.components.salesforce.dataset.SalesforceDatasetProperties.SourceType;
import org.talend.components.salesforce.datastore.SalesforceDatastoreProperties;
import org.talend.components.salesforce.integration.SalesforceTestBase;

public class SalesforceDatasetPropertiesTestIT extends SalesforceTestBase {

    @Test
    public void testAfterSourceType() {
        SalesforceDatasetProperties dataset = new SalesforceDatasetProperties("dataset");
        dataset.init();
        
        SalesforceDatastoreProperties datastore = new SalesforceDatastoreProperties("datastore");
        datastore.init();
        
        dataset.setDatastoreProperties(datastore);
        
        datastore.userId.setValue(userId);
        datastore.password.setValue(password);
        datastore.securityKey.setValue(securityKey);
        
        dataset.sourceType.setValue(SourceType.MODULE_SELECTION);
        
        try {
            dataset.afterSourceType();
        } catch (IOException e) {
            Assert.fail(e.getMessage());
        }
        
        List<String> modules = (List<String>)dataset.moduleName.getPossibleValues();
        Assert.assertTrue("the module list is empty, not right", modules!=null && !modules.isEmpty());
    }
    
}

@@ -623,32 +623,24 @@
 set.init();%0A
-        
 %0A        Sal
@@ -752,24 +752,25 @@
 init();%0A
+%0A
         
 %0A       
@@ -753,32 +753,83 @@
 nit();%0A%0A        
+dataset.sourceType.setValue(SourceType.SOQL_QUERY);
 %0A        dataset
@@ -864,24 +864,16 @@
 store);%0A
-        
 %0A       

fix failed tests