Search in sources :

Example 1 with CustomFieldType

use of com.netsuite.webservices.test.setup.customization.CustomFieldType in project components by Talend.

the class CustomMetaDataSourceTest method createCustomRecordType.

protected CustomRecordType createCustomRecordType(Map<String, CustomFieldSpec<RecordType, CustomizationFieldType>> customFieldSpecs) throws Exception {
    CustomRecordType customRecordType = new CustomRecordType();
    customRecordType.setScriptId("custrecord1");
    customRecordType.setInternalId("201");
    Map<String, CustomFieldType> customFieldTypeMap = createCustomFieldTypes(customFieldSpecs);
    customRecordType.setCustomFieldList(new CustomRecordTypeFieldList());
    for (CustomFieldType customFieldType : customFieldTypeMap.values()) {
        customRecordType.getCustomFieldList().getCustomField().add((CustomRecordCustomField) customFieldType);
    }
    return customRecordType;
}
Also used : CustomRecordType(com.netsuite.webservices.test.setup.customization.CustomRecordType) CustomRecordTypeFieldList(com.netsuite.webservices.test.setup.customization.CustomRecordTypeFieldList) CustomFieldType(com.netsuite.webservices.test.setup.customization.CustomFieldType)

Example 2 with CustomFieldType

use of com.netsuite.webservices.test.setup.customization.CustomFieldType in project components by Talend.

the class CustomFieldAdaptersTest method testAdapterForGenericCustomField.

@Test
public void testAdapterForGenericCustomField() {
    OtherCustomField customField = new OtherCustomField();
    customField.setFieldType(CustomizationFieldType.HYPERLINK);
    DefaultCustomFieldAdapter<CustomFieldType> adapter1 = new DefaultCustomFieldAdapter<>(BasicRecordType.OTHER_CUSTOM_FIELD, true);
    assertTrue(adapter1.appliesTo("opportunity", customField));
    assertEquals(CustomFieldRefType.STRING, adapter1.apply(customField));
    DefaultCustomFieldAdapter<CustomFieldType> adapter2 = new DefaultCustomFieldAdapter<>(BasicRecordType.OTHER_CUSTOM_FIELD, false);
    assertFalse(adapter2.appliesTo("opportunity", customField));
}
Also used : OtherCustomField(com.netsuite.webservices.test.setup.customization.OtherCustomField) CustomFieldType(com.netsuite.webservices.test.setup.customization.CustomFieldType) Test(org.junit.Test)

Example 3 with CustomFieldType

use of com.netsuite.webservices.test.setup.customization.CustomFieldType in project components by Talend.

the class NetSuiteMockTestBase method createCustomFieldTypes.

protected Map<String, CustomFieldType> createCustomFieldTypes(Map<String, CustomFieldSpec<RecordType, CustomizationFieldType>> customFieldSpecs) throws Exception {
    Map<String, CustomFieldType> customFieldTypeMap = new HashMap<>();
    for (CustomFieldSpec<RecordType, CustomizationFieldType> spec : customFieldSpecs.values()) {
        CustomFieldType fieldRecord = (CustomFieldType) spec.getFieldTypeClass().newInstance();
        Beans.setProperty(fieldRecord, "internalId", spec.getInternalId());
        fieldRecord.setScriptId(spec.getScriptId());
        fieldRecord.setFieldType(spec.getFieldType());
        if (spec.getAppliesTo() != null) {
            for (String appliesTo : spec.getAppliesTo()) {
                Beans.setProperty(fieldRecord, appliesTo, Boolean.TRUE);
            }
        }
        customFieldTypeMap.put(fieldRecord.getScriptId(), fieldRecord);
    }
    return customFieldTypeMap;
}
Also used : CustomizationFieldType(com.netsuite.webservices.test.setup.customization.types.CustomizationFieldType) RecordType(com.netsuite.webservices.test.platform.core.types.RecordType) CustomRecordType(com.netsuite.webservices.test.setup.customization.CustomRecordType) HashMap(java.util.HashMap) CustomFieldType(com.netsuite.webservices.test.setup.customization.CustomFieldType)

Aggregations

CustomFieldType (com.netsuite.webservices.test.setup.customization.CustomFieldType)3 CustomRecordType (com.netsuite.webservices.test.setup.customization.CustomRecordType)2 RecordType (com.netsuite.webservices.test.platform.core.types.RecordType)1 CustomRecordTypeFieldList (com.netsuite.webservices.test.setup.customization.CustomRecordTypeFieldList)1 OtherCustomField (com.netsuite.webservices.test.setup.customization.OtherCustomField)1 CustomizationFieldType (com.netsuite.webservices.test.setup.customization.types.CustomizationFieldType)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1