use of com.netsuite.webservices.v2016_2.platform.core.Record in project components by Talend.
the class NsObjectInputTransducerIT method testIncludeAllFields.
@Test
public void testIncludeAllFields() throws Exception {
NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
connection.login();
TypeDesc basicTypeDesc = connection.getBasicMetaData().getTypeInfo("Opportunity");
Schema schema = getDynamicSchema();
NsObjectInputTransducer transducer = new NsObjectInputTransducer(connection, schema, basicTypeDesc.getTypeName());
SearchResultSet<Record> rs = connection.newSearch().target(basicTypeDesc.getTypeName()).search();
TypeDesc typeDesc = connection.getMetaDataSource().getTypeInfo(basicTypeDesc.getTypeName());
int count = 0;
while (count++ < connection.getSearchPageSize() && rs.next()) {
Record record = rs.get();
IndexedRecord indexedRecord = transducer.read(record);
logger.debug("Indexed record: {}", indexedRecord);
Schema recordSchema = indexedRecord.getSchema();
assertEquals(typeDesc.getFields().size(), recordSchema.getFields().size());
for (FieldDesc fieldDesc : typeDesc.getFields()) {
String fieldName = fieldDesc.getName();
Schema.Field field = recordSchema.getField(fieldName);
assertNotNull(field);
Object value = indexedRecord.get(field.pos());
}
}
if (count == 0) {
throw new IllegalStateException("No records");
}
}
use of com.netsuite.webservices.v2016_2.platform.core.Record in project components by Talend.
the class NsObjectInputTransducerIT method testBasic.
@Test
public void testBasic() throws Exception {
NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
connection.login();
TypeDesc typeDesc = connection.getMetaDataSource().getTypeInfo("Opportunity");
Schema schema = NetSuiteDatasetRuntimeImpl.inferSchemaForType(typeDesc.getTypeName(), typeDesc.getFields());
NsObjectInputTransducer transducer = new NsObjectInputTransducer(connection, schema, typeDesc.getTypeName());
SearchResultSet<Record> rs = connection.newSearch().target(typeDesc.getTypeName()).search();
if (!rs.next()) {
throw new IllegalStateException("Not records");
}
Record record = rs.get();
IndexedRecord indexedRecord = transducer.read(record);
logger.debug("Indexed record: {}", indexedRecord);
}
use of com.netsuite.webservices.v2016_2.platform.core.Record in project components by Talend.
the class NetSuiteClientServiceImpl method toRecordList.
public static <RecT> List<Record> toRecordList(List<RecT> nsRecordList) {
List<Record> recordList = new ArrayList<>(nsRecordList.size());
for (RecT nsRecord : nsRecordList) {
Record r = (Record) nsRecord;
recordList.add(r);
}
return recordList;
}
use of com.netsuite.webservices.v2016_2.platform.core.Record in project components by Talend.
the class NetSuiteClientServiceImpl method toNsSearchResult.
public static <RecT> NsSearchResult<RecT> toNsSearchResult(SearchResult result) {
NsSearchResult nsResult = new NsSearchResult(toNsStatus(result.getStatus()));
nsResult.setSearchId(result.getSearchId());
nsResult.setTotalPages(result.getTotalPages());
nsResult.setTotalRecords(result.getTotalRecords());
nsResult.setPageIndex(result.getPageIndex());
nsResult.setPageSize(result.getPageSize());
if (result.getRecordList() != null) {
List<Record> nsRecordList = new ArrayList<>(result.getRecordList().getRecord().size());
for (Record record : result.getRecordList().getRecord()) {
nsRecordList.add(record);
}
nsResult.setRecordList(nsRecordList);
} else {
nsResult.setRecordList(Collections.emptyList());
}
return nsResult;
}
use of com.netsuite.webservices.v2016_2.platform.core.Record 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));
}
Aggregations