Search in sources :

Example 6 with PurchaseOrder

use of com.netsuite.webservices.test.transactions.purchases.PurchaseOrder in project components by Talend.

the class NetSuiteClientServiceTest method testGet.

@Test
public void testGet() throws Exception {
    TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("PurchaseOrder");
    TypeDesc refTypeDesc = clientService.getMetaDataSource().getTypeInfo("RecordRef");
    PurchaseOrder record = new NsObjectComposer<PurchaseOrder>(clientService.getMetaDataSource(), typeDesc).composeObject();
    RecordRef recordRef = new NsObjectComposer<RecordRef>(clientService.getMetaDataSource(), refTypeDesc).composeObject();
    GetResponse response = new GetResponse();
    response.setReadResponse(createSuccessReadResponse(record));
    when(port.get(notNull(GetRequest.class))).thenReturn(response);
    clientService.get(recordRef);
    verify(port, times(1)).login(notNull(LoginRequest.class));
    verify(port, times(1)).get(notNull(GetRequest.class));
    NsReadResponse readResponse = clientService.get(null);
    assertNull(readResponse.getStatus());
    assertNull(readResponse.getRecord());
}
Also used : GetRequest(com.netsuite.webservices.test.platform.messages.GetRequest) 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) GetResponse(com.netsuite.webservices.test.platform.messages.GetResponse) Test(org.junit.Test)

Example 7 with PurchaseOrder

use of com.netsuite.webservices.test.transactions.purchases.PurchaseOrder in project components by Talend.

the class NetSuiteClientServiceTest method testAddList.

@Test
public void testAddList() throws Exception {
    TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("PurchaseOrder");
    List<PurchaseOrder> recordList = makeNsObjects(new NsObjectComposer<PurchaseOrder>(clientService.getMetaDataSource(), typeDesc), 10);
    AddListResponse response = new AddListResponse();
    response.setWriteResponseList(createSuccessWriteResponseList(recordList.size()));
    when(port.addList(notNull(AddListRequest.class))).thenReturn(response);
    clientService.addList(recordList);
    verify(port, times(1)).login(notNull(LoginRequest.class));
    verify(port, times(1)).addList(notNull(AddListRequest.class));
    List<NsWriteResponse<RecordRef>> writeResponses = clientService.addList(null);
    assertTrue(writeResponses.isEmpty());
}
Also used : AddListResponse(com.netsuite.webservices.test.platform.messages.AddListResponse) AddListRequest(com.netsuite.webservices.test.platform.messages.AddListRequest) 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 8 with PurchaseOrder

use of com.netsuite.webservices.test.transactions.purchases.PurchaseOrder in project components by Talend.

the class NetSuiteClientServiceTest method testAdd.

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

Aggregations

LoginRequest (com.netsuite.webservices.test.platform.messages.LoginRequest)8 PurchaseOrder (com.netsuite.webservices.test.transactions.purchases.PurchaseOrder)8 Test (org.junit.Test)8 TypeDesc (org.talend.components.netsuite.client.model.TypeDesc)8 RecordRef (com.netsuite.webservices.test.platform.core.RecordRef)2 AddListRequest (com.netsuite.webservices.test.platform.messages.AddListRequest)1 AddListResponse (com.netsuite.webservices.test.platform.messages.AddListResponse)1 AddRequest (com.netsuite.webservices.test.platform.messages.AddRequest)1 AddResponse (com.netsuite.webservices.test.platform.messages.AddResponse)1 GetListRequest (com.netsuite.webservices.test.platform.messages.GetListRequest)1 GetListResponse (com.netsuite.webservices.test.platform.messages.GetListResponse)1 GetRequest (com.netsuite.webservices.test.platform.messages.GetRequest)1 GetResponse (com.netsuite.webservices.test.platform.messages.GetResponse)1 UpdateListRequest (com.netsuite.webservices.test.platform.messages.UpdateListRequest)1 UpdateListResponse (com.netsuite.webservices.test.platform.messages.UpdateListResponse)1 UpdateRequest (com.netsuite.webservices.test.platform.messages.UpdateRequest)1 UpdateResponse (com.netsuite.webservices.test.platform.messages.UpdateResponse)1 UpsertListRequest (com.netsuite.webservices.test.platform.messages.UpsertListRequest)1 UpsertListResponse (com.netsuite.webservices.test.platform.messages.UpsertListResponse)1 UpsertRequest (com.netsuite.webservices.test.platform.messages.UpsertRequest)1