use of com.netsuite.webservices.v2016_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();
if (record != null) {
readResponse.setStatus(createSuccessStatus());
} else {
readResponse.setStatus(createNotFoundStatus());
}
readResponse.setRecord(record);
response.setReadResponse(readResponse);
return response;
}
});
}
use of com.netsuite.webservices.v2016_2.platform.core.Record in project components by Talend.
the class NetSuiteClientServiceIT method testSearchCustomRecord.
@Test
public void testSearchCustomRecord() throws Exception {
NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
connection.login();
Collection<RecordTypeInfo> recordTypes = connection.getMetaDataSource().getRecordTypes();
RecordTypeInfo recordType = getCustomRecordType(recordTypes, "customrecord_campaign_revenue");
SearchQuery searchQuery = connection.newSearch();
searchQuery.target(recordType.getName());
SearchResultSet<Record> rs = searchQuery.search();
int count = 10;
while (rs.next() && count-- > 0) {
Record record = rs.get();
assertNotNull(record);
}
}
use of com.netsuite.webservices.v2016_2.platform.core.Record in project components by Talend.
the class NetSuiteClientServiceIT method testConnectAndLogin.
@Test
public void testConnectAndLogin() throws Exception {
NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
connection.login();
SearchResultSet<Record> rs = connection.newSearch().target("Account").condition(new SearchCondition("Type", "List.anyOf", Arrays.asList("Bank"))).search();
int count = 10;
int retrievedCount = 0;
while (rs.next() && count-- > 0) {
Record record = rs.get();
assertEquals(AccountType.BANK, getProperty(record, "acctType"));
retrievedCount++;
}
assertTrue(retrievedCount > 1);
}
use of com.netsuite.webservices.v2016_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.v2016_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("No records");
}
Record record = rs.get();
IndexedRecord indexedRecord = transducer.read(record);
logger.debug("Indexed record: {}", indexedRecord);
}
Aggregations