Search in sources :

Example 1 with CustomRecordRef

use of com.netsuite.webservices.test.platform.core.CustomRecordRef in project components by Talend.

the class NsRefTest method testCustomRecordRef.

@Test
public void testCustomRecordRef() {
    NsRef ref = new NsRef(RefType.CUSTOM_RECORD_REF);
    ref.setTypeId("1001");
    ref.setInternalId("10001");
    ref.setExternalId(UUID.randomUUID().toString());
    ref.setScriptId("custrecord25");
    CustomRecordRef customRecordRef = (CustomRecordRef) ref.toNativeRef(basicMetaData);
    assertNotNull(customRecordRef);
    assertNull(ref.getType());
    assertEquals(ref.getTypeId(), customRecordRef.getTypeId());
    assertEquals(ref.getInternalId(), customRecordRef.getInternalId());
    assertEquals(ref.getExternalId(), customRecordRef.getExternalId());
    assertEquals(ref.getScriptId(), customRecordRef.getScriptId());
    NsRef ref2 = NsRef.fromNativeRef(customRecordRef);
    assertNotNull(ref2);
    assertEquals(customRecordRef.getTypeId(), ref2.getTypeId());
    assertEquals(customRecordRef.getInternalId(), ref2.getInternalId());
    assertEquals(customRecordRef.getExternalId(), ref2.getExternalId());
    assertNull(ref2.getScriptId());
}
Also used : CustomRecordRef(com.netsuite.webservices.test.platform.core.CustomRecordRef) NsRef(org.talend.components.netsuite.client.NsRef) Test(org.junit.Test)

Example 2 with CustomRecordRef

use of com.netsuite.webservices.test.platform.core.CustomRecordRef 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());
    }
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) CustomMetaDataSource(org.talend.components.netsuite.client.CustomMetaDataSource) Schema(org.apache.avro.Schema) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) ArrayList(java.util.ArrayList) NetSuiteDatasetRuntime(org.talend.components.netsuite.NetSuiteDatasetRuntime) CustomRecordRef(com.netsuite.webservices.test.platform.core.CustomRecordRef) CustomRecord(com.netsuite.webservices.test.setup.customization.CustomRecord) IndexedRecord(org.apache.avro.generic.IndexedRecord) GenericRecord(org.apache.avro.generic.GenericRecord) GenericRecord(org.apache.avro.generic.GenericRecord) NetSuiteDatasetRuntimeImpl(org.talend.components.netsuite.NetSuiteDatasetRuntimeImpl) Test(org.junit.Test)

Aggregations

CustomRecordRef (com.netsuite.webservices.test.platform.core.CustomRecordRef)2 Test (org.junit.Test)2 CustomRecord (com.netsuite.webservices.test.setup.customization.CustomRecord)1 ArrayList (java.util.ArrayList)1 Schema (org.apache.avro.Schema)1 GenericRecord (org.apache.avro.generic.GenericRecord)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 NetSuiteDatasetRuntime (org.talend.components.netsuite.NetSuiteDatasetRuntime)1 NetSuiteDatasetRuntimeImpl (org.talend.components.netsuite.NetSuiteDatasetRuntimeImpl)1 CustomMetaDataSource (org.talend.components.netsuite.client.CustomMetaDataSource)1 NsRef (org.talend.components.netsuite.client.NsRef)1 TypeDesc (org.talend.components.netsuite.client.model.TypeDesc)1