use of org.talend.components.netsuite.TestNetSuiteRuntimeImpl in project components by Talend.
the class NetSuiteOutputTransducerTest method testCustomFields.
@Test
public void testCustomFields() throws Exception {
TestCustomMetaDataSource customMetaDataSource = new TestCustomMetaDataSource(clientService, "Opportunity");
clientService.getMetaDataSource().setCustomMetaDataSource(customMetaDataSource);
NetSuiteRuntime netSuiteRuntime = new TestNetSuiteRuntimeImpl(webServiceMockTestFixture.getClientFactory());
NetSuiteDatasetRuntime dataSetRuntime = netSuiteRuntime.getDatasetRuntime(mockTestFixture.getConnectionProperties());
mockGetRequestResults(null);
TypeDesc basicTypeDesc = clientService.getBasicMetaData().getTypeInfo("Opportunity");
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("Opportunity");
final List<Opportunity> recordList = makeNsObjects(new NsObjectComposer<Opportunity>(clientService.getMetaDataSource(), typeDesc), 10);
mockSearchRequestResults(recordList, 100);
Schema schema = dataSetRuntime.getSchema(typeDesc.getTypeName());
NsObjectOutputTransducer transducer = new NsObjectOutputTransducer(webServiceMockTestFixture.getClientService(), typeDesc.getTypeName());
List<IndexedRecord> indexedRecordList = makeIndexedRecords(clientService, schema, new NsObjectComposer<Opportunity>(clientService.getMetaDataSource(), typeDesc), 10);
for (IndexedRecord indexedRecord : indexedRecordList) {
Opportunity record = (Opportunity) transducer.write(indexedRecord);
assertNsObject(basicTypeDesc, record);
}
}
use of org.talend.components.netsuite.TestNetSuiteRuntimeImpl in project components by Talend.
the class NetSuiteOutputTransducerTest method testRecordRef.
@Test
public void testRecordRef() throws Exception {
NetSuiteRuntime netSuiteRuntime = new TestNetSuiteRuntimeImpl(webServiceMockTestFixture.getClientFactory());
NetSuiteDatasetRuntime dataSetRuntime = netSuiteRuntime.getDatasetRuntime(mockTestFixture.getConnectionProperties());
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo(RefType.RECORD_REF.getTypeName());
TypeDesc referencedTypeDesc = clientService.getMetaDataSource().getTypeInfo("Opportunity");
Schema schema = dataSetRuntime.getSchema(typeDesc.getTypeName());
NsObjectOutputTransducer transducer = new NsObjectOutputTransducer(webServiceMockTestFixture.getClientService(), referencedTypeDesc.getTypeName());
transducer.setReference(true);
List<IndexedRecord> indexedRecordList = makeIndexedRecords(clientService, schema, new AbstractNetSuiteTestBase.SimpleObjectComposer<>(typeDesc.getTypeClass()), 10);
for (IndexedRecord indexedRecord : indexedRecordList) {
Object nsObject = transducer.write(indexedRecord);
assertNsObject(typeDesc, nsObject);
RecordRef ref = (RecordRef) nsObject;
assertEquals(RecordType.OPPORTUNITY, ref.getType());
}
}
use of org.talend.components.netsuite.TestNetSuiteRuntimeImpl in project components by Talend.
the class NetSuiteOutputTransducerTest method testBasic.
@Test
public void testBasic() throws Exception {
NetSuiteRuntime netSuiteRuntime = new TestNetSuiteRuntimeImpl(webServiceMockTestFixture.getClientFactory());
NetSuiteDatasetRuntime dataSetRuntime = netSuiteRuntime.getDatasetRuntime(mockTestFixture.getConnectionProperties());
mockGetRequestResults(null);
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("Opportunity");
Schema schema = dataSetRuntime.getSchema(typeDesc.getTypeName());
NsObjectOutputTransducer transducer = new NsObjectOutputTransducer(webServiceMockTestFixture.getClientService(), typeDesc.getTypeName());
List<IndexedRecord> indexedRecordList = makeIndexedRecords(clientService, schema, new AbstractNetSuiteTestBase.SimpleObjectComposer<>(Opportunity.class), 10);
for (IndexedRecord indexedRecord : indexedRecordList) {
Opportunity record = (Opportunity) transducer.write(indexedRecord);
assertNsObject(typeDesc, record);
}
}
use of org.talend.components.netsuite.TestNetSuiteRuntimeImpl in project components by Talend.
the class NetSuiteOutputTransducerTest method testNonRecordObjects.
@Test
public void testNonRecordObjects() throws Exception {
NetSuiteRuntime netSuiteRuntime = new TestNetSuiteRuntimeImpl(webServiceMockTestFixture.getClientFactory());
NetSuiteDatasetRuntime dataSetRuntime = netSuiteRuntime.getDatasetRuntime(mockTestFixture.getConnectionProperties());
Collection<String> typeNames = Arrays.asList(RefType.RECORD_REF.getTypeName(), RefType.CUSTOM_RECORD_REF.getTypeName());
for (String typeName : typeNames) {
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo(typeName);
Schema schema = dataSetRuntime.getSchema(typeDesc.getTypeName());
NsObjectOutputTransducer transducer = new NsObjectOutputTransducer(webServiceMockTestFixture.getClientService(), typeDesc.getTypeName());
List<IndexedRecord> indexedRecordList = makeIndexedRecords(clientService, schema, new AbstractNetSuiteTestBase.SimpleObjectComposer<>(typeDesc.getTypeClass()), 10);
for (IndexedRecord indexedRecord : indexedRecordList) {
Object nsObject = transducer.write(indexedRecord);
assertNsObject(typeDesc, nsObject);
}
}
}
Aggregations