Search in sources :

Example 1 with GetListRequest

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

NetSuitePortType (com.netsuite.webservices.test.platform.NetSuitePortType)1 GetListRequest (com.netsuite.webservices.test.platform.messages.GetListRequest)1 GetListResponse (com.netsuite.webservices.test.platform.messages.GetListResponse)1 ReadResponse (com.netsuite.webservices.test.platform.messages.ReadResponse)1 ReadResponseList (com.netsuite.webservices.test.platform.messages.ReadResponseList)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1