644 |
aurelien |
1 |
package org.tela_botanica.del.test.composants.votes;
|
275 |
aurelien |
2 |
|
|
|
3 |
import static org.junit.Assert.*;
|
307 |
aurelien |
4 |
import static org.mockito.Mockito.mock;
|
275 |
aurelien |
5 |
|
|
|
6 |
import java.util.Date;
|
|
|
7 |
|
|
|
8 |
import org.junit.Before;
|
|
|
9 |
import org.junit.Test;
|
307 |
aurelien |
10 |
import org.mockito.Mock;
|
534 |
benjamin |
11 |
import org.mockito.Mockito;
|
637 |
aurelien |
12 |
import org.tela_botanica.del.client.composants.votes.barrerepartition.BarreRepartitionVotePresenteur;
|
|
|
13 |
import org.tela_botanica.del.client.composants.votes.barrerepartition.BarreRepartitionVotePresenteur.Vue;
|
690 |
gduche |
14 |
import org.tela_botanica.del.client.modeles.Contributeur;
|
275 |
aurelien |
15 |
import org.tela_botanica.del.client.modeles.MoyenneVote;
|
|
|
16 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
|
|
17 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
|
|
18 |
import org.tela_botanica.del.client.services.CalculVoteDeterminationService;
|
|
|
19 |
|
|
|
20 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
21 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
|
|
22 |
import com.google.gwt.event.shared.GwtEvent;
|
|
|
23 |
import com.google.gwt.event.shared.HandlerRegistration;
|
|
|
24 |
import com.google.gwt.user.client.ui.IsWidget;
|
|
|
25 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
26 |
|
|
|
27 |
public class BarreRepartitionVotePresenteurTest {
|
|
|
28 |
|
|
|
29 |
private BarreRepartitionVotePresenteur barreRepartitionVotePresenteur;
|
307 |
aurelien |
30 |
private BarreRepartitionVotePresenteur.Vue vue;
|
275 |
aurelien |
31 |
|
|
|
32 |
@Before
|
|
|
33 |
public void setUp() {
|
|
|
34 |
|
534 |
benjamin |
35 |
vue = mock(Vue.class, Mockito.RETURNS_DEEP_STUBS);
|
307 |
aurelien |
36 |
barreRepartitionVotePresenteur = new BarreRepartitionVotePresenteur(vue);
|
275 |
aurelien |
37 |
|
|
|
38 |
VoteDetermination voteDetermination = new VoteDetermination();
|
|
|
39 |
voteDetermination.setVote(1);
|
|
|
40 |
voteDetermination.setDate(new Date());
|
|
|
41 |
voteDetermination.setContributeur("benjamin");
|
|
|
42 |
|
|
|
43 |
PropositionDetermination propositionDetermination = new PropositionDetermination();
|
|
|
44 |
propositionDetermination.setEspece("Iris lutescens subsp. lutescens");
|
690 |
gduche |
45 |
propositionDetermination.setContributeur(new Contributeur("contrib", "test", "contrib@test.com"));
|
275 |
aurelien |
46 |
propositionDetermination.setId("1");
|
|
|
47 |
propositionDetermination.ajouterVoteDetermination(voteDetermination);
|
|
|
48 |
|
|
|
49 |
MoyenneVote moyenneVote = CalculVoteDeterminationService.calculerVoteDetermination(propositionDetermination);
|
|
|
50 |
barreRepartitionVotePresenteur.afficherVotes(moyenneVote);
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
@Test
|
|
|
54 |
public void testVoter() {
|
|
|
55 |
assertEquals("Iris lutescens subsp. lutescens", barreRepartitionVotePresenteur.getMoyenneVote().getIntituleAssocie());
|
|
|
56 |
assertEquals(100, barreRepartitionVotePresenteur.getMoyenneVote().getScore());
|
|
|
57 |
barreRepartitionVotePresenteur.voter(false);
|
|
|
58 |
assertEquals(50, barreRepartitionVotePresenteur.getMoyenneVote().getScore());
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
}
|