Search in sources :

Example 11 with TypeDesc

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

the class MetaDataSourceTest method testGetTypeInfoByClass.

@Test
public void testGetTypeInfoByClass() {
    TypeDesc typeDesc = metaDataSource.getTypeInfo(Account.class);
    assertNotNull(typeDesc);
}
Also used : SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) RecordTypeDesc(org.talend.components.netsuite.client.model.RecordTypeDesc) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) Test(org.junit.Test)

Example 12 with TypeDesc

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

the class NetSuiteClientServiceTest method testGetList.

@Test
public void testGetList() throws Exception {
    TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("PurchaseOrder");
    TypeDesc refTypeDesc = clientService.getMetaDataSource().getTypeInfo("RecordRef");
    List<PurchaseOrder> recordList = makeNsObjects(new NsObjectComposer<PurchaseOrder>(clientService.getMetaDataSource(), typeDesc), 10);
    List<RecordRef> recordRefList = makeNsObjects(new NsObjectComposer<RecordRef>(clientService.getMetaDataSource(), refTypeDesc), 10);
    GetListResponse response = new GetListResponse();
    response.setReadResponseList(createSuccessReadResponseList(recordList));
    when(port.getList(notNull(GetListRequest.class))).thenReturn(response);
    clientService.getList(recordRefList);
    verify(port, times(1)).login(notNull(LoginRequest.class));
    verify(port, times(1)).getList(notNull(GetListRequest.class));
    List<NsReadResponse<Record>> readResponses = clientService.getList(null);
    assertTrue(readResponses.isEmpty());
}
Also used : GetListResponse(com.netsuite.webservices.test.platform.messages.GetListResponse) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) RecordRef(com.netsuite.webservices.test.platform.core.RecordRef) PurchaseOrder(com.netsuite.webservices.test.transactions.purchases.PurchaseOrder) LoginRequest(com.netsuite.webservices.test.platform.messages.LoginRequest) GetListRequest(com.netsuite.webservices.test.platform.messages.GetListRequest) Test(org.junit.Test)

Example 13 with TypeDesc

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

the class NetSuiteClientServiceTest method testUpsertList.

@Test
public void testUpsertList() throws Exception {
    TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("PurchaseOrder");
    List<PurchaseOrder> recordList = makeNsObjects(new NsObjectComposer<PurchaseOrder>(clientService.getMetaDataSource(), typeDesc), 10);
    UpsertListResponse response = new UpsertListResponse();
    response.setWriteResponseList(createSuccessWriteResponseList(recordList.size()));
    when(port.upsertList(notNull(UpsertListRequest.class))).thenReturn(response);
    clientService.upsertList(recordList);
    verify(port, times(1)).login(notNull(LoginRequest.class));
    verify(port, times(1)).upsertList(notNull(UpsertListRequest.class));
    List<NsWriteResponse<RecordRef>> writeResponses = clientService.upsertList(null);
    assertTrue(writeResponses.isEmpty());
}
Also used : UpsertListRequest(com.netsuite.webservices.test.platform.messages.UpsertListRequest) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) PurchaseOrder(com.netsuite.webservices.test.transactions.purchases.PurchaseOrder) UpsertListResponse(com.netsuite.webservices.test.platform.messages.UpsertListResponse) LoginRequest(com.netsuite.webservices.test.platform.messages.LoginRequest) Test(org.junit.Test)

Example 14 with TypeDesc

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

the class NetSuiteClientServiceTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("PurchaseOrder");
    PurchaseOrder record = new NsObjectComposer<PurchaseOrder>(clientService.getMetaDataSource(), typeDesc).composeObject();
    UpdateResponse response = new UpdateResponse();
    response.setWriteResponse(createSuccessWriteResponse());
    when(port.update(notNull(UpdateRequest.class))).thenReturn(response);
    clientService.update(record);
    verify(port, times(1)).login(notNull(LoginRequest.class));
    verify(port, times(1)).update(notNull(UpdateRequest.class));
    NsWriteResponse writeResponse = clientService.update(null);
    assertNull(writeResponse.getStatus());
    assertNull(writeResponse.getRef());
}
Also used : UpdateResponse(com.netsuite.webservices.test.platform.messages.UpdateResponse) UpdateRequest(com.netsuite.webservices.test.platform.messages.UpdateRequest) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) PurchaseOrder(com.netsuite.webservices.test.transactions.purchases.PurchaseOrder) LoginRequest(com.netsuite.webservices.test.platform.messages.LoginRequest) Test(org.junit.Test)

Example 15 with TypeDesc

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

the class NetSuiteClientServiceTest method testUpdateList.

@Test
public void testUpdateList() throws Exception {
    TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("PurchaseOrder");
    List<PurchaseOrder> recordList = makeNsObjects(new NsObjectComposer<PurchaseOrder>(clientService.getMetaDataSource(), typeDesc), 10);
    UpdateListResponse response = new UpdateListResponse();
    response.setWriteResponseList(createSuccessWriteResponseList(recordList.size()));
    when(port.updateList(notNull(UpdateListRequest.class))).thenReturn(response);
    clientService.updateList(recordList);
    verify(port, times(1)).login(notNull(LoginRequest.class));
    verify(port, times(1)).updateList(notNull(UpdateListRequest.class));
    List<NsWriteResponse<RecordRef>> writeResponses = clientService.updateList(null);
    assertTrue(writeResponses.isEmpty());
}
Also used : UpdateListResponse(com.netsuite.webservices.test.platform.messages.UpdateListResponse) UpdateListRequest(com.netsuite.webservices.test.platform.messages.UpdateListRequest) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) PurchaseOrder(com.netsuite.webservices.test.transactions.purchases.PurchaseOrder) LoginRequest(com.netsuite.webservices.test.platform.messages.LoginRequest) Test(org.junit.Test)

Aggregations

TypeDesc (org.talend.components.netsuite.client.model.TypeDesc)48 Test (org.junit.Test)41 Schema (org.apache.avro.Schema)31 IndexedRecord (org.apache.avro.generic.IndexedRecord)23 ArrayList (java.util.ArrayList)14 NetSuiteDatasetRuntime (org.talend.components.netsuite.NetSuiteDatasetRuntime)13 LoginRequest (com.netsuite.webservices.test.platform.messages.LoginRequest)12 NetSuiteRuntime (org.talend.components.netsuite.NetSuiteRuntime)10 FieldDesc (org.talend.components.netsuite.client.model.FieldDesc)10 RecordTypeDesc (org.talend.components.netsuite.client.model.RecordTypeDesc)10 SearchRecordTypeDesc (org.talend.components.netsuite.client.model.SearchRecordTypeDesc)10 CustomFieldDesc (org.talend.components.netsuite.client.model.CustomFieldDesc)9 PurchaseOrder (com.netsuite.webservices.test.transactions.purchases.PurchaseOrder)8 NetSuiteWebServiceMockTestFixture.assertIndexedRecord (org.talend.components.netsuite.NetSuiteWebServiceMockTestFixture.assertIndexedRecord)8 RecordTypeInfo (org.talend.components.netsuite.client.model.RecordTypeInfo)8 RecordRef (com.netsuite.webservices.test.platform.core.RecordRef)7 CustomRecord (com.netsuite.webservices.test.setup.customization.CustomRecord)7 NetSuiteException (org.talend.components.netsuite.client.NetSuiteException)6 CustomRecordTypeInfo (org.talend.components.netsuite.client.model.CustomRecordTypeInfo)6 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4