use of org.talend.components.netsuite.CustomFieldSpec in project components by Talend.
the class CustomMetaDataSourceTest method testGetCustomRecordTypes.
@Test
public void testGetCustomRecordTypes() throws Exception {
Map<String, CustomFieldSpec<RecordType, CustomizationFieldType>> customRecordFieldSpecs = createCustomRecordFieldSpecs();
CustomRecordType customRecordType = createCustomRecordType(customRecordFieldSpecs);
customMetaDataRetriever.setCustomRecordType(customRecordType);
customMetaDataRetriever.setCustomRecordFieldSpecs(customRecordFieldSpecs);
Collection<CustomRecordTypeInfo> recordTypeInfos = customMetaDataSource.getCustomRecordTypes();
assertNotNull(recordTypeInfos);
assertEquals(1, recordTypeInfos.size());
CustomRecordTypeInfo recordTypeInfo1 = recordTypeInfos.iterator().next();
assertNotNull(recordTypeInfo1.getName());
assertNotNull(recordTypeInfo1.getCustomizationRef());
assertEquals(customRecordType.getScriptId(), recordTypeInfo1.getName());
assertEquals(customRecordType.getScriptId(), recordTypeInfo1.getCustomizationRef().getScriptId());
assertEquals(customRecordType.getInternalId(), recordTypeInfo1.getCustomizationRef().getInternalId());
}
use of org.talend.components.netsuite.CustomFieldSpec in project components by Talend.
the class CustomMetaDataSourceTest method testGetCustomFields.
@Test
public void testGetCustomFields() {
Map<String, CustomFieldSpec<RecordType, CustomizationFieldType>> customFieldSpecs = createCustomFieldSpecs();
customMetaDataRetriever.setCustomFieldSpecs(customFieldSpecs);
RecordTypeInfo recordTypeInfo = clientService.getMetaDataSource().getRecordType(TestRecordTypeEnum.OPPORTUNITY.getTypeName());
Map<String, CustomFieldDesc> customFieldDescMap = customMetaDataSource.getCustomFields(recordTypeInfo);
assertNotNull(customFieldDescMap);
for (CustomFieldSpec customFieldSpec : customFieldSpecs.values()) {
CustomFieldDesc customFieldDesc = customFieldDescMap.get(customFieldSpec.getScriptId());
assertNotNull(customFieldDesc);
assertNotNull(customFieldDesc.getCustomizationRef());
assertEquals(customFieldSpec.getScriptId(), customFieldDesc.getName());
assertEquals(customFieldSpec.getInternalId(), customFieldDesc.getCustomizationRef().getInternalId());
}
CustomFieldDesc customFieldDesc = customFieldDescMap.get("custbody_field1");
assertNotNull(customFieldDesc);
assertEquals(CustomFieldRefType.BOOLEAN, customFieldDesc.getCustomFieldType());
assertEquals(TestRecordTypeEnum.TRANSACTION_BODY_CUSTOM_FIELD.getType(), customFieldDesc.getCustomizationRef().getType());
}
use of org.talend.components.netsuite.CustomFieldSpec in project components by Talend.
the class CustomMetaDataSourceTest method testGetCustomRecordType.
@Test
public void testGetCustomRecordType() throws Exception {
Map<String, CustomFieldSpec<RecordType, CustomizationFieldType>> customRecordFieldSpecs = createCustomRecordFieldSpecs();
CustomRecordType customRecordType = createCustomRecordType(customRecordFieldSpecs);
customMetaDataRetriever.setCustomRecordType(customRecordType);
customMetaDataRetriever.setCustomRecordFieldSpecs(customRecordFieldSpecs);
CustomRecordTypeInfo recordTypeInfo = customMetaDataSource.getCustomRecordType(customRecordType.getScriptId());
assertNotNull(recordTypeInfo);
Map<String, CustomFieldDesc> customFieldDescMap = customMetaDataSource.getCustomFields(recordTypeInfo);
assertNotNull(customFieldDescMap);
for (CustomFieldSpec customFieldSpec : customRecordFieldSpecs.values()) {
CustomFieldDesc customFieldDesc = customFieldDescMap.get(customFieldSpec.getScriptId());
assertNotNull(customFieldDesc);
assertNotNull(customFieldDesc.getCustomizationRef());
assertEquals(customFieldSpec.getScriptId(), customFieldDesc.getName());
assertEquals(customFieldSpec.getInternalId(), customFieldDesc.getCustomizationRef().getInternalId());
}
}
use of org.talend.components.netsuite.CustomFieldSpec 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;
}
Aggregations