Search in sources :

Example 1 with RecordRefList

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

the class ValueConverterTest method testJsonConverterComplexObject.

@Test
public void testJsonConverterComplexObject() throws Exception {
    NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
    Account account1 = new SimpleObjectComposer<>(Account.class).composeObject();
    RecordRef recordRef1 = new RecordRef();
    recordRef1.setInternalId("120001");
    recordRef1.setName("Talend France");
    RecordRef recordRef2 = new RecordRef();
    recordRef2.setInternalId("120002");
    recordRef2.setName("Talend China");
    RecordRefList recordRefList1 = new RecordRefList();
    recordRefList1.getRecordRef().add(recordRef1);
    recordRefList1.getRecordRef().add(recordRef2);
    account1.setSubsidiaryList(recordRefList1);
    BooleanCustomFieldRef customFieldRef1 = new BooleanCustomFieldRef();
    customFieldRef1.setInternalId("100001");
    customFieldRef1.setScriptId("custentity_field1");
    customFieldRef1.setValue(true);
    StringCustomFieldRef customFieldRef2 = new StringCustomFieldRef();
    customFieldRef2.setInternalId("100002");
    customFieldRef2.setScriptId("custentity_field2");
    customFieldRef2.setValue("test123");
    CustomFieldList customFieldList = new CustomFieldList();
    customFieldList.getCustomField().add(customFieldRef1);
    customFieldList.getCustomField().add(customFieldRef2);
    account1.setCustomFieldList(customFieldList);
    AvroConverter<Account, String> converter1 = (AvroConverter<Account, String>) transducer.getValueConverter(account1.getClass());
    assertEquals(AvroUtils._string(), converter1.getSchema());
    assertEquals(account1.getClass(), converter1.getDatumClass());
    String testJson1 = converter1.convertToAvro(account1);
    assertNotNull(testJson1);
    Account testAccount1 = converter1.convertToDatum(testJson1);
    assertNotNull(testAccount1);
}
Also used : RecordRefList(com.netsuite.webservices.test.platform.core.RecordRefList) Account(com.netsuite.webservices.test.lists.accounting.Account) RecordRef(com.netsuite.webservices.test.platform.core.RecordRef) BooleanCustomFieldRef(com.netsuite.webservices.test.platform.core.BooleanCustomFieldRef) NsObjectInputTransducer(org.talend.components.netsuite.input.NsObjectInputTransducer) CustomFieldList(com.netsuite.webservices.test.platform.core.CustomFieldList) StringCustomFieldRef(com.netsuite.webservices.test.platform.core.StringCustomFieldRef) AvroConverter(org.talend.daikon.avro.converter.AvroConverter) Test(org.junit.Test)

Aggregations

Account (com.netsuite.webservices.test.lists.accounting.Account)1 BooleanCustomFieldRef (com.netsuite.webservices.test.platform.core.BooleanCustomFieldRef)1 CustomFieldList (com.netsuite.webservices.test.platform.core.CustomFieldList)1 RecordRef (com.netsuite.webservices.test.platform.core.RecordRef)1 RecordRefList (com.netsuite.webservices.test.platform.core.RecordRefList)1 StringCustomFieldRef (com.netsuite.webservices.test.platform.core.StringCustomFieldRef)1 Test (org.junit.Test)1 NsObjectInputTransducer (org.talend.components.netsuite.input.NsObjectInputTransducer)1 AvroConverter (org.talend.daikon.avro.converter.AvroConverter)1