Search in sources :

Example 1 with SearchResponse

use of com.netsuite.webservices.v2016_2.platform.messages.SearchResponse in project components by Talend.

the class NetSuiteMockTestBase method mockSearchRequestResults.

protected <T extends Record> void mockSearchRequestResults(List<T> recordList, int pageSize) throws Exception {
    final NetSuitePortType port = webServiceMockTestFixture.getPortMock();
    final List<SearchResult> pageResults = makeRecordPages(recordList, pageSize);
    when(port.search(any(SearchRequest.class))).then(new Answer<SearchResponse>() {

        @Override
        public SearchResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            SearchResponse response = new SearchResponse();
            response.setSearchResult(pageResults.get(0));
            return response;
        }
    });
    when(port.searchMoreWithId(any(SearchMoreWithIdRequest.class))).then(new Answer<SearchMoreWithIdResponse>() {

        @Override
        public SearchMoreWithIdResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            SearchMoreWithIdRequest request = (SearchMoreWithIdRequest) invocationOnMock.getArguments()[0];
            SearchMoreWithIdResponse response = new SearchMoreWithIdResponse();
            response.setSearchResult(pageResults.get(request.getPageIndex() - 1));
            return response;
        }
    });
}
Also used : NetSuitePortType(com.netsuite.webservices.v2014_2.platform.NetSuitePortType) SearchRequest(com.netsuite.webservices.v2014_2.platform.messages.SearchRequest) SearchMoreWithIdResponse(com.netsuite.webservices.v2014_2.platform.messages.SearchMoreWithIdResponse) InvocationOnMock(org.mockito.invocation.InvocationOnMock) SearchResult(com.netsuite.webservices.v2014_2.platform.core.SearchResult) SearchResponse(com.netsuite.webservices.v2014_2.platform.messages.SearchResponse) SearchMoreWithIdRequest(com.netsuite.webservices.v2014_2.platform.messages.SearchMoreWithIdRequest)

Example 2 with SearchResponse

use of com.netsuite.webservices.v2016_2.platform.messages.SearchResponse in project components by Talend.

the class NetSuiteMockTestBase method mockSearchRequestResults.

protected <T extends Record> void mockSearchRequestResults(List<T> recordList, int pageSize) throws Exception {
    final NetSuitePortType port = webServiceMockTestFixture.getPortMock();
    final List<SearchResult> pageResults = makeRecordPages(recordList, pageSize);
    when(port.search(any(SearchRequest.class))).then(new Answer<SearchResponse>() {

        @Override
        public SearchResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            SearchResponse response = new SearchResponse();
            response.setSearchResult(pageResults.get(0));
            return response;
        }
    });
    when(port.searchMoreWithId(any(SearchMoreWithIdRequest.class))).then(new Answer<SearchMoreWithIdResponse>() {

        @Override
        public SearchMoreWithIdResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            SearchMoreWithIdRequest request = (SearchMoreWithIdRequest) invocationOnMock.getArguments()[0];
            SearchMoreWithIdResponse response = new SearchMoreWithIdResponse();
            response.setSearchResult(pageResults.get(request.getPageIndex() - 1));
            return response;
        }
    });
}
Also used : NetSuitePortType(com.netsuite.webservices.v2016_2.platform.NetSuitePortType) SearchRequest(com.netsuite.webservices.v2016_2.platform.messages.SearchRequest) SearchMoreWithIdResponse(com.netsuite.webservices.v2016_2.platform.messages.SearchMoreWithIdResponse) InvocationOnMock(org.mockito.invocation.InvocationOnMock) SearchResult(com.netsuite.webservices.v2016_2.platform.core.SearchResult) SearchResponse(com.netsuite.webservices.v2016_2.platform.messages.SearchResponse) SearchMoreWithIdRequest(com.netsuite.webservices.v2016_2.platform.messages.SearchMoreWithIdRequest)

Aggregations

InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 NetSuitePortType (com.netsuite.webservices.v2014_2.platform.NetSuitePortType)1 SearchResult (com.netsuite.webservices.v2014_2.platform.core.SearchResult)1 SearchMoreWithIdRequest (com.netsuite.webservices.v2014_2.platform.messages.SearchMoreWithIdRequest)1 SearchMoreWithIdResponse (com.netsuite.webservices.v2014_2.platform.messages.SearchMoreWithIdResponse)1 SearchRequest (com.netsuite.webservices.v2014_2.platform.messages.SearchRequest)1 SearchResponse (com.netsuite.webservices.v2014_2.platform.messages.SearchResponse)1 NetSuitePortType (com.netsuite.webservices.v2016_2.platform.NetSuitePortType)1 SearchResult (com.netsuite.webservices.v2016_2.platform.core.SearchResult)1 SearchMoreWithIdRequest (com.netsuite.webservices.v2016_2.platform.messages.SearchMoreWithIdRequest)1 SearchMoreWithIdResponse (com.netsuite.webservices.v2016_2.platform.messages.SearchMoreWithIdResponse)1 SearchRequest (com.netsuite.webservices.v2016_2.platform.messages.SearchRequest)1 SearchResponse (com.netsuite.webservices.v2016_2.platform.messages.SearchResponse)1