WikibaseDataFetcher { public Map<String, EntityDocument> getEntityDocuments(String... entityIds) throws MediaWikiApiErrorException, IOException { return getEntityDocuments(Arrays.asList(entityIds)); } WikibaseDataFetcher(ApiConnection connection, String siteUri); static WikibaseDataFetcher getWikidataDataFetcher(); static WikibaseDataFetcher getWikimediaCommonsDataFetcher(); DocumentDataFilter getFilter(); EntityDocument getEntityDocument(String entityId); Map<String, EntityDocument> getEntityDocuments(String... entityIds); Map<String, EntityDocument> getEntityDocuments(List<String> entityIds); EntityDocument getEntityDocumentByTitle(String siteKey, String title); Map<String, EntityDocument> getEntityDocumentsByTitle(
			String siteKey, String... titles); Map<String, EntityDocument> getEntityDocumentsByTitle(
			String siteKey, List<String> titles); MediaInfoIdValue getMediaInfoIdByFileName(String fileName); Map<String, MediaInfoIdValue> getMediaInfoIdsByFileName(String... fileNames); Map<String, MediaInfoIdValue> getMediaInfoIdsByFileName(List<String> fileNames); List<WbSearchEntitiesResult> searchEntities(String search); List<WbSearchEntitiesResult> searchEntities(String search, String language); List<WbSearchEntitiesResult> searchEntities(String search, Long limit); List<WbSearchEntitiesResult> searchEntities(String search, String language, Long limit); List<WbSearchEntitiesResult> searchEntities(WbGetEntitiesSearchData properties);  }
@Test public void testWbGetEntities() throws IOException, MediaWikiApiErrorException { Map<String, String> parameters = new HashMap<>(); setStandardParameters(parameters); parameters.put("ids", "Q6|Q42|P31"); con.setWebResourceFromPath(parameters, this.getClass(), "/wbgetentities-Q6-Q42-P31.json", CompressionType.NONE); Map<String, EntityDocument> results = wdf.getEntityDocuments("Q6", "Q42", "P31"); assertEquals(2, results.size()); assertFalse(results.containsKey("Q6")); assertTrue(results.containsKey("Q42")); assertTrue(results.containsKey("P31")); }
@Test(expected = NoSuchEntityErrorException.class) public void testWbGetEntitiesError() throws IOException, MediaWikiApiErrorException { Map<String, String> parameters = new HashMap<>(); setStandardParameters(parameters); parameters.put("ids", "bogus"); con.setWebResourceFromPath(parameters, getClass(), "/wbgetentities-bogus.json", CompressionType.NONE); wdf.getEntityDocuments("bogus"); }
@Test public void testWbGetEntitiesEmpty() throws IOException, MediaWikiApiErrorException { Map<String, EntityDocument> results = wdf .getEntityDocuments(Collections.emptyList()); assertEquals(0, results.size()); }
@Test public void testWbGetEntitesSplitted() throws IOException, MediaWikiApiErrorException { List<String> entityIds = Arrays.asList("Q6", "Q42", "P31", "Q1"); Map<String, String> parameters1 = new HashMap<>(); setStandardParameters(parameters1); parameters1.put("ids", "Q6|Q42|P31"); Map<String, String> parameters2 = new HashMap<>(); setStandardParameters(parameters2); parameters2.put("ids", "Q1"); con.setWebResourceFromPath(parameters1, this.getClass(), "/wbgetentities-Q6-Q42-P31.json", CompressionType.NONE); con.setWebResourceFromPath(parameters2, this.getClass(), "/wbgetentities-Q1.json", CompressionType.NONE); wdf.maxListSize = 3; Map<String, EntityDocument> results = wdf.getEntityDocuments(entityIds); assertEquals(3, results.size()); assertFalse(results.containsKey("Q6")); assertTrue(results.containsKey("Q1")); assertTrue(results.containsKey("P31")); assertTrue(results.containsKey("Q42")); }