Search in sources :

Example 1 with Account

use of com.netsuite.webservices.test.lists.accounting.Account in project components by Talend.

the class ValueConverterTest method testJsonConverterComplexObject.

@Test
public void testJsonConverterComplexObject() throws Exception {
    NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
    Account account1 = new SimpleObjectComposer<>(Account.class).composeObject();
    RecordRef recordRef1 = new RecordRef();
    recordRef1.setInternalId("120001");
    recordRef1.setName("Talend France");
    RecordRef recordRef2 = new RecordRef();
    recordRef2.setInternalId("120002");
    recordRef2.setName("Talend China");
    RecordRefList recordRefList1 = new RecordRefList();
    recordRefList1.getRecordRef().add(recordRef1);
    recordRefList1.getRecordRef().add(recordRef2);
    account1.setSubsidiaryList(recordRefList1);
    BooleanCustomFieldRef customFieldRef1 = new BooleanCustomFieldRef();
    customFieldRef1.setInternalId("100001");
    customFieldRef1.setScriptId("custentity_field1");
    customFieldRef1.setValue(true);
    StringCustomFieldRef customFieldRef2 = new StringCustomFieldRef();
    customFieldRef2.setInternalId("100002");
    customFieldRef2.setScriptId("custentity_field2");
    customFieldRef2.setValue("test123");
    CustomFieldList customFieldList = new CustomFieldList();
    customFieldList.getCustomField().add(customFieldRef1);
    customFieldList.getCustomField().add(customFieldRef2);
    account1.setCustomFieldList(customFieldList);
    AvroConverter<Account, String> converter1 = (AvroConverter<Account, String>) transducer.getValueConverter(account1.getClass());
    assertEquals(AvroUtils._string(), converter1.getSchema());
    assertEquals(account1.getClass(), converter1.getDatumClass());
    String testJson1 = converter1.convertToAvro(account1);
    assertNotNull(testJson1);
    Account testAccount1 = converter1.convertToDatum(testJson1);
    assertNotNull(testAccount1);
}
Also used : RecordRefList(com.netsuite.webservices.test.platform.core.RecordRefList) Account(com.netsuite.webservices.test.lists.accounting.Account) RecordRef(com.netsuite.webservices.test.platform.core.RecordRef) BooleanCustomFieldRef(com.netsuite.webservices.test.platform.core.BooleanCustomFieldRef) NsObjectInputTransducer(org.talend.components.netsuite.input.NsObjectInputTransducer) CustomFieldList(com.netsuite.webservices.test.platform.core.CustomFieldList) StringCustomFieldRef(com.netsuite.webservices.test.platform.core.StringCustomFieldRef) AvroConverter(org.talend.daikon.avro.converter.AvroConverter) Test(org.junit.Test)

Example 2 with Account

use of com.netsuite.webservices.test.lists.accounting.Account in project components by Talend.

the class SearchResultSetTest method testPagination.

@Test
public void testPagination() throws Exception {
    NetSuiteClientService<?> conn = mock(NetSuiteClientService.class);
    List<Record> page1 = new ArrayList<>();
    for (int i = 0; i < 1000; i++) {
        page1.add(new Account());
    }
    List<Record> page2 = new ArrayList<>();
    for (int i = 0; i < 750; i++) {
        page2.add(new Account());
    }
    SearchResult result1 = new SearchResult();
    Status status = new Status();
    status.setIsSuccess(true);
    result1.setStatus(status);
    result1.setSearchId("abc123");
    result1.setPageIndex(1);
    result1.setTotalRecords(page1.size() + page2.size());
    result1.setTotalPages(2);
    result1.setRecordList(new RecordList());
    result1.getRecordList().getRecord().addAll(page1);
    SearchResult result2 = new SearchResult();
    result2.setStatus(status);
    result2.setSearchId(result1.getSearchId());
    result2.setPageIndex(2);
    result2.setTotalRecords(result1.getTotalRecords());
    result2.setTotalPages(result1.getTotalPages());
    result2.setRecordList(new RecordList());
    result2.getRecordList().getRecord().addAll(page2);
    SearchResponse response1 = new SearchResponse();
    response1.setSearchResult(result1);
    SearchMoreWithIdResponse response2 = new SearchMoreWithIdResponse();
    response2.setSearchResult(result2);
    AccountSearch nsSearchRecord1 = new AccountSearch();
    NsSearchResult nsSearchResult1 = TestNetSuiteClientService.toNsSearchResult(result1);
    NsSearchResult nsSearchResult2 = TestNetSuiteClientService.toNsSearchResult(result2);
    when(conn.search(eq(nsSearchRecord1))).thenReturn(nsSearchResult1);
    when(conn.searchMoreWithId(eq("abc123"), eq(2))).thenReturn(nsSearchResult2);
    NetSuiteClientService<?> clientService = new TestNetSuiteClientService();
    RecordTypeInfo recordTypeInfo = clientService.getMetaDataSource().getRecordType("Account");
    SearchRecordTypeDesc searchRecordTypeDesc = clientService.getMetaDataSource().getSearchRecordType(recordTypeInfo.getRecordType().getSearchRecordType());
    SearchResultSet<Record> resultSet = new SearchResultSet<>(conn, recordTypeInfo.getRecordType(), searchRecordTypeDesc, nsSearchResult1);
    List<Object> recordList = new ArrayList<>();
    while (resultSet.next()) {
        Object record = resultSet.get();
        assertNotNull(record);
        recordList.add(record);
    }
    assertEquals(page1.size() + page2.size(), recordList.size());
}
Also used : Status(com.netsuite.webservices.test.platform.core.Status) Account(com.netsuite.webservices.test.lists.accounting.Account) TestNetSuiteClientService(org.talend.components.netsuite.test.client.TestNetSuiteClientService) SearchMoreWithIdResponse(com.netsuite.webservices.test.platform.messages.SearchMoreWithIdResponse) ArrayList(java.util.ArrayList) SearchResult(com.netsuite.webservices.test.platform.core.SearchResult) SearchResponse(com.netsuite.webservices.test.platform.messages.SearchResponse) AccountSearch(com.netsuite.webservices.test.lists.accounting.AccountSearch) SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) RecordList(com.netsuite.webservices.test.platform.core.RecordList) RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) SearchResultSet(org.talend.components.netsuite.client.search.SearchResultSet) Record(com.netsuite.webservices.test.platform.core.Record) Test(org.junit.Test)

Example 3 with Account

use of com.netsuite.webservices.test.lists.accounting.Account in project components by Talend.

the class TypeUtilsTest method testCreateInstance.

@Test
public void testCreateInstance() {
    Account instance = TypeUtils.createInstance(Account.class);
    assertNotNull(instance);
}
Also used : Account(com.netsuite.webservices.test.lists.accounting.Account) Test(org.junit.Test)

Aggregations

Account (com.netsuite.webservices.test.lists.accounting.Account)3 Test (org.junit.Test)3 AccountSearch (com.netsuite.webservices.test.lists.accounting.AccountSearch)1 BooleanCustomFieldRef (com.netsuite.webservices.test.platform.core.BooleanCustomFieldRef)1 CustomFieldList (com.netsuite.webservices.test.platform.core.CustomFieldList)1 Record (com.netsuite.webservices.test.platform.core.Record)1 RecordList (com.netsuite.webservices.test.platform.core.RecordList)1 RecordRef (com.netsuite.webservices.test.platform.core.RecordRef)1 RecordRefList (com.netsuite.webservices.test.platform.core.RecordRefList)1 SearchResult (com.netsuite.webservices.test.platform.core.SearchResult)1 Status (com.netsuite.webservices.test.platform.core.Status)1 StringCustomFieldRef (com.netsuite.webservices.test.platform.core.StringCustomFieldRef)1 SearchMoreWithIdResponse (com.netsuite.webservices.test.platform.messages.SearchMoreWithIdResponse)1 SearchResponse (com.netsuite.webservices.test.platform.messages.SearchResponse)1 ArrayList (java.util.ArrayList)1 RecordTypeInfo (org.talend.components.netsuite.client.model.RecordTypeInfo)1 SearchRecordTypeDesc (org.talend.components.netsuite.client.model.SearchRecordTypeDesc)1 SearchResultSet (org.talend.components.netsuite.client.search.SearchResultSet)1 NsObjectInputTransducer (org.talend.components.netsuite.input.NsObjectInputTransducer)1 TestNetSuiteClientService (org.talend.components.netsuite.test.client.TestNetSuiteClientService)1