### Question:
WikiDataImageSearch implements ImageSearch { @Override public TaxonImage lookupImageForExternalId(String externalId) throws IOException { return lookupImageForExternalId(externalId, () -> "en"); }  @Override TaxonImage lookupImageForExternalId(String externalId); @Override TaxonImage lookupImageForExternalId(String externalId, SearchContext context);  }### Answer:
@Test public void lookupLion() throws IOException { TaxonImage taxonImage = new WikiDataImageSearch().lookupImageForExternalId("WD:Q140"); assertNotNull(taxonImage); assertThat(taxonImage.getThumbnailURL(), startsWith("https: assertThat(taxonImage.getInfoURL(), is("https: assertThat(taxonImage.getCommonName(), is("African Lion, Lion @en")); }
@Test public void lookupLionByNCBI() throws IOException { TaxonImage taxonImage = new WikiDataImageSearch().lookupImageForExternalId("NCBI:9689"); assertNotNull(taxonImage); assertThat(taxonImage.getThumbnailURL(), startsWith("https: assertThat(taxonImage.getInfoURL(), is("http: assertThat(taxonImage.getCommonName(), is("African Lion, Lion @en")); }
@Test public void lookupLionByITIS() throws IOException { TaxonImage taxonImage = new WikiDataImageSearch().lookupImageForExternalId("ITIS:183803"); assertNotNull(taxonImage); assertThat(taxonImage.getThumbnailURL(), startsWith("https: assertThat(taxonImage.getInfoURL(), is("http: assertThat(taxonImage.getCommonName(), is("African Lion, Lion @en")); }
@Test public void lookupRedVole() throws IOException { TaxonImage taxonImage = new WikiDataImageSearch().lookupImageForExternalId("WD:Q608821"); assertNotNull(taxonImage); assertThat(taxonImage.getCommonName(), is("Northern Red-backed Vole, Red Vole @en")); assertThat(taxonImage.getInfoURL(), is("https: }
@Test public void northernBat() throws IOException { TaxonImage taxonImage = new WikiDataImageSearch().lookupImageForExternalId("NBN:NHMSYS0000528007"); assertNotNull(taxonImage); assertThat(taxonImage.getCommonName(), is("Northern Bat @en")); assertThat(taxonImage.getInfoURL(), is("http: }
@Test public void lookupLionJapanese() throws IOException { TaxonImage taxonImage = new WikiDataImageSearch().lookupImageForExternalId("WD:Q140", new SearchContext() { @Override public String getPreferredLanguage() { return "ja"; } }); assertNotNull(taxonImage); assertThat(taxonImage.getThumbnailURL(), startsWith("https: assertThat(taxonImage.getInfoURL(), is("https: assertThat(taxonImage.getCommonName(), is("ライオン (raion) @ja")); }
@Test public void lookupLionUnknownLanguage() throws IOException { TaxonImage taxonImage = new WikiDataImageSearch().lookupImageForExternalId("WD:Q140", new SearchContext() { @Override public String getPreferredLanguage() { return "foo"; } }); assertNotNull(taxonImage); assertThat(taxonImage.getThumbnailURL(), startsWith("https: assertThat(taxonImage.getInfoURL(), is("https: assertThat(taxonImage.getCommonName(), is(nullValue())); }
@Test public void lookupUnsupported() throws IOException { TaxonImage taxonImage = new WikiDataImageSearch().lookupImageForExternalId("foo:bar"); assertNull(taxonImage); }