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;
}
});
}
Aggregations