Search in sources :

Example 1 with GetListResponse

use of com.netsuite.webservices.test.platform.messages.GetListResponse in project components by Talend.

the class NetSuitePortTypeMockAdapterImpl method getList.

public GetListResponse getList(GetListRequest parameters) throws InvalidSessionFault, ExceededUsageLimitFault, UnexpectedErrorFault, ExceededRequestLimitFault, ExceededRequestSizeFault, ExceededConcurrentRequestLimitFault, InvalidCredentialsFault, InsufficientPermissionFault, ExceededRecordCountFault {
    GetListResponse response = null;
    if (port != null) {
        response = port.getList(parameters);
    }
    if (response == null) {
        response = new GetListResponse();
        ReadResponseList readResponseList = new ReadResponseList();
        readResponseList.setStatus(createSuccessStatus());
        response.setReadResponseList(readResponseList);
    }
    return response;
}
Also used : GetListResponse(com.netsuite.webservices.test.platform.messages.GetListResponse) ReadResponseList(com.netsuite.webservices.test.platform.messages.ReadResponseList)

Example 2 with GetListResponse

use of com.netsuite.webservices.test.platform.messages.GetListResponse 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 3 with GetListResponse

use of com.netsuite.webservices.test.platform.messages.GetListResponse in project components by Talend.

the class NetSuiteMockTestBase method mockGetListRequestResults.

protected <T extends Record> void mockGetListRequestResults(final List<T> records) throws Exception {
    final NetSuitePortType port = webServiceMockTestFixture.getPortMock();
    when(port.getList(any(GetListRequest.class))).then(new Answer<GetListResponse>() {

        @Override
        public GetListResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            GetListRequest request = (GetListRequest) invocationOnMock.getArguments()[0];
            GetListResponse response = new GetListResponse();
            ReadResponseList readResponseList = new ReadResponseList();
            int count = request.getBaseRef().size();
            for (int i = 0; i < count; i++) {
                ReadResponse readResponse = new ReadResponse();
                T record = records != null ? records.get(i) : null;
                if (record != null) {
                    readResponse.setStatus(createSuccessStatus());
                } else {
                    readResponse.setStatus(createNotFoundStatus());
                }
                readResponse.setRecord(record);
                readResponseList.getReadResponse().add(readResponse);
            }
            response.setReadResponseList(readResponseList);
            return response;
        }
    });
}
Also used : NetSuitePortType(com.netsuite.webservices.test.platform.NetSuitePortType) GetListResponse(com.netsuite.webservices.test.platform.messages.GetListResponse) ReadResponse(com.netsuite.webservices.test.platform.messages.ReadResponse) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ReadResponseList(com.netsuite.webservices.test.platform.messages.ReadResponseList) GetListRequest(com.netsuite.webservices.test.platform.messages.GetListRequest)

Aggregations

GetListResponse (com.netsuite.webservices.test.platform.messages.GetListResponse)3 GetListRequest (com.netsuite.webservices.test.platform.messages.GetListRequest)2 ReadResponseList (com.netsuite.webservices.test.platform.messages.ReadResponseList)2 NetSuitePortType (com.netsuite.webservices.test.platform.NetSuitePortType)1 RecordRef (com.netsuite.webservices.test.platform.core.RecordRef)1 LoginRequest (com.netsuite.webservices.test.platform.messages.LoginRequest)1 ReadResponse (com.netsuite.webservices.test.platform.messages.ReadResponse)1 PurchaseOrder (com.netsuite.webservices.test.transactions.purchases.PurchaseOrder)1 Test (org.junit.Test)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 TypeDesc (org.talend.components.netsuite.client.model.TypeDesc)1