Search in sources :

Example 1 with CustomFieldRef

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

the class NetSuiteMockTestBase method createCustomFieldRefs.

protected Map<String, CustomFieldRef> createCustomFieldRefs(Map<String, CustomFieldSpec<RecordType, CustomizationFieldType>> customFieldSpecs) throws Exception {
    NetSuiteClientService<?> clientService = webServiceMockTestFixture.getClientService();
    Map<String, CustomFieldRef> map = new HashMap<>();
    for (CustomFieldSpec spec : customFieldSpecs.values()) {
        CustomFieldRef fieldRef = clientService.getBasicMetaData().createInstance(spec.getFieldRefType().getTypeName());
        fieldRef.setScriptId(spec.getScriptId());
        fieldRef.setInternalId(spec.getInternalId());
        BeanInfo beanInfo = Beans.getBeanInfo(fieldRef.getClass());
        PropertyInfo valuePropInfo = beanInfo.getProperty("value");
        Object value = composeValue(valuePropInfo.getWriteType());
        if (value != null) {
            Beans.setProperty(fieldRef, "value", value);
        }
        map.put(fieldRef.getScriptId(), fieldRef);
    }
    return map;
}
Also used : HashMap(java.util.HashMap) BeanInfo(org.talend.components.netsuite.client.model.beans.BeanInfo) CustomFieldRef(com.netsuite.webservices.test.platform.core.CustomFieldRef) PropertyInfo(org.talend.components.netsuite.client.model.beans.PropertyInfo)

Aggregations

CustomFieldRef (com.netsuite.webservices.test.platform.core.CustomFieldRef)1 HashMap (java.util.HashMap)1 BeanInfo (org.talend.components.netsuite.client.model.beans.BeanInfo)1 PropertyInfo (org.talend.components.netsuite.client.model.beans.PropertyInfo)1