Search in sources :

Example 1 with NetSuiteDatasetRuntimeImpl

use of org.talend.components.netsuite.NetSuiteDatasetRuntimeImpl in project components by Talend.

the class NetSuiteOutputTransducerTest method testCustomRecord.

@Test
public void testCustomRecord() throws Exception {
    CustomMetaDataSource customMetaDataSource = new TestCustomMetaDataSource(clientService);
    clientService.getMetaDataSource().setCustomMetaDataSource(customMetaDataSource);
    NetSuiteDatasetRuntime dataSetRuntime = new NetSuiteDatasetRuntimeImpl(clientService.getMetaDataSource());
    mockGetRequestResults(null);
    TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("custom_record_type_1");
    Schema schema = dataSetRuntime.getSchema(typeDesc.getTypeName());
    NsObjectOutputTransducer transducer = new NsObjectOutputTransducer(webServiceMockTestFixture.getClientService(), typeDesc.getTypeName());
    GenericRecord indexedRecordToAdd = new GenericData.Record(schema);
    String testId = Long.toString(System.currentTimeMillis());
    indexedRecordToAdd.put("Custom_record_field_1", "Test Project " + testId);
    indexedRecordToAdd.put("Custom_record_field_2", Long.valueOf(System.currentTimeMillis()));
    List<IndexedRecord> indexedRecordList = new ArrayList<>();
    indexedRecordList.add(indexedRecordToAdd);
    for (IndexedRecord indexedRecord : indexedRecordList) {
        CustomRecord record = (CustomRecord) transducer.write(indexedRecord);
        assertNotNull(record.getRecType());
        assertNotNull(record.getRecType().getInternalId());
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) CustomMetaDataSource(org.talend.components.netsuite.client.CustomMetaDataSource) Schema(org.apache.avro.Schema) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) ArrayList(java.util.ArrayList) NetSuiteDatasetRuntime(org.talend.components.netsuite.NetSuiteDatasetRuntime) CustomRecord(com.netsuite.webservices.test.setup.customization.CustomRecord) IndexedRecord(org.apache.avro.generic.IndexedRecord) GenericRecord(org.apache.avro.generic.GenericRecord) CustomRecord(com.netsuite.webservices.test.setup.customization.CustomRecord) GenericRecord(org.apache.avro.generic.GenericRecord) NetSuiteDatasetRuntimeImpl(org.talend.components.netsuite.NetSuiteDatasetRuntimeImpl) Test(org.junit.Test)

Example 2 with NetSuiteDatasetRuntimeImpl

use of org.talend.components.netsuite.NetSuiteDatasetRuntimeImpl in project components by Talend.

the class NetSuiteOutputTransducerTest method testCustomRecordRef.

@Test
public void testCustomRecordRef() throws Exception {
    CustomMetaDataSource customMetaDataSource = new TestCustomMetaDataSource(clientService);
    clientService.getMetaDataSource().setCustomMetaDataSource(customMetaDataSource);
    NetSuiteDatasetRuntime dataSetRuntime = new NetSuiteDatasetRuntimeImpl(clientService.getMetaDataSource());
    mockGetRequestResults(null);
    TypeDesc customTypeDesc = clientService.getMetaDataSource().getTypeInfo("custom_record_type_1");
    Schema schema = dataSetRuntime.getSchemaForDelete(customTypeDesc.getTypeName());
    NsObjectOutputTransducer transducer = new NsObjectOutputTransducer(webServiceMockTestFixture.getClientService(), customTypeDesc.getTypeName());
    transducer.setReference(true);
    GenericRecord indexedRecordToAdd = new GenericData.Record(schema);
    indexedRecordToAdd.put("InternalId", "123456789");
    List<IndexedRecord> indexedRecordList = new ArrayList<>();
    indexedRecordList.add(indexedRecordToAdd);
    for (IndexedRecord indexedRecord : indexedRecordList) {
        CustomRecordRef recordRef = (CustomRecordRef) transducer.write(indexedRecord);
        assertNotNull(recordRef.getInternalId());
        assertNotNull(recordRef.getTypeId());
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) CustomMetaDataSource(org.talend.components.netsuite.client.CustomMetaDataSource) Schema(org.apache.avro.Schema) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) ArrayList(java.util.ArrayList) NetSuiteDatasetRuntime(org.talend.components.netsuite.NetSuiteDatasetRuntime) CustomRecordRef(com.netsuite.webservices.test.platform.core.CustomRecordRef) CustomRecord(com.netsuite.webservices.test.setup.customization.CustomRecord) IndexedRecord(org.apache.avro.generic.IndexedRecord) GenericRecord(org.apache.avro.generic.GenericRecord) GenericRecord(org.apache.avro.generic.GenericRecord) NetSuiteDatasetRuntimeImpl(org.talend.components.netsuite.NetSuiteDatasetRuntimeImpl) Test(org.junit.Test)

Aggregations

CustomRecord (com.netsuite.webservices.test.setup.customization.CustomRecord)2 ArrayList (java.util.ArrayList)2 Schema (org.apache.avro.Schema)2 GenericRecord (org.apache.avro.generic.GenericRecord)2 IndexedRecord (org.apache.avro.generic.IndexedRecord)2 Test (org.junit.Test)2 NetSuiteDatasetRuntime (org.talend.components.netsuite.NetSuiteDatasetRuntime)2 NetSuiteDatasetRuntimeImpl (org.talend.components.netsuite.NetSuiteDatasetRuntimeImpl)2 CustomMetaDataSource (org.talend.components.netsuite.client.CustomMetaDataSource)2 TypeDesc (org.talend.components.netsuite.client.model.TypeDesc)2 CustomRecordRef (com.netsuite.webservices.test.platform.core.CustomRecordRef)1