Search in sources :

Example 1 with ReadResponse

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

the class NetSuiteClientServiceTest method createSuccessReadResponseList.

private ReadResponseList createSuccessReadResponseList(List<? extends Record> recordList) {
    ReadResponseList readResponseList = new ReadResponseList();
    readResponseList.setStatus(NetSuitePortTypeMockAdapterImpl.createSuccessStatus());
    for (int i = 0; i < recordList.size(); i++) {
        Record record = recordList.get(i);
        ReadResponse readResponse = createSuccessReadResponse(record);
        readResponseList.getReadResponse().add(readResponse);
    }
    return readResponseList;
}
Also used : ReadResponse(com.netsuite.webservices.test.platform.messages.ReadResponse) ReadResponseList(com.netsuite.webservices.test.platform.messages.ReadResponseList) Record(com.netsuite.webservices.test.platform.core.Record)

Example 2 with ReadResponse

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

the class NetSuiteClientServiceTest method createSuccessReadResponse.

private ReadResponse createSuccessReadResponse(Record record) {
    ReadResponse readResponse = new ReadResponse();
    readResponse.setStatus(NetSuitePortTypeMockAdapterImpl.createSuccessStatus());
    readResponse.setRecord(record);
    return readResponse;
}
Also used : ReadResponse(com.netsuite.webservices.test.platform.messages.ReadResponse)

Example 3 with ReadResponse

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

the class NetSuiteMockTestBase method mockGetRequestResults.

protected <T extends Record> void mockGetRequestResults(final T record) throws Exception {
    final NetSuitePortType port = webServiceMockTestFixture.getPortMock();
    when(port.get(any(GetRequest.class))).then(new Answer<GetResponse>() {

        @Override
        public GetResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
            GetResponse response = new GetResponse();
            ReadResponse readResponse = new ReadResponse();
            if (record != null) {
                readResponse.setStatus(createSuccessStatus());
            } else {
                readResponse.setStatus(createNotFoundStatus());
            }
            readResponse.setRecord(record);
            response.setReadResponse(readResponse);
            return response;
        }
    });
}
Also used : NetSuitePortType(com.netsuite.webservices.test.platform.NetSuitePortType) ReadResponse(com.netsuite.webservices.test.platform.messages.ReadResponse) InvocationOnMock(org.mockito.invocation.InvocationOnMock) GetRequest(com.netsuite.webservices.test.platform.messages.GetRequest) GetResponse(com.netsuite.webservices.test.platform.messages.GetResponse)

Example 4 with ReadResponse

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

ReadResponse (com.netsuite.webservices.test.platform.messages.ReadResponse)4 NetSuitePortType (com.netsuite.webservices.test.platform.NetSuitePortType)2 ReadResponseList (com.netsuite.webservices.test.platform.messages.ReadResponseList)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Record (com.netsuite.webservices.test.platform.core.Record)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