Search in sources :

Example 6 with RecordList

use of com.netsuite.webservices.v2014_2.platform.core.RecordList in project components by Talend.

the class NetSuiteMockTestBase method makeIndexedRecords.

public static <T> List<IndexedRecord> makeIndexedRecords(NetSuiteClientService<?> clientService, Schema schema, ObjectComposer<T> objectComposer, int count) throws Exception {
    NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, schema.getName());
    List<IndexedRecord> recordList = new ArrayList<>();
    while (count > 0) {
        T nsRecord = objectComposer.composeObject();
        IndexedRecord convertedRecord = transducer.read(nsRecord);
        Schema recordSchema = convertedRecord.getSchema();
        GenericRecord record = new GenericData.Record(recordSchema);
        for (Schema.Field field : schema.getFields()) {
            Object value = convertedRecord.get(field.pos());
            record.put(field.pos(), value);
        }
        recordList.add(record);
        count--;
    }
    return recordList;
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) Schema(org.apache.avro.Schema) ArrayList(java.util.ArrayList) NsObjectInputTransducer(org.talend.components.netsuite.input.NsObjectInputTransducer) Record(com.netsuite.webservices.v2014_2.platform.core.Record) IndexedRecord(org.apache.avro.generic.IndexedRecord) GenericRecord(org.apache.avro.generic.GenericRecord) GenericRecord(org.apache.avro.generic.GenericRecord)

Aggregations

ArrayList (java.util.ArrayList)4 Record (com.netsuite.webservices.v2014_2.platform.core.Record)2 SearchResult (com.netsuite.webservices.v2014_2.platform.core.SearchResult)2 Schema (org.apache.avro.Schema)2 IndexedRecord (org.apache.avro.generic.IndexedRecord)2 Account (com.netsuite.webservices.v2014_2.lists.accounting.Account)1 NetSuitePortType (com.netsuite.webservices.v2014_2.platform.NetSuitePortType)1 RecordList (com.netsuite.webservices.v2014_2.platform.core.RecordList)1 SearchRecord (com.netsuite.webservices.v2014_2.platform.core.SearchRecord)1 SearchMoreWithIdRequest (com.netsuite.webservices.v2014_2.platform.messages.SearchMoreWithIdRequest)1 SearchMoreWithIdResponse (com.netsuite.webservices.v2014_2.platform.messages.SearchMoreWithIdResponse)1 SearchRequest (com.netsuite.webservices.v2014_2.platform.messages.SearchRequest)1 SearchResponse (com.netsuite.webservices.v2014_2.platform.messages.SearchResponse)1 RecordList (com.netsuite.webservices.v2016_2.platform.core.RecordList)1 SearchResult (com.netsuite.webservices.v2016_2.platform.core.SearchResult)1 GenericRecord (org.apache.avro.generic.GenericRecord)1 Test (org.junit.Test)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 NetSuiteDatasetRuntime (org.talend.components.netsuite.NetSuiteDatasetRuntime)1 NetSuiteRuntime (org.talend.components.netsuite.NetSuiteRuntime)1