Search in sources :

Example 1 with SearchEnumMultiSelectField

use of com.netsuite.webservices.test.platform.core.SearchEnumMultiSelectField 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());
}
Also used : SearchQuery(org.talend.components.netsuite.client.search.SearchQuery) SearchBooleanCustomField(com.netsuite.webservices.test.platform.core.SearchBooleanCustomField) SearchStringCustomField(com.netsuite.webservices.test.platform.core.SearchStringCustomField) SearchCustomFieldList(com.netsuite.webservices.test.platform.core.SearchCustomFieldList) SearchLongCustomField(com.netsuite.webservices.test.platform.core.SearchLongCustomField) AccountSearchBasic(com.netsuite.webservices.test.platform.common.AccountSearchBasic) AccountSearch(com.netsuite.webservices.test.lists.accounting.AccountSearch) SearchRecord(com.netsuite.webservices.test.platform.core.SearchRecord) SearchBooleanField(com.netsuite.webservices.test.platform.core.SearchBooleanField) SearchCondition(org.talend.components.netsuite.client.search.SearchCondition) SearchDoubleField(com.netsuite.webservices.test.platform.core.SearchDoubleField) SearchStringField(com.netsuite.webservices.test.platform.core.SearchStringField) SearchEnumMultiSelectField(com.netsuite.webservices.test.platform.core.SearchEnumMultiSelectField) Test(org.junit.Test)

Example 2 with SearchEnumMultiSelectField

use of com.netsuite.webservices.test.platform.core.SearchEnumMultiSelectField 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());
}
Also used : SearchQuery(org.talend.components.netsuite.client.search.SearchQuery) TransactionSearch(com.netsuite.webservices.test.transactions.sales.TransactionSearch) SearchRecord(com.netsuite.webservices.test.platform.core.SearchRecord) SearchDateCustomField(com.netsuite.webservices.test.platform.core.SearchDateCustomField) SearchCondition(org.talend.components.netsuite.client.search.SearchCondition) SearchDateField(com.netsuite.webservices.test.platform.core.SearchDateField) TransactionSearchBasic(com.netsuite.webservices.test.platform.common.TransactionSearchBasic) SearchCustomFieldList(com.netsuite.webservices.test.platform.core.SearchCustomFieldList) SearchEnumMultiSelectField(com.netsuite.webservices.test.platform.core.SearchEnumMultiSelectField) Test(org.junit.Test)

Example 3 with SearchEnumMultiSelectField

use of com.netsuite.webservices.test.platform.core.SearchEnumMultiSelectField 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());
}
Also used : SearchQuery(org.talend.components.netsuite.client.search.SearchQuery) SearchRecord(com.netsuite.webservices.test.platform.core.SearchRecord) AddressSearchBasic(com.netsuite.webservices.test.platform.common.AddressSearchBasic) SearchCondition(org.talend.components.netsuite.client.search.SearchCondition) SearchStringCustomField(com.netsuite.webservices.test.platform.core.SearchStringCustomField) SearchCustomFieldList(com.netsuite.webservices.test.platform.core.SearchCustomFieldList) SearchEnumMultiSelectField(com.netsuite.webservices.test.platform.core.SearchEnumMultiSelectField) Test(org.junit.Test)

Example 4 with SearchEnumMultiSelectField

use of com.netsuite.webservices.test.platform.core.SearchEnumMultiSelectField in project components by Talend.

the class SearchFieldAdaptersTest method testAdapterForEnumMultiSelectSearchField.

@Test
public void testAdapterForEnumMultiSelectSearchField() {
    SearchEnumMultiSelectFieldAdapter adapter1 = new SearchEnumMultiSelectFieldAdapter(basicMetaData, SearchFieldType.SELECT, SearchEnumMultiSelectField.class);
    SearchEnumMultiSelectField field1 = (SearchEnumMultiSelectField) adapter1.populate(null, "List.anyOf", Arrays.asList("abc"));
    assertNotNull(field1);
    assertEquals(SearchEnumMultiSelectFieldOperator.ANY_OF, field1.getOperator());
    assertNotNull(field1.getSearchValue());
    assertEquals(1, field1.getSearchValue().size());
    assertEquals("abc", field1.getSearchValue().get(0));
    field1 = (SearchEnumMultiSelectField) adapter1.populate(null, "List.noneOf", Collections.emptyList());
    assertEquals(SearchEnumMultiSelectFieldOperator.NONE_OF, field1.getOperator());
    assertNotNull(field1.getSearchValue());
    assertEquals(0, field1.getSearchValue().size());
    SearchEnumMultiSelectFieldAdapter adapter2 = new SearchEnumMultiSelectFieldAdapter(basicMetaData, SearchFieldType.CUSTOM_SELECT, SearchEnumMultiSelectCustomField.class);
    SearchEnumMultiSelectCustomField field2 = (SearchEnumMultiSelectCustomField) adapter2.populate(null, "List.anyOf", Arrays.asList("qwerty"));
    assertNotNull(field2);
    assertEquals(SearchEnumMultiSelectFieldOperator.ANY_OF, field2.getOperator());
    assertEquals(1, field2.getSearchValue().size());
    assertEquals("qwerty", field2.getSearchValue().get(0));
}
Also used : SearchEnumMultiSelectCustomField(com.netsuite.webservices.test.platform.core.SearchEnumMultiSelectCustomField) SearchEnumMultiSelectField(com.netsuite.webservices.test.platform.core.SearchEnumMultiSelectField) Test(org.junit.Test)

Aggregations

SearchEnumMultiSelectField (com.netsuite.webservices.test.platform.core.SearchEnumMultiSelectField)4 Test (org.junit.Test)4 SearchCustomFieldList (com.netsuite.webservices.test.platform.core.SearchCustomFieldList)3 SearchRecord (com.netsuite.webservices.test.platform.core.SearchRecord)3 SearchCondition (org.talend.components.netsuite.client.search.SearchCondition)3 SearchQuery (org.talend.components.netsuite.client.search.SearchQuery)3 SearchStringCustomField (com.netsuite.webservices.test.platform.core.SearchStringCustomField)2 AccountSearch (com.netsuite.webservices.test.lists.accounting.AccountSearch)1 AccountSearchBasic (com.netsuite.webservices.test.platform.common.AccountSearchBasic)1 AddressSearchBasic (com.netsuite.webservices.test.platform.common.AddressSearchBasic)1 TransactionSearchBasic (com.netsuite.webservices.test.platform.common.TransactionSearchBasic)1 SearchBooleanCustomField (com.netsuite.webservices.test.platform.core.SearchBooleanCustomField)1 SearchBooleanField (com.netsuite.webservices.test.platform.core.SearchBooleanField)1 SearchDateCustomField (com.netsuite.webservices.test.platform.core.SearchDateCustomField)1 SearchDateField (com.netsuite.webservices.test.platform.core.SearchDateField)1 SearchDoubleField (com.netsuite.webservices.test.platform.core.SearchDoubleField)1 SearchEnumMultiSelectCustomField (com.netsuite.webservices.test.platform.core.SearchEnumMultiSelectCustomField)1 SearchLongCustomField (com.netsuite.webservices.test.platform.core.SearchLongCustomField)1 SearchStringField (com.netsuite.webservices.test.platform.core.SearchStringField)1 TransactionSearch (com.netsuite.webservices.test.transactions.sales.TransactionSearch)1