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