use of com.netsuite.webservices.v2014_2.platform.core.Record 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();
readResponse.setStatus(createSuccessStatus());
readResponse.setRecord(record);
response.setReadResponse(readResponse);
return response;
}
});
}
use of com.netsuite.webservices.v2014_2.platform.core.Record 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;
}
});
}
use of com.netsuite.webservices.v2014_2.platform.core.Record in project components by Talend.
the class NsObjectInputTransducerIT method testIncludeAllFields.
@Test
public void testIncludeAllFields() throws Exception {
NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
connection.login();
TypeDesc basicTypeDesc = connection.getBasicMetaData().getTypeInfo("Opportunity");
Schema schema = getDynamicSchema();
NsObjectInputTransducer transducer = new NsObjectInputTransducer(connection, schema, basicTypeDesc.getTypeName());
SearchResultSet<Record> rs = connection.newSearch().target(basicTypeDesc.getTypeName()).search();
TypeDesc typeDesc = connection.getMetaDataSource().getTypeInfo(basicTypeDesc.getTypeName());
int count = 0;
while (count++ < connection.getSearchPageSize() && rs.next()) {
Record record = rs.get();
IndexedRecord indexedRecord = transducer.read(record);
logger.debug("Indexed record: {}", indexedRecord);
Schema recordSchema = indexedRecord.getSchema();
assertEquals(typeDesc.getFields().size(), recordSchema.getFields().size());
for (FieldDesc fieldDesc : typeDesc.getFields()) {
String fieldName = fieldDesc.getName();
Schema.Field field = recordSchema.getField(fieldName);
assertNotNull(field);
Object value = indexedRecord.get(field.pos());
}
}
if (count == 0) {
throw new IllegalStateException("No records");
}
}
use of com.netsuite.webservices.v2014_2.platform.core.Record in project components by Talend.
the class NsObjectInputTransducerIT method testBasic.
@Test
public void testBasic() throws Exception {
NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
connection.login();
TypeDesc typeDesc = connection.getMetaDataSource().getTypeInfo("Opportunity");
Schema schema = NetSuiteDatasetRuntimeImpl.inferSchemaForType(typeDesc.getTypeName(), typeDesc.getFields());
NsObjectInputTransducer transducer = new NsObjectInputTransducer(connection, schema, typeDesc.getTypeName());
SearchResultSet<Record> rs = connection.newSearch().target(typeDesc.getTypeName()).search();
if (!rs.next()) {
throw new IllegalStateException("Not records");
}
Record record = rs.get();
IndexedRecord indexedRecord = transducer.read(record);
logger.debug("Indexed record: {}", indexedRecord);
}
use of com.netsuite.webservices.v2014_2.platform.core.Record in project components by Talend.
the class NetSuiteClientServiceImpl method toRecordList.
public static <RecT> List<Record> toRecordList(List<RecT> nsRecordList) {
List<Record> recordList = new ArrayList<>(nsRecordList.size());
for (RecT nsRecord : nsRecordList) {
Record r = (Record) nsRecord;
recordList.add(r);
}
return recordList;
}
Aggregations