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());
    }
    
}

@@ -1048,32 +1048,272 @@
 TION);%0A        %0A
+        List%3CString%3E modules = (List%3CString%3E)dataset.moduleName.getPossibleValues();%0A        Assert.assertTrue(%22the module list is not empty before calling 'afterSourceType' method, not right%22, modules==null %7C%7C modules.isEmpty());%0A        %0A
         try %7B%0A  
@@ -1446,37 +1446,24 @@
     %0A       
- List%3CString%3E
  modules = (
@@ -1566,16 +1566,55 @@
 is empty
+ after calling 'afterSourceType' method
 , not ri

fix the junit to add a init check (#566)