use of org.talend.components.netsuite.v2016_2.NetSuiteSourceImpl in project components by Talend.
the class NetSuiteSearchInputReaderIT method testInput.
@Test
public void testInput() throws Exception {
RuntimeContainer container = mock(RuntimeContainer.class);
NetSuiteInputProperties properties = new NetSuiteInputProperties("test");
properties.init();
properties.connection.endpoint.setValue(webServiceTestFixture.getEndpointUrl());
properties.connection.email.setValue(webServiceTestFixture.getCredentials().getEmail());
properties.connection.password.setValue(webServiceTestFixture.getCredentials().getPassword());
properties.connection.account.setValue(webServiceTestFixture.getCredentials().getAccount());
properties.connection.role.setValue(Integer.valueOf(webServiceTestFixture.getCredentials().getRoleId()));
properties.connection.applicationId.setValue(webServiceTestFixture.getCredentials().getApplicationId());
properties.module.moduleName.setValue("Account");
NetSuiteRuntimeImpl runtime = new NetSuiteRuntimeImpl();
NetSuiteDatasetRuntime dataSetRuntime = runtime.getDatasetRuntime(properties.getConnectionProperties());
Schema schema = dataSetRuntime.getSchema(properties.module.moduleName.getValue());
properties.module.main.schema.setValue(schema);
properties.module.afterModuleName();
properties.module.searchQuery.field.setValue(Arrays.asList("Type"));
properties.module.searchQuery.operator.setValue(Arrays.asList("List.anyOf"));
properties.module.searchQuery.value1.setValue(Arrays.<Object>asList("Bank"));
properties.module.searchQuery.value2.setValue(Arrays.<Object>asList((String) null));
NetSuiteSource source = new NetSuiteSourceImpl();
source.initialize(container, properties);
NetSuiteSearchInputReader reader = (NetSuiteSearchInputReader) source.createReader(container);
boolean started = reader.start();
assertTrue(started);
IndexedRecord record = reader.getCurrent();
assertNotNull(record);
List<Schema.Field> fields = record.getSchema().getFields();
for (int i = 0; i < fields.size(); i++) {
Schema.Field typeField = getFieldByName(fields, "AcctType");
Object value = record.get(typeField.pos());
assertNotNull(value);
assertEquals(AccountType.BANK.value(), value);
}
}
use of org.talend.components.netsuite.v2016_2.NetSuiteSourceImpl in project components by Talend.
the class NetSuiteSearchInputReaderTest method testBasic.
@Test
public void testBasic() throws Exception {
properties.module.moduleName.setValue("Account");
properties.module.searchQuery.field.setValue(Lists.newArrayList("type", "generalRateType"));
properties.module.searchQuery.operator.setValue(Lists.newArrayList("List.anyOf", "List.anyOf"));
properties.module.searchQuery.value1.setValue(Lists.newArrayList((Object) Arrays.asList("bank", "otherAsset"), (Object) Arrays.asList("current", "historical")));
properties.module.searchQuery.value2.setValue(Lists.newArrayList(null, null));
NetSuiteRuntime netSuiteRuntime = new NetSuiteRuntimeImpl();
NetSuiteDatasetRuntime dataSetRuntime = netSuiteRuntime.getDatasetRuntime(properties.getConnectionProperties());
Schema schema = dataSetRuntime.getSchema(properties.module.moduleName.getValue());
properties.module.main.schema.setValue(schema);
NetSuiteSource source = new NetSuiteSourceImpl();
source.initialize(mockTestFixture.getRuntimeContainer(), properties);
List<Account> recordList = makeNsObjects(new SimpleObjectComposer<>(Account.class), 150);
mockSearchRequestResults(recordList, 100);
NetSuiteClientService<?> clientService = source.getClientService();
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo(Account.class);
NetSuiteSearchInputReader reader = (NetSuiteSearchInputReader) source.createReader(mockTestFixture.getRuntimeContainer());
boolean started = reader.start();
assertTrue(started);
IndexedRecord record = reader.getCurrent();
assertNotNull(record);
while (reader.advance()) {
record = reader.getCurrent();
assertIndexedRecord(typeDesc, record);
}
Map<String, Object> readerResult = reader.getReturnValues();
assertNotNull(readerResult);
assertEquals(150, readerResult.get(ComponentDefinition.RETURN_TOTAL_RECORD_COUNT));
}
use of org.talend.components.netsuite.v2016_2.NetSuiteSourceImpl in project components by Talend.
the class NetSuiteSearchInputReaderTest method testBasic.
@Test
public void testBasic() throws Exception {
properties.module.moduleName.setValue("Account");
NetSuiteRuntime netSuiteRuntime = new NetSuiteRuntimeImpl();
NetSuiteDatasetRuntime dataSetRuntime = netSuiteRuntime.getDatasetRuntime(properties.getConnectionProperties());
Schema schema = dataSetRuntime.getSchema(properties.module.moduleName.getValue());
properties.module.main.schema.setValue(schema);
NetSuiteSource source = new NetSuiteSourceImpl();
source.initialize(mockTestFixture.getRuntimeContainer(), properties);
List<Account> recordList = makeNsObjects(new SimpleObjectComposer<>(Account.class), 150);
mockSearchRequestResults(recordList, 100);
NetSuiteClientService<?> clientService = source.getClientService();
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo(Account.class);
NetSuiteSearchInputReader reader = (NetSuiteSearchInputReader) source.createReader(mockTestFixture.getRuntimeContainer());
boolean started = reader.start();
assertTrue(started);
IndexedRecord record = reader.getCurrent();
assertNotNull(record);
while (reader.advance()) {
record = reader.getCurrent();
assertIndexedRecord(typeDesc, record);
}
Map<String, Object> readerResult = reader.getReturnValues();
assertNotNull(readerResult);
assertEquals(150, readerResult.get(ComponentDefinition.RETURN_TOTAL_RECORD_COUNT));
}
use of org.talend.components.netsuite.v2016_2.NetSuiteSourceImpl in project components by Talend.
the class NetSuiteSearchInputReaderIT method testSearch.
@Test
public void testSearch() throws Exception {
RuntimeContainer container = mock(RuntimeContainer.class);
NetSuiteInputProperties properties = new NetSuiteInputProperties("test");
properties.init();
properties.connection.endpoint.setValue(webServiceTestFixture.getEndpointUrl());
properties.connection.email.setValue(webServiceTestFixture.getCredentials().getEmail());
properties.connection.password.setValue(webServiceTestFixture.getCredentials().getPassword());
properties.connection.account.setValue(webServiceTestFixture.getCredentials().getAccount());
properties.connection.role.setValue(Integer.valueOf(webServiceTestFixture.getCredentials().getRoleId()));
properties.connection.applicationId.setValue(webServiceTestFixture.getCredentials().getApplicationId());
properties.module.moduleName.setValue("Account");
NetSuiteRuntimeImpl runtime = new NetSuiteRuntimeImpl();
runtime.setClientFactory(clientFactory);
NetSuiteDatasetRuntime dataSetRuntime = runtime.getDatasetRuntime(properties.getConnectionProperties());
Schema schema = dataSetRuntime.getSchema(properties.module.moduleName.getValue());
properties.module.main.schema.setValue(schema);
properties.module.afterModuleName();
properties.module.searchQuery.field.setValue(Arrays.asList("Type"));
properties.module.searchQuery.operator.setValue(Arrays.asList("List.anyOf"));
properties.module.searchQuery.value1.setValue(Arrays.<Object>asList("Bank"));
properties.module.searchQuery.value2.setValue(Arrays.<Object>asList((String) null));
NetSuiteSource source = new NetSuiteSourceImpl();
source.initialize(container, properties);
NetSuiteSearchInputReader reader = (NetSuiteSearchInputReader) source.createReader(container);
boolean started = reader.start();
assertTrue(started);
IndexedRecord record = reader.getCurrent();
assertNotNull(record);
List<Schema.Field> fields = record.getSchema().getFields();
for (int i = 0; i < fields.size(); i++) {
Schema.Field typeField = getFieldByName(fields, "AcctType");
Object value = record.get(typeField.pos());
assertNotNull(value);
assertEquals(AccountType.BANK.value(), value);
}
}
Aggregations