/** * Searches for the query and compares the result with the given item object for equality. * * @param query The query for which is searched * @param itemToCompare The item to which the result is compared * @throws Exception */ private void searchAndCompareResults(MetadataSearchQuery query, ItemVO itemToCompare) throws Exception { ItemContainerSearchResult result = itemContainerSearch.searchForItemContainer(query); List<SearchResultElement> resultList = result.getResultList(); assertEquals("Wrong number of search results", 1, resultList.size()); ItemVO resultItem = (ItemVO) resultList.get(0); ObjectComparator oc = new ObjectComparator(new ItemVO(itemToCompare), new ItemVO(resultItem)); assertTrue(oc.toString(), oc.isEqual()); }
/** * Searches for an title that should not exist. * * @throws Exception */ @Test public void testSearchNoResults() throws Exception { // search the item for source String testTitle = "Der kleine Prinz" + System.nanoTime(); MetadataSearchQuery query = getStandardQuery(); query.addCriterion( new MetadataSearchCriterion(CriterionType.TITLE, testTitle, LogicalOperator.AND)); ItemContainerSearchResult result = itemContainerSearch.searchForItemContainer(query); List<SearchResultElement> resultList = result.getResultList(); assertEquals("Wrong number of search results", 0, resultList.size()); }