WbSearchEntitiesAction { public List<WbSearchEntitiesResult> wbSearchEntities(WbGetEntitiesSearchData properties) throws MediaWikiApiErrorException, IOException { return wbSearchEntities(properties.search, properties.language, properties.strictlanguage, properties.type, properties.limit, properties.offset); } WbSearchEntitiesAction(ApiConnection connection, String siteUri); List<WbSearchEntitiesResult> wbSearchEntities(WbGetEntitiesSearchData properties); List<WbSearchEntitiesResult> wbSearchEntities(String search, String language,
                                                         Boolean strictLanguage, String type, Long limit, Long offset);  }
@Test public void testWbSearchEntities() throws MediaWikiApiErrorException, IOException { List<WbSearchEntitiesResult> results = action.wbSearchEntities("abc", "en", null, null, null, null); assertEquals(7, results.size()); WbSearchEntitiesResult firstResult = results.get(0); assertEquals("Q169889", firstResult.getEntityId()); assertEquals(firstResult.getConceptUri(), "http: assertEquals(firstResult.getUrl(), " assertEquals("Q169889", firstResult.getTitle()); assertEquals(170288, firstResult.getPageId()); assertEquals("American Broadcasting Company", firstResult.getLabel()); assertEquals("American broadcast television network", firstResult.getDescription()); WbSearchEntitiesResult.Match match = new JacksonWbSearchEntitiesResult.JacksonMatch( "alias", "en", "ABC"); assertEquals(match, firstResult.getMatch()); List<String> aliases = new ArrayList<>(); aliases.add("ABC"); assertEquals(aliases, firstResult.getAliases()); }
@Test public void testWbSearchEntitiesEmpty() throws MediaWikiApiErrorException, IOException { List<WbSearchEntitiesResult> results = action.wbSearchEntities( "some search string with no results", "en", null, null, null, null); assertTrue(results.isEmpty()); }
@Test(expected = IllegalArgumentException.class) public void testIdsAndTitles() throws MediaWikiApiErrorException, IOException { action.wbSearchEntities(null, "en", null, null, null, null); }
@Test(expected = IllegalArgumentException.class) public void testIdsAndSites() throws MediaWikiApiErrorException, IOException { action.wbSearchEntities("abc", null, null, null, null, null); }