Search in sources :

Example 1 with Item

use of com.opentext.ia.sdk.dto.query.Item in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class WhenUsingInfoArchive method shouldSearchSuccessfully.

@Test
void shouldSearchSuccessfully() throws IOException {
    SearchResults searchResults = mock(SearchResults.class);
    when(searchResults.getUri("next")).thenReturn(null);
    when(restClient.post(anyString(), eq(SearchResults.class), anyString(), eq(MediaTypes.XML))).thenReturn(searchResults);
    SearchQuery searchQuery = new SearchQuery();
    List<Item> items = new ArrayList<>();
    items.add(new Comparison("from", Operator.EQUAL, ""));
    items.add(new Comparison("recipient", Operator.EQUAL, ""));
    List<String> dates = new ArrayList<>();
    dates.add("2014-04-27");
    dates.add("2016-10-11");
    items.add(new Comparison("sentDate", Operator.BETWEEN, dates));
    items.add(new Comparison("fromCountry", Operator.STARTS_WITH, ""));
    items.add(new Comparison("toCountry", Operator.NOT_EQUAL, ""));
    searchQuery.setItems(items);
    SearchComposition searchComparison = new SearchComposition();
    Map<String, Link> searchComparisonLinks = new HashMap<>();
    Link compositionLink = new Link();
    compositionLink.setHref(randomString());
    searchComparisonLinks.put("self", compositionLink);
    searchComparison.setLinks(searchComparisonLinks);
    configureServer();
    SearchResults result = archiveClient.search(searchQuery, searchComparison);
    assertEquals(searchResults, result);
}
Also used : SearchQuery(com.opentext.ia.sdk.dto.query.SearchQuery) Item(com.opentext.ia.sdk.dto.query.Item) Comparison(com.opentext.ia.sdk.dto.query.Comparison) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) StringContains.containsString(org.hamcrest.core.StringContains.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Link(com.opentext.ia.sdk.support.http.rest.Link) Test(org.junit.jupiter.api.Test)

Aggregations

Comparison (com.opentext.ia.sdk.dto.query.Comparison)1 Item (com.opentext.ia.sdk.dto.query.Item)1 SearchQuery (com.opentext.ia.sdk.dto.query.SearchQuery)1 Link (com.opentext.ia.sdk.support.http.rest.Link)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 StringContains.containsString (org.hamcrest.core.StringContains.containsString)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1