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());
}
}
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());
}
}
Aggregations