WikibaseDataFetcher { public Map<String, MediaInfoIdValue> getMediaInfoIdsByFileName(String... fileNames) throws IOException, MediaWikiApiErrorException { return getMediaInfoIdsByFileName(Arrays.asList(fileNames)); } 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 testGetMediaInfoIdDuplicated1() throws IOException, MediaWikiApiErrorException { Map<String, String> parameters = new HashMap<>(); parameters.put("action", "query"); parameters.put("format", "json"); parameters.put("titles", "File:Cat.jpg|File:Cat.jpg"); con.setWebResourceFromPath(parameters, getClass(), "/query-Cat.jpg.json", CompressionType.NONE); Map<String, MediaInfoIdValue> result = wdf.getMediaInfoIdsByFileName("Cat.jpg", "Cat.jpg"); assertEquals(result.size(), 1); assertEquals("M32455073", result.get("Cat.jpg").getId()); }
@Test public void testGetMediaInfoIdDuplicated2() throws IOException, MediaWikiApiErrorException { Map<String, String> parameters = new HashMap<>(); parameters.put("action", "query"); parameters.put("format", "json"); parameters.put("titles", "File:Cat.jpg|File:Cat.jpg"); con.setWebResourceFromPath(parameters, getClass(), "/query-Cat.jpg.json", CompressionType.NONE); Map<String, MediaInfoIdValue> result = wdf.getMediaInfoIdsByFileName("Cat.jpg", "File:Cat.jpg"); assertEquals(result.size(), 2); assertEquals("M32455073", result.get("Cat.jpg").getId()); assertEquals("M32455073", result.get("File:Cat.jpg").getId()); }
@Test public void getGetMediaInfoIdsSplitted() throws IOException, MediaWikiApiErrorException { Map<String, String> parameters1 = new HashMap<>(); parameters1.put("action", "query"); parameters1.put("format", "json"); parameters1.put("titles", "File:Cat.jpg"); con.setWebResourceFromPath(parameters1, getClass(), "/query-Cat.jpg.json", CompressionType.NONE); Map<String, String> parameters2 = new HashMap<>(); parameters2.put("action", "query"); parameters2.put("format", "json"); parameters2.put("titles", "File:Albert Einstein Head.jpg"); con.setWebResourceFromPath(parameters2, getClass(), "/query-Albert Einstein Head.jpg.json", CompressionType.NONE); wdf.maxListSize = 1; Map<String, MediaInfoIdValue> result = wdf.getMediaInfoIdsByFileName("Cat.jpg", "File:Albert Einstein Head.jpg"); assertEquals(2, result.size()); assertEquals("M32455073", result.get("Cat.jpg").getId()); assertEquals("M925243", result.get("File:Albert Einstein Head.jpg").getId()); }