use of com.netsuite.webservices.test.setup.customization.CustomRecord 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 com.netsuite.webservices.test.setup.customization.CustomRecord in project components by Talend.
the class NsObjectInputTransducerTest method testDynamicSchemaWithCustomRecordType.
@Test
public void testDynamicSchemaWithCustomRecordType() throws Exception {
CustomMetaDataSource customMetaDataSource = new TestCustomMetaDataSource(clientService);
clientService.getMetaDataSource().setCustomMetaDataSource(customMetaDataSource);
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("custom_record_type_1");
final List<CustomRecord> recordList = makeNsObjects(new NsObjectComposer<CustomRecord>(clientService.getMetaDataSource(), typeDesc), 10);
mockSearchRequestResults(recordList, 100);
Schema schema = getDynamicSchema();
NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
SearchResultSet<CustomRecord> rs = clientService.newSearch().target(typeDesc.getTypeName()).search();
while (rs.next()) {
CustomRecord record = rs.get();
IndexedRecord indexedRecord = transducer.read(record);
assertIndexedRecord(typeDesc, indexedRecord);
}
}
Aggregations