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);
}
Aggregations