use of com.netsuite.webservices.test.platform.core.SearchStringCustomField in project components by Talend.
the class SearchQueryTest method testBasics.
@Test
public void testBasics() throws Exception {
SearchQuery s1 = clientService.newSearch();
s1.target("Account");
s1.condition(new SearchCondition("Type", "List.anyOf", Arrays.asList("bank")));
s1.condition(new SearchCondition("Balance", "Double.greaterThanOrEqualTo", Arrays.asList("10000.0", "")));
s1.condition(new SearchCondition("LegalName", "String.contains", Arrays.asList("Acme")));
s1.condition(new SearchCondition("IsInactive", "Boolean", Arrays.asList("true")));
s1.condition(new SearchCondition("CustomBooleanField1", "Boolean", Arrays.asList("true")));
s1.condition(new SearchCondition("CustomStringField1", "String.doesNotContain", Arrays.asList("Foo")));
s1.condition(new SearchCondition("CustomLongField1", "Long.lessThan", Arrays.asList("100", "")));
SearchRecord sr1 = (SearchRecord) s1.toNativeQuery();
assertNotNull(sr1);
Assert.assertEquals(AccountSearch.class, sr1.getClass());
AccountSearch search = (AccountSearch) sr1;
assertNotNull(search.getBasic());
AccountSearchBasic searchBasic = search.getBasic();
assertNotNull(searchBasic.getBalance());
SearchEnumMultiSelectField typeField = searchBasic.getType();
Assert.assertEquals(SearchEnumMultiSelectFieldOperator.ANY_OF, typeField.getOperator());
Assert.assertEquals(Arrays.asList("bank"), typeField.getSearchValue());
SearchDoubleField balanceField = searchBasic.getBalance();
Assert.assertEquals(SearchDoubleFieldOperator.GREATER_THAN_OR_EQUAL_TO, balanceField.getOperator());
Assert.assertEquals(Double.valueOf(10000.0), balanceField.getSearchValue());
SearchBooleanField isInactiveField = searchBasic.getIsInactive();
Assert.assertEquals(Boolean.TRUE, isInactiveField.getSearchValue());
SearchStringField legalNameField = searchBasic.getLegalName();
Assert.assertEquals(SearchStringFieldOperator.CONTAINS, legalNameField.getOperator());
Assert.assertEquals("Acme", legalNameField.getSearchValue());
SearchCustomFieldList customFieldList = searchBasic.getCustomFieldList();
assertNotNull(customFieldList);
assertNotNull(customFieldList.getCustomField());
Assert.assertEquals(3, customFieldList.getCustomField().size());
SearchBooleanCustomField customBooleanField1 = (SearchBooleanCustomField) customFieldList.getCustomField().get(0);
Assert.assertEquals(Boolean.TRUE, customBooleanField1.getSearchValue());
SearchStringCustomField customStringField1 = (SearchStringCustomField) customFieldList.getCustomField().get(1);
Assert.assertEquals(SearchStringFieldOperator.DOES_NOT_CONTAIN, customStringField1.getOperator());
Assert.assertEquals("Foo", customStringField1.getSearchValue());
SearchLongCustomField customLongField1 = (SearchLongCustomField) customFieldList.getCustomField().get(2);
Assert.assertEquals(SearchLongFieldOperator.LESS_THAN, customLongField1.getOperator());
Assert.assertEquals(Long.valueOf(100), customLongField1.getSearchValue());
}
use of com.netsuite.webservices.test.platform.core.SearchStringCustomField in project components by Talend.
the class SearchFieldAdaptersTest method testAdapterForStringSearchField.
@Test
public void testAdapterForStringSearchField() {
SearchStringFieldAdapter adapter1 = new SearchStringFieldAdapter(basicMetaData, SearchFieldType.STRING, SearchStringField.class);
SearchStringField field1 = (SearchStringField) adapter1.populate(null, "String.startsWith", Arrays.asList("abc"));
assertNotNull(field1);
assertEquals(SearchStringFieldOperator.STARTS_WITH, field1.getOperator());
assertEquals("abc", field1.getSearchValue());
field1 = (SearchStringField) adapter1.populate(null, "String.isNot", null);
assertEquals(SearchStringFieldOperator.IS_NOT, field1.getOperator());
assertNull(field1.getSearchValue());
SearchStringFieldAdapter adapter2 = new SearchStringFieldAdapter(basicMetaData, SearchFieldType.CUSTOM_STRING, SearchStringCustomField.class);
SearchStringCustomField field2 = (SearchStringCustomField) adapter2.populate(null, "String.contains", Arrays.asList("qwerty"));
assertNotNull(field2);
assertEquals(SearchStringFieldOperator.CONTAINS, field2.getOperator());
assertEquals("qwerty", field2.getSearchValue());
}
use of com.netsuite.webservices.test.platform.core.SearchStringCustomField 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());
}
Aggregations