use of com.netsuite.webservices.test.platform.core.BooleanCustomFieldRef 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);
}
use of com.netsuite.webservices.test.platform.core.BooleanCustomFieldRef in project components by Talend.
the class ValueConverterTest method testJsonConverterNestedObjectPolymorphicType.
@Test
public void testJsonConverterNestedObjectPolymorphicType() throws Exception {
NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
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);
FieldDesc fieldDesc = typeDesc.getField("customFieldList");
AvroConverter<CustomFieldList, String> converter1 = (AvroConverter<CustomFieldList, String>) transducer.getValueConverter(fieldDesc);
String testJson1 = converter1.convertToAvro(customFieldList);
assertNotNull(testJson1);
ObjectNode node1 = JsonNodeFactory.instance.objectNode();
ArrayNode list1 = JsonNodeFactory.instance.arrayNode();
node1.set("customField", list1);
ObjectNode customFieldNode1 = JsonNodeFactory.instance.objectNode();
customFieldNode1.set(NsTypeResolverBuilder.TYPE_PROPERTY_NAME, JsonNodeFactory.instance.textNode("BooleanCustomFieldRef"));
customFieldNode1.set("internalId", JsonNodeFactory.instance.textNode("100001"));
customFieldNode1.set("scriptId", JsonNodeFactory.instance.textNode("custentity_field1"));
customFieldNode1.set("value", JsonNodeFactory.instance.booleanNode(true));
list1.add(customFieldNode1);
ObjectNode customFieldNode2 = JsonNodeFactory.instance.objectNode();
customFieldNode2.set(NsTypeResolverBuilder.TYPE_PROPERTY_NAME, JsonNodeFactory.instance.textNode("StringCustomFieldRef"));
customFieldNode2.set("internalId", JsonNodeFactory.instance.textNode("100002"));
customFieldNode2.set("scriptId", JsonNodeFactory.instance.textNode("custentity_field2"));
customFieldNode2.set("value", JsonNodeFactory.instance.textNode("test123"));
list1.add(customFieldNode2);
CustomFieldList testCustomFieldList = converter1.convertToDatum(node1.toString());
assertNotNull(testCustomFieldList);
assertEquals(2, testCustomFieldList.getCustomField().size());
}
Aggregations