Search in sources :

Example 1 with SalesforceDatastoreProperties

use of org.talend.components.salesforce.datastore.SalesforceDatastoreProperties in project components by Talend.

the class SalesforceDatastoreRuntimeTestIT method testDoHealthChecksWithFail.

/*
    * If the logic changes for this test please specify appropriate timeout.
    * The average execution time for this test less than 1 sec.
    */
@Test(timeout = 30_000)
public void testDoHealthChecksWithFail() {
    SalesforceDatastoreProperties datastore = new SalesforceDatastoreProperties("datastore");
    CommonTestUtils.setValueForDatastoreProperties(datastore);
    datastore.password.setValue("wrongone");
    SalesforceDatastoreRuntime runtime = new SalesforceDatastoreRuntime();
    runtime.initialize(null, datastore);
    Iterable<ValidationResult> results = runtime.doHealthChecks(null);
    Assert.assertNotNull(results);
    for (ValidationResult result : results) {
        Assert.assertTrue(result.getMessage(), result.getStatus() == ValidationResult.Result.ERROR);
        Assert.assertNotNull(result.getMessage());
    }
}
Also used : SalesforceDatastoreProperties(org.talend.components.salesforce.datastore.SalesforceDatastoreProperties) ValidationResult(org.talend.daikon.properties.ValidationResult) Test(org.junit.Test)

Example 2 with SalesforceDatastoreProperties

use of org.talend.components.salesforce.datastore.SalesforceDatastoreProperties in project components by Talend.

the class SalesforceDatasetPropertiesTestIT method testAfterModuleName.

@Test
public void testAfterModuleName() {
    SalesforceDatasetProperties dataset = new SalesforceDatasetProperties("dataset");
    dataset.init();
    SalesforceDatastoreProperties datastore = new SalesforceDatastoreProperties("datastore");
    datastore.init();
    dataset.sourceType.setValue(SourceType.SOQL_QUERY);
    dataset.setDatastoreProperties(datastore);
    datastore.userId.setValue(userId);
    datastore.password.setValue(password);
    datastore.securityKey.setValue(securityKey);
    dataset.sourceType.setValue(SourceType.MODULE_SELECTION);
    dataset.moduleName.setValue("Account");
    List modules = dataset.selectColumnIds.getPossibleValues();
    Assert.assertTrue("the module list is not empty before calling 'afterSourceType' method, not right", modules == null || modules.isEmpty());
    try {
        dataset.afterModuleName();
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
    modules = dataset.selectColumnIds.getPossibleValues();
    Assert.assertTrue("the module list is empty after calling 'afterSourceType' method, not right", modules != null && !modules.isEmpty());
    Assert.assertTrue("the list of selected columns or fields must be null or empty", dataset.selectColumnIds.getValue() == null || dataset.selectColumnIds.getValue().isEmpty());
    Assert.assertTrue("the query value must be empty", StringUtils.isEmpty(dataset.query.getValue()));
}
Also used : SalesforceDatastoreProperties(org.talend.components.salesforce.datastore.SalesforceDatastoreProperties) List(java.util.List) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with SalesforceDatastoreProperties

use of org.talend.components.salesforce.datastore.SalesforceDatastoreProperties in project components by Talend.

the class SalesforceDatasetPropertiesTest method setUp.

@Before
public void setUp() {
    propertiesService = new PropertiesServiceImpl();
    datastoreProperties = new SalesforceDatastoreProperties("datastore");
    properties = spy(new SalesforceDatasetProperties("dataset"));
}
Also used : PropertiesServiceImpl(org.talend.daikon.properties.service.PropertiesServiceImpl) SalesforceDatastoreProperties(org.talend.components.salesforce.datastore.SalesforceDatastoreProperties) Before(org.junit.Before)

Example 4 with SalesforceDatastoreProperties

use of org.talend.components.salesforce.datastore.SalesforceDatastoreProperties in project components by Talend.

the class SalesforceDatasetPropertiesTestIT method testAfterSourceType.

@Test
public void testAfterSourceType() {
    SalesforceDatasetProperties dataset = new SalesforceDatasetProperties("dataset");
    dataset.init();
    SalesforceDatastoreProperties datastore = new SalesforceDatastoreProperties("datastore");
    datastore.init();
    dataset.sourceType.setValue(SourceType.SOQL_QUERY);
    dataset.setDatastoreProperties(datastore);
    datastore.userId.setValue(userId);
    datastore.password.setValue(password);
    datastore.securityKey.setValue(securityKey);
    dataset.sourceType.setValue(SourceType.MODULE_SELECTION);
    List modules = dataset.moduleName.getPossibleValues();
    Assert.assertTrue("the module list is not empty before calling 'afterSourceType' method, not right", modules == null || modules.isEmpty());
    try {
        dataset.afterSourceType();
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
    modules = dataset.moduleName.getPossibleValues();
    for (Object object : modules) {
        if (SalesforceDatasetProperties.MODULE_LIST_WHICH_NOT_SUPPORT_BULK_API.contains((String) object)) {
            Assert.fail(object + " is not supported by Bulk API");
        }
    }
    Assert.assertTrue("the module list is empty after calling 'afterSourceType' method, not right", modules != null && !modules.isEmpty());
    Assert.assertTrue("the module value must be empty at this point", StringUtils.isEmpty(dataset.moduleName.getValue()));
    Assert.assertTrue("the list of selected columns or fields must be null or empty", dataset.selectColumnIds.getValue() == null || dataset.selectColumnIds.getValue().isEmpty());
    Assert.assertTrue("the query value must be empty", StringUtils.isEmpty(dataset.query.getValue()));
}
Also used : SalesforceDatastoreProperties(org.talend.components.salesforce.datastore.SalesforceDatastoreProperties) List(java.util.List) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with SalesforceDatastoreProperties

use of org.talend.components.salesforce.datastore.SalesforceDatastoreProperties in project components by Talend.

the class SalesforceDatastoreRuntimeTestIT method testDoHealthChecksWithSuccess.

@Test
public void testDoHealthChecksWithSuccess() {
    SalesforceDatastoreProperties datastore = new SalesforceDatastoreProperties("datastore");
    CommonTestUtils.setValueForDatastoreProperties(datastore);
    SalesforceDatastoreRuntime runtime = new SalesforceDatastoreRuntime();
    runtime.initialize(null, datastore);
    Iterable<ValidationResult> results = runtime.doHealthChecks(null);
    Assert.assertNotNull(results);
    for (ValidationResult result : results) {
        Assert.assertTrue(result.getMessage(), result.getStatus() == ValidationResult.Result.OK);
    }
}
Also used : SalesforceDatastoreProperties(org.talend.components.salesforce.datastore.SalesforceDatastoreProperties) ValidationResult(org.talend.daikon.properties.ValidationResult) Test(org.junit.Test)

Aggregations

SalesforceDatastoreProperties (org.talend.components.salesforce.datastore.SalesforceDatastoreProperties)10 Test (org.junit.Test)5 SalesforceDatasetProperties (org.talend.components.salesforce.dataset.SalesforceDatasetProperties)5 SalesforceDatastoreDefinition (org.talend.components.salesforce.datastore.SalesforceDatastoreDefinition)5 IOException (java.io.IOException)2 List (java.util.List)2 SalesforceInputDefinition (org.talend.components.salesforce.dataprep.SalesforceInputDefinition)2 SalesforceInputProperties (org.talend.components.salesforce.dataprep.SalesforceInputProperties)2 ValidationResult (org.talend.daikon.properties.ValidationResult)2 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 Before (org.junit.Before)1 Consumer (org.talend.daikon.java8.Consumer)1 PropertiesServiceImpl (org.talend.daikon.properties.service.PropertiesServiceImpl)1