Search in sources :

Example 1 with TestNetSuiteRuntimeImpl

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);
    }
}
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 TestNetSuiteRuntimeImpl

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());
    }
}
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) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) RecordRef(com.netsuite.webservices.test.platform.core.RecordRef) CustomRecordRef(com.netsuite.webservices.test.platform.core.CustomRecordRef) NetSuiteDatasetRuntime(org.talend.components.netsuite.NetSuiteDatasetRuntime) NetSuiteWebServiceMockTestFixture.assertNsObject(org.talend.components.netsuite.NetSuiteWebServiceMockTestFixture.assertNsObject) TestNetSuiteRuntimeImpl(org.talend.components.netsuite.TestNetSuiteRuntimeImpl) Test(org.junit.Test)

Example 3 with TestNetSuiteRuntimeImpl

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);
    }
}
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 4 with TestNetSuiteRuntimeImpl

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);
        }
    }
}
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) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) NetSuiteDatasetRuntime(org.talend.components.netsuite.NetSuiteDatasetRuntime) TestNetSuiteRuntimeImpl(org.talend.components.netsuite.TestNetSuiteRuntimeImpl) NetSuiteWebServiceMockTestFixture.assertNsObject(org.talend.components.netsuite.NetSuiteWebServiceMockTestFixture.assertNsObject) Test(org.junit.Test)

Aggregations

Schema (org.apache.avro.Schema)4 IndexedRecord (org.apache.avro.generic.IndexedRecord)4 Test (org.junit.Test)4 NetSuiteDatasetRuntime (org.talend.components.netsuite.NetSuiteDatasetRuntime)4 NetSuiteRuntime (org.talend.components.netsuite.NetSuiteRuntime)4 TestNetSuiteRuntimeImpl (org.talend.components.netsuite.TestNetSuiteRuntimeImpl)4 TypeDesc (org.talend.components.netsuite.client.model.TypeDesc)4 AbstractNetSuiteTestBase (org.talend.components.netsuite.AbstractNetSuiteTestBase)3 Opportunity (com.netsuite.webservices.test.transactions.sales.Opportunity)2 NetSuiteWebServiceMockTestFixture.assertNsObject (org.talend.components.netsuite.NetSuiteWebServiceMockTestFixture.assertNsObject)2 CustomRecordRef (com.netsuite.webservices.test.platform.core.CustomRecordRef)1 RecordRef (com.netsuite.webservices.test.platform.core.RecordRef)1