Search in sources :

Example 1 with ImageSearch

use of org.eol.globi.service.ImageSearch in project eol-globi-data by jhpoelen.

the class ImageServiceTest method taxonFoundButNoExternalId.

@Test
public void taxonFoundButNoExternalId() throws IOException {
    imageService.setTaxonSearch(new TaxonSearch() {

        @Override
        public Map<String, String> findTaxon(String scientificName, HttpServletRequest request) throws IOException {
            return new HashMap<String, String>() {

                {
                    put(PropertyAndValueDictionary.EXTERNAL_ID, "no:match");
                    put(PropertyAndValueDictionary.NAME, "some latin name");
                }
            };
        }

        @Override
        public Map<String, String> findTaxonWithImage(String scientificName) throws IOException {
            return null;
        }
    });
    imageService.setImageSearch(new ImageSearch() {

        @Override
        public TaxonImage lookupImageForExternalId(String externalId) {
            return null;
        }
    });
    TaxonImage image = imageService.findTaxonImagesForTaxonWithName("some name");
    assertThat(image.getInfoURL(), is(nullValue()));
    assertThat(image.getScientificName(), is("some latin name"));
    assertThat(image.getCommonName(), is(nullValue()));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ImageSearch(org.eol.globi.service.ImageSearch) TaxonImage(org.eol.globi.domain.TaxonImage) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 2 with ImageSearch

use of org.eol.globi.service.ImageSearch in project eol-globi-data by jhpoelen.

the class ImageServiceTest method init.

@Before
public void init() {
    imageService = new ImageService();
    imageService.setTaxonSearch(new TaxonSearch() {

        @Override
        public Map<String, String> findTaxon(String scientificName, HttpServletRequest request) throws IOException {
            return new HashMap<String, String>() {

                {
                    put(PropertyAndValueDictionary.EXTERNAL_ID, "EOL:123456");
                }
            };
        }

        @Override
        public Map<String, String> findTaxonWithImage(String scientificName) throws IOException {
            return null;
        }
    });
    imageService.setImageSearch(new ImageSearch() {

        @Override
        public TaxonImage lookupImageForExternalId(String externalId) {
            TaxonImage taxonImage = new TaxonImage();
            taxonImage.setCommonName("some common name for " + externalId);
            return taxonImage;
        }
    });
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ImageSearch(org.eol.globi.service.ImageSearch) TaxonImage(org.eol.globi.domain.TaxonImage) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) Before(org.junit.Before)

Example 3 with ImageSearch

use of org.eol.globi.service.ImageSearch in project eol-globi-data by jhpoelen.

the class ImageServiceTest method taxonFoundButNoImage.

@Test
public void taxonFoundButNoImage() throws IOException {
    imageService.setTaxonSearch(new TaxonSearch() {

        @Override
        public Map<String, String> findTaxon(String scientificName, HttpServletRequest request) throws IOException {
            return new HashMap<String, String>() {

                {
                    put(PropertyAndValueDictionary.EXTERNAL_ID, "EOL:123456");
                    put(PropertyAndValueDictionary.NAME, "some latin name");
                    put(PropertyAndValueDictionary.PATH, "path1 | path2");
                    put(PropertyAndValueDictionary.COMMON_NAMES, "one @en | zwei @de");
                }
            };
        }

        @Override
        public Map<String, String> findTaxonWithImage(String scientificName) throws IOException {
            return null;
        }
    });
    imageService.setImageSearch(new ImageSearch() {

        @Override
        public TaxonImage lookupImageForExternalId(String externalId) {
            TaxonImage taxonImage = new TaxonImage();
            taxonImage.setInfoURL("some info url");
            return taxonImage;
        }
    });
    TaxonImage image = imageService.findTaxonImagesForTaxonWithName("some name");
    assertThat(image.getInfoURL(), is("some info url"));
    assertThat(image.getScientificName(), is("some latin name"));
    assertThat(image.getCommonName(), is("one"));
    assertThat(image.getTaxonPath(), is("path1 | path2"));
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ImageSearch(org.eol.globi.service.ImageSearch) TaxonImage(org.eol.globi.domain.TaxonImage) IOException(java.io.IOException) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 TaxonImage (org.eol.globi.domain.TaxonImage)3 ImageSearch (org.eol.globi.service.ImageSearch)3 Test (org.junit.Test)2 Before (org.junit.Before)1