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;
|
838 |
aurelien |
16 |
import org.tela_botanica.del.client.modeles.Observation;
|
275 |
aurelien |
17 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
|
|
18 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
|
|
19 |
import org.tela_botanica.del.client.services.CalculVoteDeterminationService;
|
|
|
20 |
|
|
|
21 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
22 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
|
|
23 |
import com.google.gwt.event.shared.GwtEvent;
|
|
|
24 |
import com.google.gwt.event.shared.HandlerRegistration;
|
|
|
25 |
import com.google.gwt.user.client.ui.IsWidget;
|
|
|
26 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
27 |
|
|
|
28 |
public class BarreRepartitionVotePresenteurTest {
|
|
|
29 |
|
|
|
30 |
private BarreRepartitionVotePresenteur barreRepartitionVotePresenteur;
|
307 |
aurelien |
31 |
private BarreRepartitionVotePresenteur.Vue vue;
|
275 |
aurelien |
32 |
|
|
|
33 |
@Before
|
|
|
34 |
public void setUp() {
|
|
|
35 |
|
534 |
benjamin |
36 |
vue = mock(Vue.class, Mockito.RETURNS_DEEP_STUBS);
|
307 |
aurelien |
37 |
barreRepartitionVotePresenteur = new BarreRepartitionVotePresenteur(vue);
|
275 |
aurelien |
38 |
|
|
|
39 |
VoteDetermination voteDetermination = new VoteDetermination();
|
|
|
40 |
voteDetermination.setVote(1);
|
|
|
41 |
voteDetermination.setDate(new Date());
|
|
|
42 |
voteDetermination.setContributeur("benjamin");
|
|
|
43 |
|
838 |
aurelien |
44 |
PropositionDetermination propositionDetermination = new PropositionDetermination(new Observation());
|
275 |
aurelien |
45 |
propositionDetermination.setEspece("Iris lutescens subsp. lutescens");
|
882 |
aurelien |
46 |
propositionDetermination.setContributeur(new Contributeur("1", "contrib", "test", "contrib@test.com"));
|
275 |
aurelien |
47 |
propositionDetermination.setId("1");
|
|
|
48 |
propositionDetermination.ajouterVoteDetermination(voteDetermination);
|
|
|
49 |
|
|
|
50 |
MoyenneVote moyenneVote = CalculVoteDeterminationService.calculerVoteDetermination(propositionDetermination);
|
|
|
51 |
barreRepartitionVotePresenteur.afficherVotes(moyenneVote);
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
@Test
|
|
|
55 |
public void testVoter() {
|
|
|
56 |
assertEquals("Iris lutescens subsp. lutescens", barreRepartitionVotePresenteur.getMoyenneVote().getIntituleAssocie());
|
|
|
57 |
assertEquals(100, barreRepartitionVotePresenteur.getMoyenneVote().getScore());
|
|
|
58 |
barreRepartitionVotePresenteur.voter(false);
|
|
|
59 |
assertEquals(50, barreRepartitionVotePresenteur.getMoyenneVote().getScore());
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
}
|