WikibaseDataFetcher { public EntityDocument getEntityDocumentByTitle(String siteKey, String title) throws MediaWikiApiErrorException, IOException { return getEntityDocumentsByTitle(siteKey, title).get(title); } 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 testWbGetEntitiesTitle() throws IOException, MediaWikiApiErrorException { Map<String, String> parameters = new HashMap<>(); this.setStandardParameters(parameters); parameters.put("titles", "Douglas Adams"); parameters.put("sites", "enwiki"); con.setWebResourceFromPath(parameters, getClass(), "/wbgetentities-Douglas-Adams.json", CompressionType.NONE); EntityDocument result = wdf.getEntityDocumentByTitle("enwiki", "Douglas Adams"); assertEquals("Q42", result.getEntityId().getId()); }
@Test public void testWbGetEntitiesTitleEmpty() throws IOException, MediaWikiApiErrorException { Map<String, String> parameters = new HashMap<>(); this.setStandardParameters(parameters); parameters.put("titles", "1234567890"); parameters.put("sites", "dewiki"); con.setWebResourceFromPath(parameters, getClass(), "/wbgetentities-1234567890-missing.json", CompressionType.NONE); EntityDocument result = wdf.getEntityDocumentByTitle("dewiki", "1234567890"); assertNull(result); }
@Test public void testWbGetMediaInfoEntityFromTitle() throws IOException, MediaWikiApiErrorException { Map<String, String> parameters = new HashMap<>(); this.setStandardParameters(parameters); parameters.put("titles", "File:RandomImage 4658098723742867.jpg"); parameters.put("sites", "commonswiki"); con.setWebResourceFromPath(parameters, getClass(), "/wbgetentities-RandomImage.jpg.json", CompressionType.NONE); EntityDocument result = wdf.getEntityDocumentByTitle("commonswiki", "File:RandomImage 4658098723742867.jpg"); assertEquals("M65057", result.getEntityId().getId()); }
@Test public void testWbGetVirtualMediaInfoEntityFromTitle() throws IOException, MediaWikiApiErrorException { Map<String, String> parameters = new HashMap<>(); this.setStandardParameters(parameters); parameters.put("titles", "File:Test.jpg"); parameters.put("sites", "commonswiki"); con.setWebResourceFromPath(parameters, getClass(), "/wbgetentities-virtual-Test.jpg.json", CompressionType.NONE); EntityDocument result = wdf.getEntityDocumentByTitle("commonswiki", "File:Test.jpg"); assertEquals("M4215516", result.getEntityId().getId()); }