use of org.talend.components.netsuite.client.search.SearchQuery in project components by Talend.
the class SearchQueryTest method testSearchOperatorWithoutValues.
@Test
public void testSearchOperatorWithoutValues() throws Exception {
SearchQuery s1 = clientService.newSearch();
s1.target("Account");
s1.condition(new SearchCondition("LegalName", "String.notEmpty", null));
SearchRecord sr1 = (SearchRecord) s1.toNativeQuery();
AccountSearch search = (AccountSearch) sr1;
AccountSearchBasic searchBasic = search.getBasic();
SearchStringField legalNameField = searchBasic.getLegalName();
Assert.assertEquals(SearchStringFieldOperator.NOT_EMPTY, legalNameField.getOperator());
assertNull(legalNameField.getSearchValue());
}
use of org.talend.components.netsuite.client.search.SearchQuery in project components by Talend.
the class SearchQueryTest method testSearchDateFieldWithPredefinedDate.
@Test
public void testSearchDateFieldWithPredefinedDate() throws Exception {
SearchQuery s1 = clientService.newSearch();
s1.target("Check");
s1.condition(new SearchCondition("TranDate", "PredefinedDate.lastBusinessWeek", null));
s1.condition(new SearchCondition("CustomDateField1", "PredefinedDate.lastBusinessWeek", null));
SearchRecord sr1 = (SearchRecord) s1.toNativeQuery();
assertNotNull(sr1);
Assert.assertEquals(TransactionSearch.class, sr1.getClass());
TransactionSearch search = (TransactionSearch) sr1;
assertNotNull(search.getBasic());
TransactionSearchBasic searchBasic = search.getBasic();
assertNotNull(searchBasic.getTranDate());
SearchEnumMultiSelectField typeField = searchBasic.getType();
assertNotNull(typeField);
assertNotNull(typeField.getSearchValue());
Assert.assertEquals(1, typeField.getSearchValue().size());
Assert.assertEquals(RecordType.CHECK.value(), typeField.getSearchValue().get(0));
SearchDateField field1 = searchBasic.getTranDate();
assertNull(field1.getOperator());
assertNull(field1.getSearchValue());
assertNull(field1.getSearchValue2());
assertNotNull(field1.getPredefinedSearchValue());
Assert.assertEquals(SearchDate.LAST_BUSINESS_WEEK, field1.getPredefinedSearchValue());
SearchCustomFieldList customFieldList = searchBasic.getCustomFieldList();
assertNotNull(customFieldList);
assertNotNull(customFieldList.getCustomField());
Assert.assertEquals(1, customFieldList.getCustomField().size());
SearchDateCustomField customField1 = (SearchDateCustomField) customFieldList.getCustomField().get(0);
assertNull(customField1.getOperator());
assertNull(customField1.getSearchValue());
assertNull(customField1.getSearchValue2());
assertNotNull(customField1.getPredefinedSearchValue());
Assert.assertEquals(SearchDate.LAST_BUSINESS_WEEK, customField1.getPredefinedSearchValue());
}
use of org.talend.components.netsuite.client.search.SearchQuery in project components by Talend.
the class SearchQueryTest method testSearchForSpecialRecordTypes.
@Test
public void testSearchForSpecialRecordTypes() throws Exception {
SearchQuery s1 = clientService.newSearch();
s1.target("Address");
s1.condition(new SearchCondition("Country", "List.anyOf", Arrays.asList("Ukraine")));
s1.condition(new SearchCondition("CustomStringField1", "String.contains", Arrays.asList("abc")));
SearchRecord sr1 = (SearchRecord) s1.toNativeQuery();
assertNotNull(sr1);
Assert.assertEquals(AddressSearchBasic.class, sr1.getClass());
AddressSearchBasic search = (AddressSearchBasic) sr1;
assertNotNull(search.getCountry());
SearchEnumMultiSelectField field1 = search.getCountry();
assertNotNull(field1);
Assert.assertEquals(SearchEnumMultiSelectFieldOperator.ANY_OF, field1.getOperator());
assertNotNull(field1.getSearchValue());
Assert.assertEquals(1, field1.getSearchValue().size());
Assert.assertEquals(Arrays.asList("Ukraine"), field1.getSearchValue());
SearchCustomFieldList customFieldList = search.getCustomFieldList();
assertNotNull(customFieldList);
assertNotNull(customFieldList.getCustomField());
Assert.assertEquals(1, customFieldList.getCustomField().size());
SearchStringCustomField customField1 = (SearchStringCustomField) customFieldList.getCustomField().get(0);
assertNotNull(customField1.getOperator());
Assert.assertEquals(SearchStringFieldOperator.CONTAINS, customField1.getOperator());
assertNotNull(customField1.getSearchValue());
Assert.assertEquals("abc", customField1.getSearchValue());
}
use of org.talend.components.netsuite.client.search.SearchQuery 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);
}
}
Aggregations