Search in sources :

Example 1 with Opportunity

use of com.netsuite.webservices.test.transactions.sales.Opportunity 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);
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) NetSuiteRuntime(org.talend.components.netsuite.NetSuiteRuntime) Opportunity(com.netsuite.webservices.test.transactions.sales.Opportunity) Schema(org.apache.avro.Schema) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) NetSuiteDatasetRuntime(org.talend.components.netsuite.NetSuiteDatasetRuntime) TestNetSuiteRuntimeImpl(org.talend.components.netsuite.TestNetSuiteRuntimeImpl) Test(org.junit.Test)

Example 2 with Opportunity

use of com.netsuite.webservices.test.transactions.sales.Opportunity 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);
    }
}
Also used : AbstractNetSuiteTestBase(org.talend.components.netsuite.AbstractNetSuiteTestBase) IndexedRecord(org.apache.avro.generic.IndexedRecord) NetSuiteRuntime(org.talend.components.netsuite.NetSuiteRuntime) Schema(org.apache.avro.Schema) Opportunity(com.netsuite.webservices.test.transactions.sales.Opportunity) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) NetSuiteDatasetRuntime(org.talend.components.netsuite.NetSuiteDatasetRuntime) TestNetSuiteRuntimeImpl(org.talend.components.netsuite.TestNetSuiteRuntimeImpl) Test(org.junit.Test)

Example 3 with Opportunity

use of com.netsuite.webservices.test.transactions.sales.Opportunity in project components by Talend.

the class NsObjectInputTransducerTest method testBasic.

@Test
public void testBasic() throws Exception {
    TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("Opportunity");
    final List<Opportunity> recordList = makeNsObjects(new NsObjectComposer<Opportunity>(clientService.getMetaDataSource(), typeDesc), 10);
    mockSearchRequestResults(recordList, 100);
    Schema schema = NetSuiteDatasetRuntimeImpl.inferSchemaForType(typeDesc.getTypeName(), typeDesc.getFields());
    NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
    for (Record record : recordList) {
        IndexedRecord indexedRecord = transducer.read(record);
        assertIndexedRecord(typeDesc, indexedRecord);
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) NetSuiteWebServiceMockTestFixture.assertIndexedRecord(org.talend.components.netsuite.NetSuiteWebServiceMockTestFixture.assertIndexedRecord) Opportunity(com.netsuite.webservices.test.transactions.sales.Opportunity) Schema(org.apache.avro.Schema) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) CustomRecord(com.netsuite.webservices.test.setup.customization.CustomRecord) IndexedRecord(org.apache.avro.generic.IndexedRecord) NetSuiteWebServiceMockTestFixture.assertIndexedRecord(org.talend.components.netsuite.NetSuiteWebServiceMockTestFixture.assertIndexedRecord) Record(com.netsuite.webservices.test.platform.core.Record) Test(org.junit.Test)

Example 4 with Opportunity

use of com.netsuite.webservices.test.transactions.sales.Opportunity in project components by Talend.

the class NsObjectInputTransducerTest method testDynamicSchemaWithCustomFields.

@Test
public void testDynamicSchemaWithCustomFields() throws Exception {
    TestCustomMetaDataSource customMetaDataSource = new TestCustomMetaDataSource(clientService, "Opportunity");
    clientService.getMetaDataSource().setCustomMetaDataSource(customMetaDataSource);
    TypeDesc basicTypeDesc = clientService.getMetaDataSource().getTypeInfo("Opportunity");
    final List<Opportunity> recordList = makeNsObjects(new NsObjectComposer<Opportunity>(clientService.getMetaDataSource(), basicTypeDesc), 10);
    mockSearchRequestResults(recordList, 100);
    TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo(basicTypeDesc.getTypeName());
    Schema schema = getDynamicSchema();
    NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
    SearchResultSet<Record> rs = clientService.newSearch().target(basicTypeDesc.getTypeName()).search();
    while (rs.next()) {
        Record record = rs.get();
        IndexedRecord indexedRecord = transducer.read(record);
        assertIndexedRecord(typeDesc, indexedRecord);
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) NetSuiteWebServiceMockTestFixture.assertIndexedRecord(org.talend.components.netsuite.NetSuiteWebServiceMockTestFixture.assertIndexedRecord) Opportunity(com.netsuite.webservices.test.transactions.sales.Opportunity) Schema(org.apache.avro.Schema) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) CustomRecord(com.netsuite.webservices.test.setup.customization.CustomRecord) IndexedRecord(org.apache.avro.generic.IndexedRecord) NetSuiteWebServiceMockTestFixture.assertIndexedRecord(org.talend.components.netsuite.NetSuiteWebServiceMockTestFixture.assertIndexedRecord) Record(com.netsuite.webservices.test.platform.core.Record) Test(org.junit.Test)

Aggregations

Opportunity (com.netsuite.webservices.test.transactions.sales.Opportunity)4 Schema (org.apache.avro.Schema)4 IndexedRecord (org.apache.avro.generic.IndexedRecord)4 Test (org.junit.Test)4 TypeDesc (org.talend.components.netsuite.client.model.TypeDesc)4 Record (com.netsuite.webservices.test.platform.core.Record)2 CustomRecord (com.netsuite.webservices.test.setup.customization.CustomRecord)2 NetSuiteDatasetRuntime (org.talend.components.netsuite.NetSuiteDatasetRuntime)2 NetSuiteRuntime (org.talend.components.netsuite.NetSuiteRuntime)2 NetSuiteWebServiceMockTestFixture.assertIndexedRecord (org.talend.components.netsuite.NetSuiteWebServiceMockTestFixture.assertIndexedRecord)2 TestNetSuiteRuntimeImpl (org.talend.components.netsuite.TestNetSuiteRuntimeImpl)2 AbstractNetSuiteTestBase (org.talend.components.netsuite.AbstractNetSuiteTestBase)1