Subversion Repositories eFlore/Applications.del

Rev

Rev 882 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.del.test.composants.votes;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;

import java.util.Date;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.tela_botanica.del.client.composants.votes.barrerepartition.BarreRepartitionVotePresenteur;
import org.tela_botanica.del.client.composants.votes.barrerepartition.BarreRepartitionVotePresenteur.Vue;
import org.tela_botanica.del.client.modeles.Contributeur;
import org.tela_botanica.del.client.modeles.MoyenneVote;
import org.tela_botanica.del.client.modeles.Observation;
import org.tela_botanica.del.client.modeles.PropositionDetermination;
import org.tela_botanica.del.client.modeles.VoteDetermination;
import org.tela_botanica.del.client.services.CalculVoteDeterminationService;
import org.tela_botanica.del.client.services.rest.VoteDeterminationService;

public class BarreRepartitionVotePresenteurTest {

        private BarreRepartitionVotePresenteur barreRepartitionVotePresenteur;
        private BarreRepartitionVotePresenteur.Vue vue;

        @Before
        public void setUp() {

                vue = mock(Vue.class, Mockito.RETURNS_DEEP_STUBS);
                VoteDeterminationService voteDeterminationService = Mockito.mock(VoteDeterminationService.class);
                barreRepartitionVotePresenteur = new BarreRepartitionVotePresenteur(vue, voteDeterminationService);

                VoteDetermination voteDetermination = new VoteDetermination();
                voteDetermination.setVote(1);
                voteDetermination.setDate(new Date());
                voteDetermination.setContributeur("benjamin");

                PropositionDetermination propositionDetermination = new PropositionDetermination(new Observation());
                propositionDetermination.setEspece("Iris lutescens subsp. lutescens");
                propositionDetermination.setContributeur(new Contributeur("1", "contrib", "test", "contrib@test.com"));
                propositionDetermination.setId("1");
                propositionDetermination.ajouterVoteDetermination(voteDetermination);

                MoyenneVote moyenneVote = CalculVoteDeterminationService.calculerVoteDetermination(propositionDetermination);
                barreRepartitionVotePresenteur.afficherVotes(moyenneVote);
        }

        @Test
        public void testVoter() {
                assertEquals("Iris lutescens subsp. lutescens", barreRepartitionVotePresenteur.getMoyenneVote().getIntituleAssocie());
                assertEquals(100, barreRepartitionVotePresenteur.getMoyenneVote().getScore());
                barreRepartitionVotePresenteur.voter(false);
                assertEquals(100, barreRepartitionVotePresenteur.getMoyenneVote().getScore());
        }

}