Subversion Repositories eFlore/Applications.del

Rev

Rev 690 | 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.*;
import static org.mockito.Mockito.mock;

import java.util.Date;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
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 com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;

public class BarreRepartitionVotePresenteurTest {

        private BarreRepartitionVotePresenteur barreRepartitionVotePresenteur;
        private BarreRepartitionVotePresenteur.Vue vue;
        
        @Before
        public void setUp() {
                
                vue = mock(Vue.class, Mockito.RETURNS_DEEP_STUBS);
                barreRepartitionVotePresenteur = new BarreRepartitionVotePresenteur(vue);
                
                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("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(50, barreRepartitionVotePresenteur.getMoyenneVote().getScore());
        }

}