Search in sources :

Example 1 with RecordTypeInfo

use of org.talend.components.netsuite.client.model.RecordTypeInfo in project components by Talend.

the class NetSuiteClientServiceIT method testRetrieveCustomRecordTypes.

@Test
public void testRetrieveCustomRecordTypes() throws Exception {
    NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
    connection.login();
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    Collection<RecordTypeInfo> recordTypes = connection.getMetaDataSource().getRecordTypes();
    stopWatch.stop();
    for (RecordTypeInfo recordType : recordTypes) {
        logger.debug("Record type info: {}", recordType);
    }
}
Also used : RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) StopWatch(org.apache.commons.lang3.time.StopWatch) Test(org.junit.Test)

Example 2 with RecordTypeInfo

use of org.talend.components.netsuite.client.model.RecordTypeInfo in project components by Talend.

the class NetSuiteDatasetRuntimeTest method testGetSchemaForRecordWithCustomFields.

@Test
public void testGetSchemaForRecordWithCustomFields() throws Exception {
    final CustomMetaDataSource customMetaDataSource = new EmptyCustomMetaDataSource() {

        @Override
        public Map<String, CustomFieldDesc> getCustomFields(RecordTypeInfo recordTypeInfo) {
            try {
                if (recordTypeInfo.getName().equals("Account")) {
                    JsonNode fieldListNode = objectMapper.readTree(NetSuiteDatasetRuntimeTest.class.getResource("/test-data/customFields-1.json"));
                    Map<String, CustomFieldDesc> customFieldDescMap = TestUtils.readCustomFields(fieldListNode);
                    return customFieldDescMap;
                }
                return null;
            } catch (IOException e) {
                throw new NetSuiteException(e.getMessage(), e);
            }
        }
    };
    MetaDataSource metaDataSource = clientService.createDefaultMetaDataSource();
    metaDataSource.setCustomMetaDataSource(customMetaDataSource);
    NetSuiteDatasetRuntimeImpl datasetRuntime = new NetSuiteDatasetRuntimeImpl(metaDataSource);
    TypeDesc typeDesc = metaDataSource.getTypeInfo("Account");
    Schema s = datasetRuntime.getSchema(typeDesc.getTypeName());
    assertThat(s.getType(), is(Schema.Type.RECORD));
    assertThat(s.getName(), is("Account"));
    assertThat(s.getFields(), hasSize(typeDesc.getFields().size()));
    assertThat(s.getObjectProps().keySet(), Matchers.<String>empty());
    CustomFieldDesc fieldDesc = (CustomFieldDesc) typeDesc.getField("custom_field_1");
    Schema.Field f = getNsFieldByName(s, fieldDesc.getName());
    assertUnionType(f.schema(), Arrays.asList(Schema.Type.STRING, Schema.Type.NULL));
    assertThat(f.getObjectProps().keySet(), containsInAnyOrder(SchemaConstants.TALEND_COLUMN_DB_COLUMN_NAME, SchemaConstants.TALEND_COLUMN_DB_TYPE, NetSuiteSchemaConstants.NS_CUSTOM_FIELD, NetSuiteSchemaConstants.NS_CUSTOM_FIELD_SCRIPT_ID, NetSuiteSchemaConstants.NS_CUSTOM_FIELD_INTERNAL_ID, NetSuiteSchemaConstants.NS_CUSTOM_FIELD_CUSTOMIZATION_TYPE, NetSuiteSchemaConstants.NS_CUSTOM_FIELD_TYPE));
    assertThat(f.getProp(SchemaConstants.TALEND_COLUMN_DB_COLUMN_NAME), is(fieldDesc.getName()));
    CustomFieldDesc customFieldDesc = NetSuiteDatasetRuntimeImpl.readCustomField(f);
    assertThat(customFieldDesc.getName(), is(fieldDesc.getName()));
}
Also used : EmptyCustomMetaDataSource(org.talend.components.netsuite.client.EmptyCustomMetaDataSource) CustomMetaDataSource(org.talend.components.netsuite.client.CustomMetaDataSource) Schema(org.apache.avro.Schema) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) JsonNode(com.fasterxml.jackson.databind.JsonNode) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) IOException(java.io.IOException) EmptyCustomMetaDataSource(org.talend.components.netsuite.client.EmptyCustomMetaDataSource) MetaDataSource(org.talend.components.netsuite.client.MetaDataSource) EmptyCustomMetaDataSource(org.talend.components.netsuite.client.EmptyCustomMetaDataSource) CustomMetaDataSource(org.talend.components.netsuite.client.CustomMetaDataSource) RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) CustomFieldDesc(org.talend.components.netsuite.client.model.CustomFieldDesc) Test(org.junit.Test)

Example 3 with RecordTypeInfo

use of org.talend.components.netsuite.client.model.RecordTypeInfo in project components by Talend.

the class MetaDataSourceTest method testGetRecordTypes.

@Test
public void testGetRecordTypes() {
    Collection<RecordTypeInfo> recordTypeInfos = metaDataSource.getRecordTypes();
    assertNotNull(recordTypeInfos);
    assertFalse(recordTypeInfos.isEmpty());
    Set<String> recordTypeNames = new HashSet<>();
    for (RecordTypeInfo recordTypeInfo : recordTypeInfos) {
        assertNotNull(recordTypeInfo);
        recordTypeNames.add(recordTypeInfo.getName());
    }
    for (RecordTypeDesc recordTypeDesc : TestRecordTypeEnum.values()) {
        assertTrue(recordTypeNames.contains(recordTypeDesc.getTypeName()));
    }
    for (RecordTypeInfo recordTypeInfo : customMetaDataSource.getCustomRecordTypes()) {
        assertTrue(recordTypeNames.contains(recordTypeInfo.getName()));
    }
}
Also used : RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) RecordTypeDesc(org.talend.components.netsuite.client.model.RecordTypeDesc) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with RecordTypeInfo

use of org.talend.components.netsuite.client.model.RecordTypeInfo in project components by Talend.

the class NetSuiteClientServiceTest method testStandardMetaData.

@Test
public void testStandardMetaData() throws Exception {
    NetSuiteClientService<?> clientService = webServiceMockTestFixture.getClientService();
    Set<SearchRecordType> searchRecordTypeSet = new HashSet<>(Arrays.asList(SearchRecordType.values()));
    Set<String> searchRecordTypeNameSet = new HashSet<>();
    for (SearchRecordType searchRecordType : searchRecordTypeSet) {
        searchRecordTypeNameSet.add(toInitialUpper(searchRecordType.value()));
    }
    searchRecordTypeNameSet.add("InventoryDetail");
    searchRecordTypeNameSet.add("TimeEntry");
    for (String searchRecordType : searchRecordTypeNameSet) {
        try {
            SearchRecordTypeDesc searchRecordInfo = clientService.getMetaDataSource().getSearchRecordType(searchRecordType);
            assertNotNull("Search record def found: " + searchRecordType, searchRecordInfo);
        } catch (Exception e) {
            throw new AssertionError("Search record type: " + searchRecordType, e);
        }
    }
    Set<RecordType> recordTypeSet = new HashSet<>(Arrays.asList(RecordType.values()));
    Set<String> recordTypeNameSet = new HashSet<>();
    for (RecordType recordType : recordTypeSet) {
        recordTypeNameSet.add(toInitialUpper(recordType.value()));
    }
    recordTypeNameSet.add("InventoryDetail");
    recordTypeNameSet.add("TimeEntry");
    for (String recordType : recordTypeNameSet) {
        RecordTypeInfo recordTypeInfo = clientService.getMetaDataSource().getRecordType(recordType);
        assertNotNull("Record type def found: " + recordType, recordTypeInfo);
    }
}
Also used : SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) SearchRecordType(com.netsuite.webservices.v2014_2.platform.core.types.SearchRecordType) RecordType(com.netsuite.webservices.v2014_2.platform.core.types.RecordType) RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) SearchRecordType(com.netsuite.webservices.v2014_2.platform.core.types.SearchRecordType) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with RecordTypeInfo

use of org.talend.components.netsuite.client.model.RecordTypeInfo 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)

Aggregations

RecordTypeInfo (org.talend.components.netsuite.client.model.RecordTypeInfo)24 SearchRecordTypeDesc (org.talend.components.netsuite.client.model.SearchRecordTypeDesc)17 ArrayList (java.util.ArrayList)13 Test (org.junit.Test)12 CustomRecordTypeInfo (org.talend.components.netsuite.client.model.CustomRecordTypeInfo)11 RecordTypeDesc (org.talend.components.netsuite.client.model.RecordTypeDesc)11 CustomFieldDesc (org.talend.components.netsuite.client.model.CustomFieldDesc)9 TypeDesc (org.talend.components.netsuite.client.model.TypeDesc)8 Schema (org.apache.avro.Schema)7 FieldDesc (org.talend.components.netsuite.client.model.FieldDesc)7 HashSet (java.util.HashSet)5 NetSuiteException (org.talend.components.netsuite.client.NetSuiteException)5 ComponentException (org.talend.components.api.exception.ComponentException)4 Record (com.netsuite.webservices.test.platform.core.Record)3 SearchResult (com.netsuite.webservices.test.platform.core.SearchResult)3 Status (com.netsuite.webservices.test.platform.core.Status)3 SearchResponse (com.netsuite.webservices.test.platform.messages.SearchResponse)3 SearchResultSet (org.talend.components.netsuite.client.search.SearchResultSet)3 TestNetSuiteClientService (org.talend.components.netsuite.test.client.TestNetSuiteClientService)3 NamedThing (org.talend.daikon.NamedThing)3