use of com.netsuite.webservices.test.platform.core.Record 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;
}
use of com.netsuite.webservices.test.platform.core.Record in project components by Talend.
the class SearchResultSetTest method testEmptyResult.
@Test
public void testEmptyResult() throws Exception {
NetSuiteClientService<?> conn = mock(NetSuiteClientService.class);
SearchResult result1 = new SearchResult();
Status status = new Status();
status.setIsSuccess(true);
result1.setStatus(status);
result1.setSearchId("abc123");
result1.setPageIndex(1);
result1.setTotalRecords(0);
result1.setTotalPages(0);
SearchResponse response1 = new SearchResponse();
response1.setSearchResult(result1);
AccountSearch nsSearchRecord1 = new AccountSearch();
NsSearchResult nsSearchResult1 = TestNetSuiteClientService.toNsSearchResult(result1);
when(conn.search(eq(nsSearchRecord1))).thenReturn(nsSearchResult1);
NetSuiteClientService<?> clientService = new TestNetSuiteClientService();
RecordTypeInfo recordTypeInfo = clientService.getMetaDataSource().getRecordType("Account");
SearchRecordTypeDesc searchRecordTypeDesc = clientService.getMetaDataSource().getSearchRecordType(recordTypeInfo.getRecordType().getSearchRecordType());
SearchResultSet<Record> resultSet = new SearchResultSet<>(conn, recordTypeInfo.getRecordType(), searchRecordTypeDesc, nsSearchResult1);
assertFalse(resultSet.next());
}
use of com.netsuite.webservices.test.platform.core.Record in project components by Talend.
the class NsObjectInputTransducerTest method testBasic.
@Test
public void testBasic() throws Exception {
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("Opportunity");
final List<Opportunity> recordList = makeNsObjects(new NsObjectComposer<Opportunity>(clientService.getMetaDataSource(), typeDesc), 10);
mockSearchRequestResults(recordList, 100);
Schema schema = NetSuiteDatasetRuntimeImpl.inferSchemaForType(typeDesc.getTypeName(), typeDesc.getFields());
NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
for (Record record : recordList) {
IndexedRecord indexedRecord = transducer.read(record);
assertIndexedRecord(typeDesc, indexedRecord);
}
}
use of com.netsuite.webservices.test.platform.core.Record in project components by Talend.
the class NsObjectInputTransducerTest method testDynamicSchemaWithDynamicColumnLast.
@Test
public void testDynamicSchemaWithDynamicColumnLast() throws Exception {
TypeDesc basicTypeDesc = clientService.getMetaDataSource().getTypeInfo("Check");
final List<Check> recordList = makeNsObjects(new NsObjectComposer<Check>(clientService.getMetaDataSource(), basicTypeDesc), 10);
mockSearchRequestResults(recordList, 100);
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo(basicTypeDesc.getTypeName());
Schema designSchema = SchemaBuilder.record(typeDesc.getTypeName()).fields().name("InternalId").type(NetSuiteDatasetRuntimeImpl.inferSchemaForField(typeDesc.getField("internalId"))).noDefault().name("TranId").type(NetSuiteDatasetRuntimeImpl.inferSchemaForField(typeDesc.getField("tranId"))).noDefault().name("LastModifiedDate").type(NetSuiteDatasetRuntimeImpl.inferSchemaForField(typeDesc.getField("lastModifiedDate"))).noDefault().endRecord();
designSchema.addProp(NetSuiteSchemaConstants.TALEND6_DYNAMIC_COLUMN_POSITION, "3");
designSchema.addProp(NetSuiteSchemaConstants.TALEND6_DYNAMIC_COLUMN_ID, "dynamic");
Schema schema = AvroUtils.setIncludeAllFields(designSchema, true);
NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
SearchResultSet<Record> rs = clientService.newSearch().target(basicTypeDesc.getTypeName()).search();
while (rs.next()) {
Record record = rs.get();
IndexedRecord indexedRecord = transducer.read(record);
assertIndexedRecord(typeDesc, indexedRecord);
}
}
use of com.netsuite.webservices.test.platform.core.Record in project components by Talend.
the class NsObjectInputTransducerTest method testDynamicSchemaWithDynamicColumnMiddle.
@Test
public void testDynamicSchemaWithDynamicColumnMiddle() throws Exception {
TypeDesc basicTypeDesc = clientService.getMetaDataSource().getTypeInfo("Check");
final List<Check> recordList = makeNsObjects(new NsObjectComposer<Check>(clientService.getMetaDataSource(), basicTypeDesc), 10);
mockSearchRequestResults(recordList, 100);
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo(basicTypeDesc.getTypeName());
Schema designSchema = SchemaBuilder.record(typeDesc.getTypeName()).fields().name("InternalId").type(NetSuiteDatasetRuntimeImpl.inferSchemaForField(typeDesc.getField("internalId"))).noDefault().name("TranId").type(NetSuiteDatasetRuntimeImpl.inferSchemaForField(typeDesc.getField("tranId"))).noDefault().name("LastModifiedDate").type(NetSuiteDatasetRuntimeImpl.inferSchemaForField(typeDesc.getField("lastModifiedDate"))).noDefault().endRecord();
designSchema.addProp(NetSuiteSchemaConstants.TALEND6_DYNAMIC_COLUMN_POSITION, "1");
designSchema.addProp(NetSuiteSchemaConstants.TALEND6_DYNAMIC_COLUMN_ID, "dynamic");
Schema schema = AvroUtils.setIncludeAllFields(designSchema, true);
NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
SearchResultSet<Record> rs = clientService.newSearch().target(basicTypeDesc.getTypeName()).search();
while (rs.next()) {
Record record = rs.get();
IndexedRecord indexedRecord = transducer.read(record);
assertIndexedRecord(typeDesc, indexedRecord);
}
}
Aggregations