use of org.talend.components.api.component.runtime.Reader in project components by Talend.
the class SalesforceProxyTestIT method testProxyWithBulkQuery.
@Test
public void testProxyWithBulkQuery() {
TSalesforceInputDefinition definition = (TSalesforceInputDefinition) getComponentService().getComponentDefinition(TSalesforceInputDefinition.COMPONENT_NAME);
TSalesforceInputProperties properties = (TSalesforceInputProperties) definition.createRuntimeProperties();
properties.connection.bulkConnection.setValue(true);
properties.queryMode.setValue(QueryMode.Bulk);
SalesforceRuntimeTestUtil util = new SalesforceRuntimeTestUtil();
properties.module.moduleName.setValue(util.getTestModuleName());
properties.module.main.schema.setValue(util.getTestSchema1());
properties.connection.userPassword.userId.setValue(userId);
properties.connection.userPassword.password.setValue(password);
properties.connection.userPassword.securityKey.setValue(securityKey);
Source source = new SalesforceSource();
source.initialize(null, properties);
org.talend.daikon.properties.ValidationResult vr = source.validate(null);
Assert.assertEquals(ValidationResult.Result.OK, vr.getStatus());
Reader reader = source.createReader(null);
try {
reader.start();
do {
reader.getCurrent();
} while (reader.advance());
reader.close();
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
use of org.talend.components.api.component.runtime.Reader in project components by Talend.
the class SalesforceInputTestIT method testLimitOfSalesforceBulQueryReader.
public void testLimitOfSalesforceBulQueryReader() throws Exception {
SalesforceInputProperties properties = createCommonSalesforceInputPropertiesForModule();
SalesforceDataprepSource source = new SalesforceDataprepSource();
source.initialize(null, properties);
source.validate(null);
properties.getDatasetProperties().selectColumnIds.setValue(Arrays.asList("IsDeleted", "Id", "Name"));
try (Reader reader = source.createReader(null)) {
((SalesforceBulkQueryReader) reader).setLimit(1);
reader.start();
reader.advance();
IndexedRecord record = (IndexedRecord) reader.getCurrent();
assertEquals(3, record.getSchema().getFields().size());
try {
reader.advance();
fail();
} catch (IOException e) {
// Excepted to happen
}
}
}
use of org.talend.components.api.component.runtime.Reader in project components by Talend.
the class SalesforceInputTestIT method testReaderForQuery.
@Test
public void testReaderForQuery() {
Reader reader = null;
try {
SalesforceInputProperties properties = createCommonSalesforceInputPropertiesForQuery();
SalesforceDataprepSource source = new SalesforceDataprepSource();
source.initialize(null, properties);
source.validate(null);
reader = source.createReader(null);
reader.start();
IndexedRecord row = (IndexedRecord) reader.getCurrent();
String id = (String) row.get(0);
String name = (String) row.get(1);
Assert.assertNotNull("id is null", id);
reader.advance();
row = (IndexedRecord) reader.getCurrent();
Assert.assertNotNull("id is null", id);
reader.close();
// Map<String, Object> returnMap = reader.getReturnValues();
// Assert.assertEquals(3, returnMap.get(ComponentDefinition.RETURN_TOTAL_RECORD_COUNT));
} catch (Exception e) {
Assert.fail(e.getMessage());
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
}
}
use of org.talend.components.api.component.runtime.Reader in project components by Talend.
the class SalesforceInputTestIT method testTypeForModuleWithPickListType.
@Test
public void testTypeForModuleWithPickListType() throws Exception {
SalesforceInputProperties properties = createCommonSalesforceInputPropertiesForModule();
SalesforceDataprepSource source = new SalesforceDataprepSource();
source.initialize(null, properties);
source.validate(null);
properties.getDatasetProperties().selectColumnIds.setValue(Arrays.asList("IsDeleted", "Id", "Name", "Type"));
try (Reader reader = source.createReader(null)) {
int count = 3;
for (boolean available = reader.start(); available; available = reader.advance()) {
IndexedRecord record = (IndexedRecord) reader.getCurrent();
assertEquals(4, record.getSchema().getFields().size());
if ((count--) < 1) {
break;
}
}
}
}
use of org.talend.components.api.component.runtime.Reader in project components by Talend.
the class SalesforceInputTestIT method testReaderForModule.
@Test
public void testReaderForModule() {
Reader reader = null;
try {
SalesforceInputProperties properties = createCommonSalesforceInputPropertiesForModule();
properties.getDatasetProperties().selectColumnIds.setValue(Arrays.asList("IsDeleted", "Id"));
SalesforceDataprepSource source = new SalesforceDataprepSource();
source.initialize(null, properties);
source.validate(null);
reader = source.createReader(null);
reader.start();
IndexedRecord row = (IndexedRecord) reader.getCurrent();
String id = (String) row.get(0);
Assert.assertNotNull("id is null", id);
reader.advance();
row = (IndexedRecord) reader.getCurrent();
Assert.assertNotNull("id is null", id);
reader.close();
// Map<String, Object> returnMap = reader.getReturnValues();
// Assert.assertEquals(3, returnMap.get(ComponentDefinition.RETURN_TOTAL_RECORD_COUNT));
} catch (Exception e) {
Assert.fail(e.getMessage());
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
}
}
Aggregations