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