Search in sources :

Example 1 with CustomFieldSpec

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());
}
Also used : CustomRecordType(com.netsuite.webservices.test.setup.customization.CustomRecordType) CustomFieldSpec(org.talend.components.netsuite.CustomFieldSpec) CustomRecordTypeInfo(org.talend.components.netsuite.client.model.CustomRecordTypeInfo) Test(org.junit.Test)

Example 2 with CustomFieldSpec

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());
}
Also used : RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) CustomRecordTypeInfo(org.talend.components.netsuite.client.model.CustomRecordTypeInfo) CustomFieldSpec(org.talend.components.netsuite.CustomFieldSpec) CustomFieldDesc(org.talend.components.netsuite.client.model.CustomFieldDesc) Test(org.junit.Test)

Example 3 with CustomFieldSpec

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());
    }
}
Also used : CustomRecordType(com.netsuite.webservices.test.setup.customization.CustomRecordType) CustomFieldSpec(org.talend.components.netsuite.CustomFieldSpec) CustomFieldDesc(org.talend.components.netsuite.client.model.CustomFieldDesc) CustomRecordTypeInfo(org.talend.components.netsuite.client.model.CustomRecordTypeInfo) Test(org.junit.Test)

Example 4 with CustomFieldSpec

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;
}
Also used : HashMap(java.util.HashMap) BeanInfo(org.talend.components.netsuite.client.model.beans.BeanInfo) CustomFieldSpec(org.talend.components.netsuite.CustomFieldSpec) CustomFieldRef(com.netsuite.webservices.v2016_2.platform.core.CustomFieldRef) PropertyInfo(org.talend.components.netsuite.client.model.beans.PropertyInfo)

Aggregations

CustomFieldSpec (org.talend.components.netsuite.CustomFieldSpec)4 Test (org.junit.Test)3 CustomRecordTypeInfo (org.talend.components.netsuite.client.model.CustomRecordTypeInfo)3 CustomRecordType (com.netsuite.webservices.test.setup.customization.CustomRecordType)2 CustomFieldDesc (org.talend.components.netsuite.client.model.CustomFieldDesc)2 CustomFieldRef (com.netsuite.webservices.v2016_2.platform.core.CustomFieldRef)1 HashMap (java.util.HashMap)1 RecordTypeInfo (org.talend.components.netsuite.client.model.RecordTypeInfo)1 BeanInfo (org.talend.components.netsuite.client.model.beans.BeanInfo)1 PropertyInfo (org.talend.components.netsuite.client.model.beans.PropertyInfo)1