Subversion Repositories eFlore/Applications.del

Rev

Rev 534 | Blame | Last modification | View Log | RSS feed

package org.tela_botanica.del.test.vues.comparaisoneflore;

import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.tela_botanica.del.client.services.rest.ImageService;
import org.tela_botanica.del.client.services.rest.VoteProtocoleService;
import org.tela_botanica.del.client.services.rest.async.ImagesParTaxonCallback;
import org.tela_botanica.del.client.utils.MockDatasource;
import org.tela_botanica.del.client.vues.comparaisoneflore.ComparaisonEflorePresenteur;
import org.tela_botanica.del.client.vues.comparaisoneflore.ComparaisonEflorePresenteur.Vue;

public class ComparaisonEflorePresenteurTest {

        private ComparaisonEflorePresenteur comparaisonEflorePresenteur;

        @Before
        public void setUp() {
                Vue vue = mock(Vue.class);
                ImageService imageService = Mockito.mock(ImageService.class);
                VoteProtocoleService voteProtocoleService = mock(VoteProtocoleService.class);

                doAnswer(new Answer<Void>() {
                        public Void answer(InvocationOnMock invocation) {
                                comparaisonEflorePresenteur.setImagesEflore(MockDatasource.getInstance().getImages(0, 10));
                                return null;
                        }
                }).when(imageService).getImagesEfloreParTaxon(Mockito.anyString(), Mockito.any(ImagesParTaxonCallback.class));

                comparaisonEflorePresenteur = new ComparaisonEflorePresenteur(vue, imageService);
                comparaisonEflorePresenteur.chargerObservationsEflore();

        }

        @Test
        public void testChargerImages() {
                assertTrue(comparaisonEflorePresenteur.getImagesEflore().size() == 10);
        }

}